Skip to content

Instantly share code, notes, and snippets.

@svinz
Last active August 15, 2022 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svinz/ea8c8d25421d74b9435e2bae93bf25fa to your computer and use it in GitHub Desktop.
Save svinz/ea8c8d25421d74b9435e2bae93bf25fa to your computer and use it in GitHub Desktop.
How to access a ublox GNSS-receivier with U-center when the receiver is connected to a Raspberry Pi and is only accessible through SSH

How to access a ublox GNSS-receivier with U-center when the receiver is connected to a Raspberry Pi and is only accessible through SSH

System topology

Systemsketch-Copy of Page-1

Config of the Raspberry Pi with the serial device connected (e.g. a ublox ZED-F9R)

  • Ensure that the computer is accessible with SSH and that socat is installed.
  • For a one time test, it is only necessary to run stty once like this: stty -F /dev/ttyACM0 38400 raw This is to ensure that baudrate is fixed, and that raw data traffic is used. Else it will probably fail in strange ways.
  • For a more permanent setup, it is probably smart to run this command whenever the device is connected. To do this, we use udev by adding a rule file named ublox.rules to /etc/udev/rules.d/ with the following content: SUBSYSTEM=="tty", ATTRS{idVendor}=="1546", ATTRS{idProduct}=="01a9", MODE="0666", RUN+="/bin/stty -F /dev/%k 230400 raw" To find out what the idVendor and idProduct is, run lsusb -v and find the correct device in the output. The MODE="0666" isn't strictly necessary, but if accessing the serial device from a docker container, it will need elevated permissions on the device. The udev rule will run whenever the device is reconnected or on reboot.

Sources:

How to set baud rate automatically when device connects?

Pass ATTR{idVendor} as argument in udev script

WSL/Linux PC

  • Ensure that it has socat installed.
  • Run: socat tcp-l:6000,fork,nodelay,keepalive,reuseaddr EXEC:"ssh user@raspberrypi socat - /dev/ttyACM0" This line will connect to the Raspberry Pi over SSH, start socat and clone port /dev/ttyACM0. It will then clone it onto TCP port 6000 for the WSL/Linux PC making it possible to use network connection in U-center by connecting to tcp://localhost:6000 or tcp://[IP-address]:6000

Sources:

How can I create a virtual serial port that relays data over ssh?

ACCESSING A USB IO MODULE IN A NETWORK BY USING LINUX AND SOCAT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment