Skip to content

Commit

Permalink
Automatically start gps at /dev/pts/1 in px4 service to receive NMEA …
Browse files Browse the repository at this point in the history
…comms

Ideally we would not hard code the PTY path here but based on testing the /dev/pts/1 port should be the one that socat allocates for bridging incoming communication from TCP port 15000
  • Loading branch information
hmakelin committed Aug 7, 2024
1 parent 4e76b6e commit 146d6c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docker/px4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ RUN cat 6011_typhoon_h480 >> ROMFS/px4fmu_common/init.d-posix/airframes/6011_gaz

# TODO: configure GPS serial ports in environment variables
# Cube Orange: GPS 1 -> ttyS2, GPS 2 --> ttyS5
RUN echo "gps start -d /dev/ttyS2 -e /dev/ttyS5 -p ubx" >> ROMFS/px4fmu_common/init.d-posix/rcS \
&& echo "CONFIG_BOARD_SERIAL_GPS1=\"/dev/pts/0\"" >> boards/px4/sitl/default.px4board # TODO use dynamically allocated PTY device, not hard-coded pts/0
RUN echo "gps start -d /dev/pts/1 -b 9600 -p nmea" >> ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator \
&& echo "CONFIG_BOARD_SERIAL_GPS1=\"/dev/pts/1\"" >> boards/px4/sitl/default.px4board # TODO use dynamically allocated PTY device, not hard-coded pts/1
#&& echo "CONFIG_BOARD_SERIAL_GPS1=\"/dev/ttyS2\"" >> boards/px4/sitl/default.px4board \
#&& echo "CONFIG_BOARD_SERIAL_GPS2=\"/dev/ttyS5\"" >> boards/px4/sitl/default.px4board

Expand Down
6 changes: 0 additions & 6 deletions docker/px4/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ mavlink-routerd -e ${GISNAV_COMPANION_IP:?empty or not set}:${GISNAV_CMP_MAVROS_
# px4 container (simulation host). Bridging serial ports over TCP is easier with
# Docker than e.g. bridging via virtual serial ports (pseudo-ttys) on Docker
# host
#socat tcp-listen:15000 pty,link=/dev/ACM0 &
# TODO: do not hard code /dev/ttyS2, use .env file
echo "Setting up socat bridge at from TCP port ${SOCAT_BRIDGE_PORT:?empty or not set} to /tmp/gisnav-pty-link"
socat tcp-listen:${SOCAT_BRIDGE_PORT:?empty or not set},reuseaddr,fork pty,raw,echo=0,link=/tmp/gisnav-pty-link &
echo "PTY device created at (might not show up until client connects at ${SOCAT_BRIDGE_PORT}): $(readlink /tmp/gisnav-pty-link)"

# Start socat and capture the PTY name
#echo "Setting up socat bridge at from TCP port ${SOCAT_BRIDGE_PORT:?empty or not set} to PTY"
#socat tcp-listen:${SOCAT_BRIDGE_PORT},reuseaddr,fork pty,link=/tmp/gisnav-pty-link,raw,echo=0 || (echo "Could not establish TCP-to-serial bridge."; exit 1) &
#echo "PTS device created at (might not show up until client connects at ${SOCAT_BRIDGE_PORT}): $(readlink /tmp/gisnav-pty-link)"

# Setup uXRCE agent IP
# PX4 needs the IP as int32 - convert_ip.py script does the conversion
# https://docs.px4.io/main/en/middleware/uxrce_dds.html#starting-the-client
Expand Down

0 comments on commit 146d6c7

Please sign in to comment.