123456789101112131415161718192021222324252627282930313233 |
- import serial
- import time,sys
- import array
- SERIAL_PORT = '/dev/ttyUSB0'
- ser = serial.Serial(SERIAL_PORT, baudrate = 115200 , timeout = 1)
- arr=[]
- j=0
- i=0
- commandarray = [0x7F]
- print(commandarray)
- ser.write(array.array('B', commandarray).tostring())
- rcv = ser.read(1)
- print (hex(ord(rcv)))
- if (rcv =='y'):
- commandarray = [0x31,0xCE]
- print(commandarray)
- ser.write(array.array('B', commandarray).tostring())
- rcv = ser.read(1)
- print (hex(ord(rcv)))
- if (rcv =='y'):
- commandarray = [0x08,0x00,0x00,0x00,0x08]
- print(commandarray)
- ser.write(array.array('B', commandarray).tostring())
- rcv = ser.read(1)
- print (hex(ord(rcv)))
- if (rcv =='y'):
- commandarray = [0x03,0x01,0x02,0x02,0x04,(0x02^0x04)]
- print(commandarray)
- ser.write(array.array('B', commandarray).tostring())
- rcv = ser.read(1)
- print (hex(ord(rcv)))
|