I am trying to to send a number from serial ports on my Pi 3 to a motor driver, (RoboLCaw) by using Python.
I have read lots of articles on the internet about how to to do very simple number sending through serial ports but till now it has not worked.
The main error message that I am receiving is:
Traceback (most recent call last): File "test.py", line 15, in <module> ser.write("This is a test") File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 475, in write n = os.write(self.fd, d) TypeError: 'str' does not support the buffer interface
There are different solutions for that error, some of them say byte-arrays, some say strings and so on. I would appreciate any hint or guidance that let me know what kind of input I can enter by using the write function
Below is an example of a program that I have used to check the serial port write and read:
import serial ser = serial.Serial( port='/dev/ttyAMA0', baudrate = 9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1 ) print ("Serial is open: " + str(ser.isOpen())) print ("Now Writing") ser.write("This is a test") print ("Did write, now read") x = ser.readline() print ("got '" + x + "'") ser.close()