Hey, to interface Zigbee coordinator with python, I have used the mentioned below program. I was able to read the Byte array
please suggest the best way to make it work so that I'll be able to read data from Byte Array
import serial
ser = serial.Serial('COM6',115200)
read_byte = ser.read()
while read_byte is not None:
read_byte = ser.read()
print ('%x' % ord(read_byte))Result in hexadecimal format:7E 00 32 90 00 13 A2 00 41 91 25 D4 FF FE C2 7F 00 01 03 FF BC 00 08 00 01 52 55 00 BE 6B 01 89 DC 00 00 00 00 CB 4D 00 00 00 FE A4 04 00 00 00 FE 58 3E 00 1B 46but when I am trying to read the data from the byte array then I am facing some problem using mentioned below code.
import time
import serial
# Change this serial port to the serial port you are using.
s = serial.Serial('COM6', 115200)
while True:
packet_ready = s.read(1)
if(ord(packet_ready) == 126):
while s.inWaiting() < 28:
time.sleep(.001)
bytes_back = s.read(28)
if(ord(bytes_back[15]) == 127):
print('The packet has a data payload: ' + str(ord(bytes_back[15])))
print('The packet is for sensor type: '+str(ord(bytes_back[22])))Error:Error:Traceback (most recent call last):
File "C:/Users/Misha/Desktop/test/Xbee Test/Test2.py", line 13, in <module>
if(ord(bytes_back[15]) == 127):
TypeError: ord() expected string of length 1, but int foundand I am not able to understand the error problem please suggest the best way to make it work so that I'll be able to read data from Byte Array
