вторник, 1 мая 2012 г.

python serial usage

Do the UART connection with board or pc with serial module.


import serial
import array
l = [0x1, 0x2, 0x3]
t = array.array('B', l)
s = t.tostring()
ser = serial.Serial(0,115200) 
#ser = serial.Serial('/dev/ttyS0', 115200)
ser.write(s)
r = ser.read(5)
ser.close()
m = memoryview(r)
rl = m.tolist()
print rl

It is the simplest way...

Комментариев нет:

Отправить комментарий