If you want to read binary data you need to do a bit more planning (or specify in more detail what you are sending). Serial.readline() reads data until a newline. Arab invasion of sindh pdf. Serial.read(n) reads n bytes (unless you have set a timeout). So you could use serial.read(4) if you were sending bytes in groups of 4. You need to synchronise the reading so you start at the group. Mar 28, 2010 - The professor here suggested to use Java to implement the applications. Surprisingly I found that Python with the pySerial module is a pretty intelligent solution! Ser.readline() # should be cgi.escape(ser.readline())! ![]() Anvil game engine. EDIT __________ The data is already bytes!! If all you want to do is display the bytes (in hex) read try the following (Note I am not a Python expert - this is much easier in c) #!/usr/bin/python import serial ser = serial.Serial('/dev/ttyACM0',115200) read_byte = ser.read() while read_byte is not None: read_byte = ser.read() print '%x'% ord(read_byte).
0 Comments
Leave a Reply. |