Pi 4 Problem with UART

The Raspberry Pi is a series of credit card-sized single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and developing countries.

Post Reply
User avatar
/RaspberryPi
Corporate
Posts: 2449
Joined: Wed Jun 05, 2019 1:29 am

Pi 4 Problem with UART

Post by /RaspberryPi »


Hello everyone, I'm currently trying to make a tiny little spider bot using a raspberry pi 4 running raspberry pi OS and a Torobot USC-32 servo controller (SSC-32 clone). I've hooked up pin 8 from GPIO to RX on the servo board and I've hooked up pin 10 from GPIO to the TX on the servo board. I've gone in raspi-config and enabled serial communication and disabled login shell over serial. I've run some python scripts attempting to send commands to the servo controller but sadly nothing results in movement. I've spent a lot of time designing the little bot and I'm heartbroken I still couldn't get my raspberry pi to work with it.



Here is my initial servo control script:

--------------------------------------------------------------------------

import serial

import sys

import time



ssc32 = serial.Serial('/dev/serial1', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1.0)

print("start")

ssc32.write(b"#4P1500\r\n") # Note the b before the string for bytes

time.sleep(2)

ssc32.write(b"#4P1600T2000\r\n")

print("end")

ssc32.close()

--------------------------------------------------------------------------

and running it via sudo python3 in terminal i get this:

----------------------------------------------------------------------------

Traceback (most recent call last):

File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 380, in _reconfigure_port

orig_attr = termios.tcgetattr(self.fd)

termios.error: (5, 'Input/output error')



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

File "/home/yoshi/Desktop/PythonScripts/othertest.py", line 5, in

ssc32 = serial.Serial('/dev/serial1', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1.0)

File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 244, in _init_

self.open()

File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 329, in open

self._reconfigure_port(force_update=True)

File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 383, in _reconfigure_port

raise SerialException("Could not configure port: {}".format(msg))

serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')

----------------------------------------------------------------------------------------------------------------------------------------

So i tried running this simple script:

------------------------------------------------------------------------------------------

import serial

try:

ssc32 = serial.Serial('/dev/serial1', baudrate=9600, timeout=1.0)

ssc32.close()

print("Serial port test successful.")

except Exception as e:

print(f"Serial port test failed: {e}")

------------------------------------------------------------------------------------------

and as a result I got this error:

------------------------------------------------------------------------------------------

Serial port test failed: Could not configure port: (5, 'Input/output error')

-----------------------------------------------------------------------------------------------

I've tried two different sd cards with separate raspberry pi OS installs and neither of them work. My Arduino Uno works great with this servo controller over UART but I'm at my wit's end here. Any and all help/suggestions you guys might have is deeply appreciated! :)
submitted by /u/Yoshizwinner
[link] [comments]

Source: https://www.reddit.com/r/raspberry_pi/c ... with_uart/
/RaspberryPi
Post Reply

Return to “Raspberry Pi Forum”