Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pyserial to send binary data

I know there has been a lot of discussion on this but I still have a question. I am trying to send hex values through pyserial to my device using pyserial

command="\x89\x45\x56"
ser.write(command)

However I keep getting an error saying string argument without encoding. Does anyone know how to solve this?

like image 818
BladeRunner Avatar asked Jul 11 '13 09:07

BladeRunner


1 Answers

packet = bytearray()
packet.append(0x41)
packet.append(0x42)
packet.append(0x43)

ser.write(packet)
like image 62
rjha94 Avatar answered Sep 20 '22 03:09

rjha94