Overview
The Karbon 'Command Line Interface' (CLI) is a simple, cross-platform, command line utility for interfacing with the onboard microcontroller. This document assumes some basic familiarity with using the command line on Windows, or the terminal on a linux system. The Karbon CLI supports four core commands for managing and interacting with the microcontroller.
Command | Functionality |
---|---|
Change and report all user configuration parameters, including automotive settings, power management, etc. |
|
Run 'operations' on the microcontroller, including reporting firmware version, reading the input voltage, setting the output state of the DIO and LEDs, etc. |
|
Send and receive can messages. Supports filtering and timing messages, sending extended and standard frames, and more. |
|
Update the microcontroller’s firmware version. Binaries are available at OnLogic’s support portal. |
The Karbon series microcontroller is managed through two virtual serial interfaces. During normal operation,
this command line utility will automatically detect and attach to the correct interface. The tool additionally
supports a fifth command raw
, that allows manually specifying any available interface.
On most Linux systems, this tool will need the correct permissions in order to access the microcontroller’s interfaces. To achieve this, either run the Karbon CLI as root, or add the current user the "dialout" group.
Method | Command Example |
---|---|
Run the CLI as root |
|
Add user to dialout group |
|
Note
|
When adding a user to the dialout group, you may need to logout or reboot the system before it takes effect. |
On Windows systems, administrative privileges are usually not required when accessing COM devices.
Command Reference
The Karbon command line utility ships with built-in help text. This can be used as a quick reference when
running commands directly on the target machine. Help text can be printed for multiple levels of commands with
the help
flag:
Note
|
Commands in this reference will specified as karbon . For Linux systems, you may need to replace this with
sudo ./karbon or ./karbon . For Windows operating systems, you should replace it with karbon.exe .
|
$ karbon --help
$ karbon <COMMAND> --help
$ karbon <COMMAND> <SUBCOMMAND> --help
Karbon 1.0.1
Run various commands and operations on a Karbon series microcontroller. Access permissions to serial devices are
required, so you may need to run this command with elevated privileges (e.g. `sudo karbon <SUBCOMMAND>`).
Run `karbon <SUBCOMMAND> --help` for detailed help about a command.
USAGE:
karbon [OPTIONS] [SUBCOMMAND]
FLAGS:
-h, --help
Prints help information
-V, --version
Prints version information
OPTIONS:
--gen-completions <gen-completions>
Generate auto-completions for a given shell [possible values: bash, fish, zsh, powershell, elvish]
SUBCOMMANDS:
can Interface with and control the on-board can device
config Set or get a user configuration parameter
help Prints this message or the help of the given subcommand(s)
op Run a command or operation on the microcontroller
raw Run string commands directly against or listen to a specified serial interface
update Update to a new microcontroller firmware version
Config
The config
subcommand handles changing and reporting all configurable system settings. Each parameter can be
called directly:
$ karbon config <PARAMETER>
Which will report the current value of the setting. Or with an argument, which will program the value of that setting:
$ karbon config <PARAMETER> <VALUE>
By default, any configuration changes will not be saved to the microcontroller’s flash memory.
This means that the setting will not be persistent across hard (AC) reboots and power failures.
To give a change persistency, use the save
flag to write the configuration change to flash memory.
$ karbon config -s <PARAMETER> <VALUE>
Important
|
When the save flag is not used configuration changes will not be persistent!
|
It’s also possible to change the current user configuration file whenever running this command. When
the number
flag is specified, the current configuration will be changed to the specified number,
and then the command will be performed. This configuration will not be loaded after a hard-power
cycle, unless you also run the set-as-default
command.
Note
|
The configuration will not be changed back after the operation completes! |
$ karbon config -n <1-4> <PARAMETER> <VALUE>
Configuration Parameters
Parameter | Description |
---|---|
|
The default baudrate of the CAN bus. The baudrate is specified in thousands, and should fall between 100 and 1000 Example
|
The operational mode the CAN bus. This parameter allows for selecting between interpreting CAN commands with the
slcan and standard parsers. The standard parser supports this tool alongside Pykarbon,
while the slcan parser supports a number of standard Linux tools, including Example
|
|
|
If the isolated digital IO will be used for remote power on. When enabled, the system can be powered on by toggling the state of any of the digital inputs. Once the system has powered on, the digital inputs may be used normally. For proper function, the DIO must remain powered while the system is off. Example
|
|
The number of seconds that ignition can remain off, or a low voltage state can occur, before the system is forced to power off. This shutdown event does not respect the operating system’s shutdown sequence. Example
|
|
Enable or disable HDMI CEC (Consumer Electronics Control) functionality. Example
|
|
Decides if display hotplug events will be reported to the processor. When disabled, all display inputs will set the display hotplug pin as if a display is connected at all times. Example
|
|
Enable power management features based on the state of the ignition pin. When this feature is disabled, all ignition events will be ignored, and will not effect the power state of the machine. Example
|
|
Enable or disable entering low power mode (ERP mode), after the system has been shutdown. On K700 systems, when
both this feature and Example
|
|
Displays the entire current user configuration. Example
|
|
The number of seconds that ignition can remain off, or a low voltage state can occur, before the microcontroller will request that the operating system power down. To the operating system, this appears as if a user has pressed the front power button once. Example
|
The low voltage threshold of the system. If detected system voltage falls below this value for longer that the
Example
|
|
|
The number of seconds after ignition rises, before the microcontroller will power the system on. Example
|
|
Set the currently selected configuration to be loaded at boot Example
|
Op
The op
subcommand handles requesting that the system perform certain 'operations'. It supports commands for setting or
reading the state of the digital IO, reporting the system voltage, etc. Most commands will operate normally with
the system 'as is', but both the digital IO and the CAN Bus require some external hardware.
Op Commands
Parameter | Description | ||
---|---|---|---|
|
Calibrate input voltage detection based on measured voltage. Voltage calibration is limited to +- 5%.
Example
|
||
|
Attempts to automatically detect and set the baudrate of the CAN Bus. This functionality is achieved by polling for acknowledgments to messages with ID 0x7FF, and may not be suitable for use in all configurations. Example
|
||
|
Accepts id and data, formats them into a can message, and transmits it the CAN Bus. This function does not support the more sophisticated options that are exposed by the Can command, and only supports standard frames. Example
|
||
|
Reports the current logical state of a specific digital input. Example
|
||
|
Reports the current logical states of the digital inputs/outputs. This is represented by eight characters, each a '1' or a '0'. The bit order is: Example
|
||
|
Reports the current input voltage, as measured by the microcontroller. If this voltage is below the value of shutdown-voltage the system will power off. Example
|
||
|
Reports the baseboard name Example
|
||
|
Sets the state of a digital output as on or off. Outputs are numbered from 0 - 3. (See Karbon DIO Pinout) Example
|
||
|
Sets the state of a numbered front LED to on or off. LEDs are numbered from 1 - 4. Example
|
||
|
Reports system status information. Actual information reported will vary by system. Example
|
||
|
Sets the currently selected user configuration. The system supports up to four user configurations, each holding
a copy of the Configuration Parameters. It is also possible to switch between configurations using the Example
|
||
|
Reports the system firmware version and build date. Example
|
Can
The can
subcommand supports interfacing with and controlling the onboard CAN device. This includes sending and
receiving CAN messages and setting the baudrate of the CAN Bus. This module requires the CAN device be
configured standard operational mode. The mode of the CAN device is controlled by the
can-mode configuration parameter.
The CAN device does not support internal termination, and should be externally terminated when connected to a CAN bus.
By default, the can
subcommand will first check the operational mode before sending a command. Because this is
slower than just sending or receiving can messages, and requires access to the terminal port, it can disabled with
the --nocheck
flag.
$ karbon can -n <COMMAND>
Additionally all can operations support setting the baudrate before processing the command. This requires access to the terminal serial interface, and does not change the baudrate that will be loaded at system boot. If no baudrate is specified, the last transmitted baudrate will continue to be used.
$ karbon can -b 500 <COMMAND>
The baudrate is specified in Kbits/s, and supports setting rates from 100-1000.
Can Commands
Send
The send
command supports sending standard, extended, and remote frames. All messages require an id. Standard
and extended frames also require data. Standard frames are sent by default, while extended and remote frames can
be sent by using the corresponding flag.
$ karbon can send [FLAGS] [OPTIONS] <identifier> [data]
Argument | Description | Type |
---|---|---|
|
The data to be transmitted, represented as an up-to eight byte hex string. Passed data will be checked for
validity before transmission. This argument is required, except when sending remote request frames ( Example
|
|
|
The 'id' of the can frame. Should be specified as hex string from Lower numbered frames will have priority during message arbitration, and by default, the id will be interpreted as a standard frame id. Validity checking will be performed against the hex string and id range. |
|
|
Send message in extended frame format. Supports larger id range. Example
|
|
|
Length of data to be transmitted. If not specified, the data length will be automatically determined. Example
|
|
|
Send a remote frame. When specified, Example
|
|
Dump
The dump
command supports reporting all received CAN messages. Messages may be filtered by id
, and the time
between frames can be recorded.
By default, the messages will be formatted and printed to stdout
, but the data can also be reported in csv
format and/or saved to file.
For instance, to print all messages to the terminal along with their time delta, run:
$ karbon can dump -d
Or to log only messages with a matching id to messages.csv
, run:
$ karbon can dump -d -c -f 123 7FF -- messages.csv
karbon can dump [FLAGS] [OPTIONS] [--] [output]
Argument | Description | Type | ||
---|---|---|---|---|
|
Format the output as a csv. Does not redirect output from Example
|
|
||
|
Log the time delta between frames. Times will be reported as floating point seconds; 1.001 is 1001 milliseconds. Time delta is calculated at the host, and should not be considered a perfect representation of time between frames. Example
|
|
||
|
A list of CAN frame identifiers to match received messages against. All other messages will be discarded.
Example
|
|
||
|
The output location for printing CAN frames. Defaults to |
|
Update
The update
subcommand simply handles updating the microcontroller’s firmware version. Update binaries are
available from OnLogic’s
support site.
To update the system’s firmware, download a binary update file and run karbon update <filename>
.
$ karbon update Karbon_v3.1.2.1.bin
Tip
|
If the system ever encounters an un-recoverable error (for instance, power-loss during an update), you can manually start the system in bootloader mode by attaching wall/AC power while depressing the pinhole settings button. If done correctly, the watchdog light will start blinking. The system should now boot normally, and the 'update' command will be available for firmware re-flashing. |
Generate Shell Completions
This utility is capable of generating a bash completion script for the following shells: bash, fish, zsh, powershell, and elvish. Once a script has been generated and sourced, it will be possible to use TAB to auto-complete entered commands.
Shell completions only affect user experience, and are not required to run any microcontroller commands.
$ karbon --gen-completions bash > karbon_completions.bash
$ source karbon_completions.bash
Changes
1.0.3
-
Fix port kind detection on certain Windows systems
-
Improve reading multi-line messages on Windows
-
Don’t print two empty lines when closing "can-dump"