Disable DTR in pyserial from code

前端 未结 4 1511
無奈伤痛
無奈伤痛 2020-12-02 02:13

I\'m trying to use pyserial to send data to an arduino. But when I open the COM port it sets DTR low and resets the board. However, I have my arduino code setup such that I

4条回答
  •  北海茫月
    2020-12-02 02:20

    Disabling DTR does not work for me:
    ser.dtr = None
    (Linux 4.4.0 x86_64 / Python 2.7.12 / PySerial 3.4)

    But this works:

    import serial
    import termios
    
    port = '/dev/ttyACM0'
    f = open(port)
    attrs = termios.tcgetattr(f)
    attrs[2] = attrs[2] & ~termios.HUPCL
    termios.tcsetattr(f, termios.TCSAFLUSH, attrs)
    f.close()
    se = serial.Serial()
    se.baudrate = 115200
    se.port = port
    print 'dtr =', se.dtr
    se.open()
    

    I found it here.

提交回复
热议问题