LORD-MicroStrain / MSCL

MicroStrain Communication Library
https://www.microstrain.com/software/mscl
MIT License
76 stars 57 forks source link

Urgent: WSDA-200 USB Stick Communcation Error, Failed to read Firmware #397

Closed matzefit closed 1 month ago

matzefit commented 1 month ago

I encountered an error in the midst of final preparations for the deployment of a remotely operated raspberry pi outfitted with a WSDA-200 USB Stick to wirelessly connect to a G Link 200 8G. Somehow the USB Stick isn't recognized anymore.

The exact issue is that there is a communication error when running the below code:

# Test connection and read firmware version with retries def test_basestation_connection(com_port, retries=10, delay=5): for attempt in range(retries): try: # Establish connection to the BaseStation connection = mscl.Connection.Serial(com_port, 3000000) baseStation = mscl.BaseStation(connection) print(f"Successfully connected to BaseStation on {com_port}") ` # Check firmware version to ensure communication firmware_version = str(baseStation.firmwareVersion()) print(f"BaseStation Firmware Version: {firmware_version}") return baseStation except mscl.Error_Communication as e: print(f"Communication error on attempt {attempt + 1}/{retries}: {e}") except Exception as e: print(f"Error connecting to BaseStation on {com_port} on attempt {attempt + 1}/{retries}: {e}") time.sleep(delay) return None com_port = "/dev/ttyUSB0" baseStation = test_basestation_connection(com_port) if baseStation is None: print("Failed to connect to BaseStation after multiple attempts. Exiting...") sys.exit(1) # Exit the script if connection fails`

The output of above script is the following: Successfully connected to BaseStation on /dev/ttyUSB0 Communication error on attempt 1/10: Failed to read the Firmware Version (EEPROM 108) from the BaseStation Successfully connected to BaseStation on /dev/ttyUSB0 Communication error on attempt 2/10: Failed to read the Firmware Version (EEPROM 108) from the BaseStation Successfully connected to BaseStation on /dev/ttyUSB0 Communication error on attempt 3/10: Failed to read the Firmware Version (EEPROM 108) from the BaseStation Successfully connected to BaseStation on /dev/ttyUSB0 ... and so on until 10 retries are done, then: Failed to connect to BaseStation after multiple attempts. Exiting....

Basically when trying to get the firmware, the exception comes into effect and outputs the error that the communication cannot be established and the firmware cannot be read from the device.

This code worked perfectly fine in the past. Could you point me to a solution on this issue? I tried rebooting the system and I tested the connection with different WSDA-200USB sticks, all of which eventually end up with this error. 

matzefit commented 1 month ago

fixed it myself. turns out raspberry pi's reassign the USB port to which the WSDA 200 is connected to everytime after booting. It cold be that the port is ttyUSB0 and then after rebooting the port is randomly reassigned to ttyUSB5, this depends on the order the connected devices are started. To check out in which ComPort the WSDA 200 USB Stick is currently registered one can run 'dmesg | grep ttyUSB' in the terminal, then look out where cp210x (the Driver for the USB Stick) is currently attached. based on that the COMPORT in the script needs to be changed