Skip to content

Simulator Development

XOJO Simulator

The XOJO Serial Data Simulator is a desktop application that was built using XOJO whose source code is located in BitBucket. You select a text file and say "go". It reads a line from the text file and pushes through the serial port. Right now, it's running on RichNUC3 and attaches to Windows COM ports. It's only one direction and sends messages out like many instruments do. When it gets to the end of the file it starts back at the top. Goal was originally to individually diagnose messages and parsing, but now it can be set up so that when connected to the rack of serial ports, it can simulate more than one.

Python Simulator

In 2023, there was an effort to develop a linux based simulator that would not need a GUI to start each time. The idea was this could be set up to just run at boot and send simulated data to serial ports every time it was booted.

Currently the code for the Python simulator is located in BitBucket here

Python Simulator Dev Environment

This setup is to provide a smaller environment where we can work on development of the simulators themselves. It consists of a Geekom Intel NUC named 'packard-dev-ubuntu-22.shore.mbari.org', and an 8 Port Moxa. The Moxa has ports that are looped by physically so you can connect to the serial port and monitor what is coming out. For example, in the diagram below, there is an NMEA simulator running that is pushing out NMEA strings to the local virtual serial port /dev/ttyr00. These are then routed over the network, to the Moxa device and are pushed out Port 1 on the Moxa. Port 1 is then null-modem wired to Port 2 on the Moxa which is then routed back over the network to the /dev/ttyr01 virtual serial port on the simulator machine. If you were to run screen /dev/ttyr01 in a terminal window on the development machine, you would see the NMEA strings streaming.

--- title: Development Simulator Connections --- flowchart LR subgraph dev-box[packard-dev-ubuntu-22] subgraph dev-simulators[CoreNav Simulators] dev-nmea[NMEA GPS Simulator] end subgraph dev-tty-port[Virtual Serial Ports] dev-ttyr00[ttyr00] dev-ttyr01[ttyr01] dev-ttyr02[ttyr02] dev-ttyr03[ttyr03] dev-ttyr04[ttyr04] dev-ttyr05[ttyr05] dev-ttyr06[ttyr06] dev-ttyr07[ttyr07] end end subgraph dev-moxa[Moxa NPort 5610-8-DT] dev-moxa-port-1[Port 1] dev-moxa-port-2[Port 2] dev-moxa-port-3[Port 3] dev-moxa-port-4[Port 4] dev-moxa-port-5[Port 5] dev-moxa-port-6[Port 6] dev-moxa-port-7[Port 7] dev-moxa-port-8[Port 8] dev-moxa-ip>134.89.11.94] end dev-nmea --> dev-ttyr00 dev-ttyr00 --> dev-moxa-port-1 dev-ttyr01 --> dev-moxa-port-2 dev-ttyr02 --> dev-moxa-port-3 dev-ttyr03 --> dev-moxa-port-4 dev-ttyr04 --> dev-moxa-port-5 dev-ttyr05 --> dev-moxa-port-6 dev-ttyr06 --> dev-moxa-port-7 dev-ttyr07 --> dev-moxa-port-8 dev-moxa-port-1 --> dev-moxa-port-2 dev-moxa-port-3 --> dev-moxa-port-4 dev-moxa-port-5 --> dev-moxa-port-6

In order to configure the Moxa connection, I used Firefox to download the Linux driver and then ran:

tar -xvf moxa-real-tty-linux-kernel-6.x-driver-v6.0.tgz
cd moxa/
sudo ./mxinst
cd /usr/lib/npreal2/driver
sudo ./mxaddsvr 134.89.11.94 8

This then created the serial ports /dev/ttyr00 -> /dev/ttyr07.

Then, I cloned the simulator code to ~/CoreNav using

git clone git@bitbucket.org:mbari/corenav-simulators.git

I edited the simulator_config.json file and pointed the NMEA simulator to /dev/ttyr01 and then ran the simulator. I could then see the output from the loopback by running

screen /dev/ttyr03