Using the smartport telemetry with MWP - stronnag/mwptools GitHub Wiki

Using the smartport telemetry

Unmaintained Article Please check the manual for more up-to-date information.

As of 2019-02-18, mwp implements smartport telemetry parsing.

Configuring the Smartport telemetry device

At the moment (and this may change later once there is more experience of how this function might be used), it is necessary to define the smartport device on the command line, or add it to ~/.config/mwp/cmdopts:

$ # Use a BT device by address
$ mwp --smartport 00:14:03:11:35:16  --force-type 8

The device after --smartport can be any mwp supported device name; in this example I'm using a Bluetooth serial adaptor, and because I don't first connect using MSP (and hence receive platform details), I need to define the model type (8 == flying wing).

For a bluetooth device (maybe connected to the Taranis battery compartment serial port), you can use either the device address or rfcom device node:

$ mwp --smartport 00:14:03:11:35:16
# or
$ mwp --smartport /dev/rfcomm42

Note that if you first connect using MSP (e.g. to upload a mission, mwp will get the vehice type from the FC.

If you always use the same device for smartport, you can add the command option to ~/.config/mwp/cmdopts; in this case you can launch an installed mwp from a desktop icon.

 cat ~/.config/mwp/cmdopts
# Default options for mwp
--rings 50,20
#--voice-command "spd-say -t female2 -e"
--wayland
#--debug-flags=2
--dont-maximise
#-S 8192
#--voice-command "ftest file:///home/jrh/Projects/flite/cmu_us_clb.flitevox"
--smartport 00:14:03:11:35:16

When you invoke mwp with --smartport, you will see a new device *SMARTPORT* in the serial device drop down. In order to use it, you must first close (disconnect) any MSP device, and open (Connect) to the *SMARTPORT* device.mwp is now taking telemetry from your Taranis serial port.

Wired connection

Using a wired (USB serial) connection (and possibly /dev/rfcomm BT) it may be necessary to specify the baud rate:

mwp --smartport /dev/ttyUSB0@57600 --force-type 8

Simulator / replay tools

In the samples/frsky directory, there is a replay tool that will replay captured smartport logs. By default this tool listens on a localhost TCP socket, port 43210; this is accessed in mwp by setting the smartport serial device as --smartport tcp://localhost:43210. Before you connect in mwp, you must have started the replay tool:

$ cd mwptools/samples/frsky
# use the replay tool, we can connect / disconnect from mwp as we wish ...
$ ./sport_tcp_replay.rb s-port-short.log
++ New session ::1:39458
-- Close session
++ New session ::1:39576
-- Close session

And invoke mwp as:

$ mwp/mwp --smartport tcp://localhost:43210  --force-type 8

In the example, s-port-short.log was the smartport log file (thanks @wilco1967). The file plays in approximately real time; there are options to change the rate and port:

$ ./sport_tcp_replay.rb  --help
Usage: sport_tcp_replay.rb [options] file
    -p, --port PORT                  43210
    -d, --delay SECS                 0.00167
    -?, --help                       Show this message

There is a similar tool to replay smartport logs over a serial device (BT, USB serial etc):

$ ./sport_dev_replay.rb --help
Usage: sport_dev_replay.rb [options] file
    -d, --delay SECS                 0.00167
    -s, --serial DEVICE              /dev/ttyUSB0
    -b, --baud RATE                  115200
    -?, --help                       Show this message

Note that these two tools recognise a pure serial stream capture, and a mwp 'raw' log, the latter including timing information.

ToDo

This function is possibly not yet complete:

  • Potentially better (auto) switching to s-port telemetry
  • Validate RSSI scaling
  • Some "docklets" may not be populated
  • Fix any bugs from live (vice replay) usage

Caveats

If you use mwp for long flights (> 30 minutes), on memory constrained systems (VMs in particular), you may find mwp gets killed by the Linux kernel OOM (Out of memory) function.

Telemetry (smaprt port and LTM) can generate a lot of points, which the geo library used by mwp will store in memory. You can limit the number of points stored (but the line trail is still plotted) with mwp's -S npoints option

mwp -S 4096 # only keep last 4096 points. You can make this permanent by putting the -S setting into ~/.config/mwp/cmdopts, thusly:

$ cat ~/.config/mwp/cmdopts
# Default options for mwp, leading # is a comment
--rings 50,20
# only keep 4096 points (tune for your free memory)
-S 4096
--smartport 00:14:03:11:35:16

While this improves performance, it only delays the memory pressure. Just limiting the number of points is not enough if you have < 2GB of memory in your system / VM. Reducing the frequency of plotting also helps, so a combination of -S and -M is needed:

mwp -S 1024 -M 8 # keep 1024 points, plot every 8th GPS report.

As we're plotting fewer points, we can keep fewer as well, note you still get the whole track, it's just that the earlier coloured points fade out eventually.

Unfortunately the libchamplain geo library is a memory hog. Using -M also reduces the line point plotting frequency; it makes the update graphically a bit ugly, but saves memory and makes long flights (even > 1 hour) manageable on low RAM systems.

Reporting Bugs

The author does not have any FrSky / Taranis hardware. In order to investigate any issues, logs will be required:

  • Blackbox Log
  • mwp smartport raw log (mwp -r)
  • mwp json log file

Note: raw logs can be generated by invoking mwp with the -r option, and are written to the current directory with the name including a timestamp and suffix .raw, e.g. mwp_2019-02-18_203508.raw.

Links

Information on using the Taranis serial port: https://github.com/opentx/opentx/wiki/Taranis-IO-ports. Note this is inverted.

Step by step guide to building a BT adaptor for a Taranis TX. It's somewhat Windows orientated; Linux users will find it even easier, just use mwp's clitool -n [-b baud] [-d device] as the terminal to configure your BT device.

mwp issue : https://github.com/stronnag/mwptools/issues/19