Being able to deploy over the air updates to your robot’s peripherals is a powerful thing. In the early stages it may also be useful for engineers to be able to connect directly to these devices as if they were connected to their personal computers. Here I’m going to detail one approach for this using ser2net. I’ll use connecting to a U-Blox Z-F9P GNSS receiver as a demonstration use case.
Whilst this is tutorial can work over a local WiFi network or LAN it’s true power is over a VPN solution, allowing for remote connection to devices anywhere in the world. Take a look at my previous post on setting up an OpenVPN server to get up and running with that.
Assuming classic U-Center, not U-Center 2.
Figure out which serial port you have assigned to the peripheral you intend to connect to. You’ll also need to know the baud rate, parity, stop bits etc. We’ll be using port /dev/ttyACM0 at a baud rate of 460800, with eight data bits and one stop bit.
You also need to choose a port for TCP communications, I’ve decided on 50100.
You’ll need to be sure to open the port on your network. For me this is on my VPN servers firewall and making changes to my AWS Security Group to allow TCP traffic on 50100.
Embedded Computer Setup
Establish a ssh connection to your robot’s embedded computer, hopefully this is the one with the peripheral connected to it also.
Install ser2net to allow access to serial ports on the embedded computer.
sudo apt-get install ser2net
Now you can edit ser2net’s configuration file.
sudo nano /etc/ser2net.conf
Add a line near the end that looks something like the following code chunk, alter the values as appropriate for your peripheral device and port.
50100:raw:600:/dev/ttyACM0:460800 8DATABITS NONE 1STOPBIT
Check it’s operational with the following command. Be sure to grep for your chosen port.
sudo netstat -ltnp | grep 50100
You ought to get a return similar to this.
tcp6 0 0 :::50100 :::* LISTEN 1660/ser2net
Use with U-Center
To establish a remote connection using U-Center once you have the software open and a connection to your network, follow the following steps on the toolbar menus.
Receiver > Connection > Network connection > New…
In the text box enter.
You will now have access to the receiver as though you had directly connected to it using serial on your workstation.
In order to stop the forwarding of serial data we can take a look to see what the process ID of ser2net is.
ps ax | grep ser2net
Here is the returun and we can see ser2net on 1007308.
1660 ? S 0:01 /usr/sbin/ser2net -c /etc/ser2net.conf -P /run/ser2net.pid 1007308 ? S 0:00 ser2net 1007341 pts/5 S+ 0:00 grep --color=auto ser2
Then to kill the process issue.
sudo kill 1007308
Resources and Further Reading
Found this useful or interesting?
Consider donating to support.
Any question, comments, corrections or suggestions?
Reach out on the social links below through the buttons.