Reputation: 31
I use PC to control extral device, and this device is serial port communicate with PC, and it works good. I can send the commands to device from PC to device. The belwo is command structure.Python versio is 2.7.
Initialize=[0xEE,0x01,0x01]
ser.write(Initialize)
Now, I use the raspberry pi to connect this device, and I'm sure rapsberry pi has connected with thid device. I use the below command to test connection.
ser=serial.Serial("/dev/ttyACM0", baudrate=115200, timeout=0.5)
print ("Port "+ ser.portstr + "opened:" + str(ser.isOpen()))
Now, the issue is I cannot write the data to device as I did in PC. The python version is 3.4.2. Write command:
Initialize=[0xEE,0x01,0x01]
ser.write(Initialize)
Error message:
Traceback (most recent call last):
File "/home/pi/ssbar/ss.py", line 65, in <module>
ser.write(Initialize)
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 475, in write
n = os.write(self.fd, d)
TypeError: 'list' does not support the buffer interface
Is anyone knows how to fix it? Many thank for your help!
Upvotes: 1
Views: 1089
Reputation: 31
Thanks for your answer. It works now. The belwo is correct command.
x=bytearray(Initialize)
ser.write(x)
Upvotes: 1