NMEA-0183 depth simulator for serial-connected systems.
- Generates
SDDPTorSDDBTframes once per second by default. - Uses a deterministic depth pattern based on current second (
10 + second). - Sends data over a serial port (
/dev/ttyUSB0and9600by default). - Can run manually or as a
systemdservice (nmea.service).
Script/sonar_simulator.py: simulator entrypoint.Script/autolaunch.sh: launcher used by systemd.Script/sonar_simulator_unittest.py: unit tests.Script/unittest.sh: test runner.Install/install.sh: service installation script.BOM.txt: hardware bill of materials.
- Ubuntu (tested workflow targets Raspberry Pi with Ubuntu Server).
- Python 3.
pyserial(python3-serialpackage).
From repository root:
python3 Script/sonar_simulator.py /dev/ttyUSB0 9600Optional arguments:
python3 Script/sonar_simulator.py /dev/ttyUSB0 9600 --sentence-type dbt --interval 0.5 --iterations 10From repository root:
bash Install/install.shThis installs and starts nmea.service with default environment values:
SONAR_SERIAL_PORT=/dev/ttyUSB0SONAR_BAUD_RATE=9600SONAR_SENTENCE_TYPE=dpt
Service commands:
sudo systemctl status nmea
sudo systemctl restart nmea
sudo systemctl stop nmeaOption 1 (recommended): override service environment values in the unit file.
sudo systemctl edit --full nmea
# Update SONAR_SERIAL_PORT, SONAR_BAUD_RATE, and SONAR_SENTENCE_TYPE (dpt or dbt)
sudo systemctl daemon-reload
sudo systemctl restart nmeaOption 2: export environment values before running manually.
SONAR_SERIAL_PORT=/dev/ttyUSB1 SONAR_BAUD_RATE=115200 SONAR_SENTENCE_TYPE=dbt bash Script/autolaunch.shFrom repository root:
bash Script/unittest.sh- The simulator writes one frame per cycle terminated by
\r\n. - If serial opening fails, the script logs the error and exits cleanly.