Has anyone connected a raspberry pi to the BiBoard using the Tx,Rx, Ground, and 5v GPIO pins? I was able to run ardserial.py using the usb-c port connected to the Rpi, but didn't have any luck with GPIO.
For the second serial port, should it be sending a response after receiving a command? I've made a simple test in the main script of SerialCommunication.py in the serialMaster directory of opencat:
if __name__ == '__main__':
Communication.Print_Used_Com()
port = port_list_number
if not port:
print("No serial ports found.")
else:
myCom = Communication(port[0], 115200, 1)
print("Ret = ", Ret)
myCom.Open_Engine()
try:
while True:
key = input("Enter a command (or 'exit' to quit): ")
if key == 'exit':
print("Exiting...")
break
# Send the user input to the serial device
myCom.Send_data((key + '\n').encode('utf-8'))
print(f"Sent: {key}")
# Wait for a response from the serial device
response = ""
while True:
try:
line = myCom.Read_Line().decode('ISO-8859-1').strip()
if line:
response += line
# Check for known response endings
if response.endswith("k"):
break
else:
break
except UnicodeDecodeError as e:
print(f"Decode error: {e}")
break
# Extract the actual response before the "k"
actual_response = response[:-1].strip() if response.endswith("k") else response
if actual_response:
print(f"Received: {actual_response}")
else:
print("No response received")
except KeyboardInterrupt:
print("\nProgram interrupted by user.")
finally:
myCom.Close_Engine()
But this only sends a response back when I connect my raspberry pi to the BiBoard through USB instead of the tx2 and rx2 pins.
I'm trying to get confirmation that a command is executed on the BiBoard, so I don't need to blindly blast the board with a bunch of commands in my autonomous control loop.
Serial port 2 is activated, and I am able to send commands to the robot through the Tx2 and Rx2 pins, but I don't get a confirmation response back. If I connect the BiBoard to the raspberry pi with usb, then it is connected to port ttyACM0, and I get feedback after sending and executing commands:Connected to myCom: /dev/ttyACM0
Ret = True
Enter a command (or 'exit' to quit): krest
Sent: krest
Received: rest
Enter a command (or 'exit' to quit): kbalance
Sent: kbalance
Received: balance
Enter a command (or 'exit' to quit): krest
Sent: krest
Received: rest
If I then disconnect the usb cable and connect with the tx2 and rx2 pins, I am connected to port ttyAMA0, but receive empty responses back. I am able to send commands, and the robot executes them:Connected to myCom: /dev/ttyAMA0
For the second serial port, should it be sending a response after receiving a command? I've made a simple test in the main script of SerialCommunication.py in the serialMaster directory of opencat:
if __name__ == '__main__':
Communication.Print_Used_Com()
port = port_list_number
if not port:
print("No serial ports found.")
else:
myCom = Communication(port[0], 115200, 1)
print("Ret = ", Ret)
myCom.Open_Engine()
try:
while True:
key = input("Enter a command (or 'exit' to quit): ")
if key == 'exit':
print("Exiting...")
break
# Send the user input to the serial device
myCom.Send_data((key + '\n').encode('utf-8'))
print(f"Sent: {key}")
# Wait for a response from the serial device
response = ""
while True:
try:
line = myCom.Read_Line().decode('ISO-8859-1').strip()
if line:
response += line
# Check for known response endings
if response.endswith("k"):
break
else:
break
except UnicodeDecodeError as e:
print(f"Decode error: {e}")
break
# Extract the actual response before the "k"
actual_response = response[:-1].strip() if response.endswith("k") else response
if actual_response:
print(f"Received: {actual_response}")
else:
print("No response received")
except KeyboardInterrupt:
print("\nProgram interrupted by user.")
finally:
myCom.Close_Engine()
But this only sends a response back when I connect my raspberry pi to the BiBoard through USB instead of the tx2 and rx2 pins.
I'm trying to get confirmation that a command is executed on the BiBoard, so I don't need to blindly blast the board with a bunch of commands in my autonomous control loop.