!REDIRECT “https://docs.px4.io/master/ja/middleware/modules_communication.html

Modules Reference: Communication

frsky_telemetry

Source: drivers/telemetry/frsky_telemetry

FrSky Telemetry support. Auto-detects D or S.PORT protocol.

Usage

  1. frsky_telemetry <command> [arguments...]
  2. Commands:
  3. start
  4. [-d <val>] Select Serial Device
  5. values: <file:dev>, default: /dev/ttyS6
  6. [-t <val>] Scanning timeout [s] (default: no timeout)
  7. default: 0
  8. [-m <val>] Select protocol (default: auto-detect)
  9. values: sport|sport_single|sport_single_invert|dtype, default:
  10. auto
  11. stop
  12. status

mavlink

Source: modules/mavlink

Description

This module implements the MAVLink protocol, which can be used on a Serial link or UDP network connection. It communicates with the system via uORB: some messages are directly handled in the module (eg. mission protocol), others are published via uORB (eg. vehicle_command).

Streams are used to send periodic messages with a specific rate, such as the vehicle attitude. When starting the mavlink instance, a mode can be specified, which defines the set of enabled streams with their rates. For a running instance, streams can be configured via mavlink stream command.

There can be multiple independent instances of the module, each connected to one serial device or network port.

Implementation

The implementation uses 2 threads, a sending and a receiving thread. The sender runs at a fixed rate and dynamically reduces the rates of the streams if the combined bandwidth is higher than the configured rate (-r) or the physical link becomes saturated. This can be checked with mavlink status, see if rate mult is less than 1.

Careful: some of the data is accessed and modified from both threads, so when changing code or extend the functionality, this needs to be take into account, in order to avoid race conditions and corrupt data.

Examples

Start mavlink on ttyS1 serial with baudrate 921600 and maximum sending rate of 80kB/s:

  1. mavlink start -d /dev/ttyS1 -b 921600 -m onboard -r 80000

Start mavlink on UDP port 14556 and enable the HIGHRES_IMU message with 50Hz:

  1. mavlink start -u 14556 -r 1000000
  2. mavlink stream -u 14556 -s HIGHRES_IMU -r 50

Usage

  1. mavlink <command> [arguments...]
  2. Commands:
  3. start Start a new instance
  4. [-d <val>] Select Serial Device
  5. values: <file:dev>, default: /dev/ttyS1
  6. [-b <val>] Baudrate (can also be p:<param_name>)
  7. default: 57600
  8. [-r <val>] Maximum sending data rate in B/s (if 0, use baudrate / 20)
  9. default: 0
  10. [-u <val>] Select UDP Network Port (local)
  11. default: 14556
  12. [-o <val>] Select UDP Network Port (remote)
  13. default: 14550
  14. [-t <val>] Partner IP (broadcasting can be enabled via MAV_BROADCAST
  15. param)
  16. default: 127.0.0.1
  17. [-m <val>] Mode: sets default streams and rates
  18. values:
  19. custom|camera|onboard|osd|magic|config|iridium|minimal|extvsisi
  20. on, default: normal
  21. [-n <val>] wifi/ethernet interface name
  22. values: <interface_name>
  23. [-c <val>] Multicast address (multicasting can be enabled via
  24. MAV_BROADCAST param)
  25. values: Multicast address in the range
  26. [239.0.0.0,239.255.255.255]
  27. [-f] Enable message forwarding to other Mavlink instances
  28. [-w] Wait to send, until first message received
  29. [-x] Enable FTP
  30. [-z] Force hardware flow control always on
  31. [-Z] Force hardware flow control always off
  32. stop-all Stop all instances
  33. status Print status for all instances
  34. [streams] Print all enabled streams
  35. stream Configure the sending rate of a stream for a running instance
  36. [-u <val>] Select Mavlink instance via local Network Port
  37. [-d <val>] Select Mavlink instance via Serial Device
  38. values: <file:dev>
  39. -s <val> Mavlink stream to configure
  40. -r <val> Rate in Hz (0 = turn off, -1 = set to default)
  41. boot_complete Enable sending of messages. (Must be) called as last step in
  42. startup script.

micrortps_client

Source: modules/micrortps_bridge/micrortps_client

Usage

  1. micrortps_client <command> [arguments...]
  2. Commands:
  3. start
  4. [-t <val>] Transport protocol
  5. values: UART|UDP, default: UART
  6. [-d <val>] Select Serial Device
  7. values: <file:dev>, default: /dev/ttyACM0
  8. [-b <val>] Baudrate (can also be p:<param_name>)
  9. default: 460800
  10. [-p <val>] Poll timeout for UART in ms
  11. [-l <val>] Limit number of iterations until the program exits
  12. (-1=infinite)
  13. default: 10000
  14. [-w <val>] Time in ms for which each iteration sleeps
  15. default: 1
  16. [-r <val>] Select UDP Network Port for receiving (local)
  17. default: 2019
  18. [-s <val>] Select UDP Network Port for sending (remote)
  19. default: 2020
  20. [-i <val>] Select IP address (remote)
  21. values: <x.x.x.x>, default: 127.0.0.1
  22. [-f] Activate UART link SW flow control
  23. [-h] Activate UART link HW flow control
  24. [-v] Add more verbosity
  25. stop
  26. status

uorb

Source: modules/uORB

Description

uORB is the internal pub-sub messaging system, used for communication between modules.

It is typically started as one of the very first modules and most other modules depend on it.

Implementation

No thread or work queue is needed, the module start only makes sure to initialize the shared global state. Communication is done via shared memory. The implementation is asynchronous and lock-free, ie. a publisher does not wait for a subscriber and vice versa. This is achieved by having a separate buffer between a publisher and a subscriber.

The code is optimized to minimize the memory footprint and the latency to exchange messages.

The interface is based on file descriptors: internally it uses read, write and ioctl. Except for the publications, which use orb_advert_t handles, so that they can be used from interrupts as well (on NuttX).

Messages are defined in the /msg directory. They are converted into C/C++ code at build-time.

If compiled with ORB_USE_PUBLISHER_RULES, a file with uORB publication rules can be used to configure which modules are allowed to publish which topics. This is used for system-wide replay.

Examples

Monitor topic publication rates. Besides top, this is an important command for general system inspection:

  1. uorb top

Usage

  1. uorb <command> [arguments...]
  2. Commands:
  3. start
  4. status Print topic statistics
  5. top Monitor topic publication rates
  6. [-a] print all instead of only currently publishing topics with
  7. subscribers
  8. [-1] run only once, then exit
  9. [<filter1> [<filter2>]] topic(s) to match (implies -a)