basecamelectronics / sbgc32-serial-api

A complete C-library and example projects for the SimpleBGC32 Serial API integration. Serial API allows to communicate with all gimbal controllers developed by Basecamelectronics company.
Apache License 2.0
23 stars 12 forks source link

RX_TIMEOUT error when running the Linux demo #6

Open ricfrr opened 2 weeks ago

ricfrr commented 2 weeks ago

Hi it has been a while that I am trying to connect the gimbal to a linux x86 machine running ubuntu 22.04 without success.

When I try to execute the demo code I get the following error and nothing happen:

Board Info: Receive Error: RX_TIMEOUT_ERROR
Board Info: Receive Error: RX_TIMEOUT_ERROR

******************************
Communication Error!
******************************

Board Info: Receive Error: RX_TIMEOUT_ERROR
Board Info 3: Receive Error: RX_TIMEOUT_ERROR
Main Parameters 3: Receive Error: RX_TIMEOUT_ERROR
Main Parameters Ext: Receive Error: RX_TIMEOUT_ERROR
Main Parameters Ext 2: Receive Error: RX_TIMEOUT_ERROR
Main Parameters Ext 3: Receive Error: RX_TIMEOUT_ERROR
Real-Time Data 4: Receive Error: RX_TIMEOUT_ERROR
Board Version: 0.0 
Firmware Version: 0.0 
Flash Size = 0
Current profile # 0
Roll P = 0
Roll I = 0
Roll D = 0
Pitch P = 0
Pitch I = 0
Pitch D = 0
Yaw P = 0
Yaw I = 0
Yaw D = 0
Acc Limiter All =  0
RC Max Angle = 0
RC Min Angle = 0
RC Map Roll = 0
RC Map Pitch = 0
RC Map Yaw = 0
RC Map Cmd = 0
RC Map FC Roll = 0
RC Map FC Pitch = 0
LPF Frequency Roll = 0
LPF Frequency Pitch = 0
LPF Frequency Yaw = 0
Frame IMU LPF Freq = 0
Timelapse Time = 0
Motor Startup Delay = 0

ACC Roll = 0
ACC Pitch = 0
ACC Yaw = 0
Roll Current Angle = 0
Pitch Current Angle = 0
Yaw Current Angle = 0
IMU Temperature = 0
CONFIRM_TIMEOUT_ERROR!
Adj Var Values vol. 1: Receive Error: RX_TIMEOUT_ERROR
ADJ_VAL_ACC_LIMITER_ROLL 0
ADJ_VAL_ACC_LIMITER_PITCH 0
ADJ_VAL_ACC_LIMITER_YAW 0 

I have setted given the permission to the user to gain the access to the port so it shouldn't be problem of permission.

Also when I try to connect to the gimbal trought GUI it is stuck in a loop :

GUI : 09:46:26,865 INFO Opened /dev/ttyUSB0 / EDT
09:46:26,968 DEBUG Protocol version set to AUTO(in), V1(out) / EDT
09:46:26,969 INFO Starting board connection.. / ConnectThread
09:46:26,969 DEBUG BoardInfo is set to null / ConnectThread
09:46:26,969 DEBUG Setting parity: 0 / ConnectThread
09:46:26,969 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:26,980 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:27,288 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:27,296 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:27,605 DEBUG Setting parity: 2 / ConnectThread
09:46:27,605 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:27,612 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:27,920 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:27,928 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:28,240 DEBUG Setting baudrate: 57600 / ConnectThread
09:46:28,241 DEBUG Setting parity: 0 / ConnectThread
09:46:28,242 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:28,248 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:28,556 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:28,564 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:28,876 DEBUG Setting parity: 2 / ConnectThread
09:46:28,877 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:28,884 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:29,192 DEBUG OUT:[1,0] [] 0 / ConnectThread
......
09:46:31,405 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:31,412 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:31,720 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:31,728 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:32,036 DEBUG Setting baudrate: 9600 / ConnectThread
09:46:32,037 DEBUG Setting parity: 0 / ConnectThread
09:46:32,038 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:32,044 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:32,352 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:32,360 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:32,676 DEBUG Setting parity: 2 / ConnectThread
09:46:32,677 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:32,684 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:32,992 DEBUG OUT:[1,0] [] 0 / ConnectThread
09:46:33,000 DEBUG OUT:[86,2] [00 00 ] 0 / ConnectThread
09:46:33,316 DEBUG Setting baudrate: 256000 / ConnectThread
09:46:33,317 ERROR Error configuring serial port: gnu.io.UnsupportedCommOperationException: Invalid Parameter / ConnectThread

where if I check

dmesg --follow

I get

[99483.839532] tty_set_serial: 'ConnectThread' is using deprecated serial flags (with no effect): 00008200

The gimbal should be fine as it runs properly and under Windows I can connect trought the app and see and set all the different parameters.

Any help is very welcome :)

qsivey commented 2 weeks ago

Hello! I haven't encountered a similar issue before. If you are confident that you have correctly assigned permissions and configured the library properly, you can try accessing the controller using raw SerialAPI commands through the terminal. For examle try to ping a SBGC32 with the next command: 0x24, 0x45, 0x01, 0x46, 0x00, 0x35, 0x6E, 0x07

However, I still suspect that the issue lies within the port connection itself. It might be something within Linux software.

ricfrr commented 1 week ago

Hi, thank you very much for your time.

If I run the command from the bash

ls -l /dev/ttyUSB0 | grep "/dev/ttyUSB0"

I get the following

crwxrwxrwx 1 root dialout 188, 0 jul 17 09:20 /dev/ttyUSB0

while if I check the dialout group

getent group dialout

I get (riccardo.franceschin@local.eurecat.org is my username)

dialout:x:20:riccardo.franceschin@local.eurecat.org

I then tried to create a tiny python script for sending the command you suggested

import serial
import time

# Configure the serial port
ser = serial.Serial(
    port='/dev/ttyUSB0',  
    baudrate=115200        
)

# Ensure the port is open
if ser.is_open:
    print("Serial port is open")

# Send the bytes
command = b'\x24\x45\x01\x46\x00\x35\x6E\x07'
ser.write(command)
print(f"Sent: {command}")

# Give the device some time to respond
time.sleep(1)

# Read the response
response = ser.read(ser.in_waiting)  # Read all available data
print(f"Response: {response}")

# Close the serial port
ser.close()

and the output from the program is and in the meanwhile nothing happen:

Serial port is open
Sent: b'$E\x01F\x005n\x07'
Response: b''

I have also tried the same code on a jetson orin nano running ubuntu 22.04, and the problem is exactly the same.

Any idea? do you think it is a linux generic problem or a might be a gimblal problem? (the weird thing is that the board works and correctly stabilize, and on windows I can connect with the SBG UI)

qsivey commented 1 week ago

Hello! Let's try to solve your problem as a regular support ticket. Can I communicate with you via this email? riccardo.franceschini@live.it

ricfrr commented 1 week ago

Hi yes, but probably is better using riccardo.franceschini@eurecat.org