1. 程式人生 > >使用python在openwrt下操作串列埠傳送十六進位制資料

使用python在openwrt下操作串列埠傳送十六進位制資料

#!/usr/bin/python
import serial

from time import sleep

ser = serial.Serial('/dev/ttyS0', 9600, timeout=0.5)

print ser.port
print ser.baudrate

if __name__ == '__main__':
    data=b'\xAA\xBB\x06\x00\x00\x00\x01\x01\x02\x02'
    while True:
        print data
        ser.write(data)
        sleep(1)