开发者

How do I send single character ASCII data to a serial port with python

开发者 https://www.devze.com 2023-01-20 13:04 出处:网络
I\'v looked at pyserial but I can\'t seem to figure out开发者_如何转开发 how to do it. I only need to send one at a time? Please help?Using pySerial:

I'v looked at pyserial but I can't seem to figure out开发者_如何转开发 how to do it. I only need to send one at a time? Please help?


Using pySerial:

Python 2.x:

import serial
byte = 42
out = serial.Serial("/dev/ttyS0")  # "COM1" on Windows
out.write(chr(byte))

Python 3.x:

import serial
byte = 42
out = serial.Serial("/dev/ttyS0")  # "COM1" on Windows
out.write(bytes(byte))


Google says:

  1. http://pyserial.sourceforge.net/
  2. http://balder.prohosting.com/ibarona/en/python/uspp/uspp_en.html

if you're using Uspp; to write on serial port documentation says

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号