<p>I am using python 3.6 with pySerial library to connect to the Hyrel System 30M 3D Printer. I am able to read the data from the device but unable to write any commands to it</p>

<p>Here is the code:</p>



<pre><code>    ser = serial.Serial()
    ser.port = 'COM4'
    ser.baudrate = 38400
    out = ser.readline()
    ser.write(b'M106 T14 S30\n') %This is the command to turn on the fan at 30% power
</code></pre>

<p>Can somebody suggest me how to write commands to printer through python</p>

[{'answer_id': 5343, 'author': 'mac', 'author_id': 9134, 'author_profile': 'https://3dprinting.stackexchange.com/users/9134', 'pm_score': 2, 'selected': False, 'text': '<p>If the one in your question is your <em>complete</em> code, a possibility is that your computer is just buffering the output for the serial port, withholding it in memory.  Try to add</p>\n\n<pre><code>ser.flush()\n</code></pre>\n\n<p>after your last line.  This command will... well... <em>flush</em> anything into the buffer through the actual connection.</p>\n'}, {'answer_id': 13840, 'author': 'Davo', 'author_id': 4922, 'author_profile': 'https://3dprinting.stackexchange.com/users/4922', 'pm_score': 0, 'selected': False, 'text': '<p>Sorry for the late answer, but with Repetrel v3 and later, we have the option for you to configure a secondary COM port, and relay G- or M-Code commands from your other source through the Repetrel software to the printer. Please contact us for assistance.</p>\n\n<p>Note: I work for Hyrel 3D.</p>\n'}]
['https://3dprinting.stackexchange.com/questions/5341', 'https://3dprinting.stackexchange.com', 'https://3dprinting.stackexchange.com/users/9736/']