Serial Wire Output Read Commands#
Simplicity Commander supports reading and dumping data received over Serial Wire Output (SWO) using the swo read command. When the command is executed, the target device is reset. The command will then read and dump SWO data until the application is terminated by pressing Ctrl+C, or one of the conditions described below is met.
By default, Commander reads data from SWO channel 0. Valid channels are 0–31. Only data from the selected channel is printed.
By default, the target will be reset during initialization of the SWO connection. Providing the --noreset option will prevent this.
Configure SWO Speed#
This command sets the SWO speed frequency in Hz. The default SWO speed is 875000 Hz. The SWO speed must match the frequency used by the target application.
Command Line Syntax
$ commander swo read [--swospeed <frequency in Hz>]
Command Line Input Example
$ commander swo read --swospeed 1000000
Command Line Output Example
<data written by the target application at 1 MHz> CTRL+C entered, terminating SWO connection... DONE
Read SWO from a Specific Channel#
Use the --channel option to select which SWO channel to print. Valid channels are 0–31. The default is channel 0.
Note: Depending on the application running on the target, SWO channel 8 might be used internally for debug messages or other structured data. As a result, you might see unexpected data on this channel.
Command Line Syntax
$ commander swo read [--channel <channel>]
Command Line Input Example
$ commander swo read --channel 3
This command line reads and dumps SWO data from channel 3.
Command Line Output Example
<data written by the target application on channel 3> CTRL+C entered, terminating SWO connection... DONE
Read SWO Until Timeout#
This command sets the number of seconds for the adapter to wait without receiving data before it times out. The default is to never time out.
By default, the timeout applies only to the selected SWO channel. If the --monitorall option is used, the command times out only if no data is received on any channel.
Command Line Syntax
$ commander swo read [--timeout <timeout in s>]
Command Line Input Example
$ commander swo read --timeout 1
Command Line Output Example
<data written by the target application> Timeout: No SWO output for 1 seconds. DONE
Read SWO Until a Marker Is Found#
If the --endmarker option is used, the command will terminate after finding the specified string in the SWO stream.
By default, Commander looks for the end marker only on the selected SWO channel. If the --monitorall option is used, Commander looks for the end marker on all channels and reports the channel where it was found.
Command Line Syntax
$ commander swo read [--endmarker <end marker>]
Command Line Input Example
$ commander swo read --endmarker "--finished--"
Command Line Output Example
<data written by the target application> --finished-- SWO connection terminated. End marker '--finished--' found. DONE
Monitor All SWO Channels#
When you use the --monitorall option with --timeout or --endmarker, Commander monitors all SWO channels for the specified end condition. Commander still prints data only from the selected channel.
With --timeout, the command times out only if no data is received on any channel. With --endmarker, the command terminates when the marker is detected on any channel.
The --monitorall option has no effect unless you also specify --timeout or --endmarker.
Command Line Syntax
$ commander swo read [--timeout <timeout in s> --endmarker <end marker> --channel <channel> --monitorall]
Command Line Input Example
$ commander swo read --channel 0 --timeout 7 --endmarker "--finished--" --monitorall
This command prints data from channel 0 and terminates when either the string --finished-- is received on any SWO channel or no data is received on any channel for 7 seconds.
Command Line Output Example
<data written by the target application on channel 0> SWO connection terminated. End marker '--finished--' found on channel 3. DONE
Dump Hex Encoded SWO Output#
When you use the --hex option, Commander converts all input and output to hexadecimal strings. This is useful when the target outputs binary data. If you also use --endmarker, provide the end marker as a hexadecimal value.
In text mode, Commander discards all incoming NUL bytes. In hex mode, Commander includes these bytes in the output.
Command Line Syntax
$ commander swo read [--hex] [--endmarker <hex encoded end marker>]
Command Line Input Example
$ commander swo read --hex --endmarker 50415353
Command Line Output Example
0a5374617274696e6720746573742067726f757020434d550a434d553a333836323a546573745f434d555f4275675f363639393a50415353 SWO connection terminated. End marker '50415353' found. DONE