m2kcli is a command-line frontend for libm2k.
m2kcli is composed from many commands, each representing a major functionality of the ADALM-2000:
m2kcli offers an easy way to communicate with other devices using digital protocols such as:
In the Select Additional Tasks window, select Install libm2k tools option.
Build and install libm2k. Instruction can be found here. Make sure to enable tools option.
~/libm2k/build$ cmake -DENABLE_TOOLS=ON ../
Check the ENABLE_TOOLS box in CMake GUI.
All commands require an URI. URI describes the context location.
Common options:
help
Show the help message and exit.
quiet
Return the result only.
m2kcli analog-in <uri> [-h | --help] [-q | --quiet] [-C | --calibrate] [-v | --voltage channel=<index>,... raw=<value>] [-c | --capture channel=<index>,... buffer_size=<size> raw=<value> [nb_samples=<value>] [format=<type>]] [-g | --get <attribute>...] [-G | --get-channel channel=<index>,... <attribute>...] [-s | --set <attribute>=<value>...] [-S | --set-channel channel=<index> <attribute>=<value>...]
analog-in command controls the analogical input component, having two main functions: oscilloscope and voltmeter. The available channels for analog in are channel 0 and channel 1.
Pinout:
▤ ▥ □ □ □ □ □ □ □ □ □ □ □ □ □
▤ ▥ □ □ □ □ □ □ □ □ □ □ □ □ □
Options:
calibrate
Calibrate the ADC.
voltage
Return the voltage of the given channels. The result is printed to standard output.
Mandatory arguments:
Examples:
m2kcli analog-in auto -v channel=0,1 raw=1
m2kcli analog-in auto --voltage channel=0 raw=0 -q
capture
Return a specific number of samples. The result is printed to standard output.
Mandatory arguments:
Optional arguments:
Examples:
m2kcli analog-in auto --capture channel=0,1 buffer_size=1024 nb_samples=2048 raw=1 format=binary > file.bin
m2kcli analog-in ip:192.168.2.1 -c channel=1 buffer_size=1024 raw=0
get
Return the value of the global attributes. Enumerate the attributes with a space between them.
Attributes:
Examples:
m2kcli analog-in auto --get all
m2kcli analog-in auto -g sampling_frequency oversampling_ratio
get-channel
Return the value of the attributes corresponding the the given channels.
Mandatory arguments:
Attributes:
Examples:
m2kcli analog-in --get-channel channel=0,1 all
m2kcli analog-in -G channel=1 trigger_condition
set
Set the value of the global attributes.
Attributes:
Examples:
m2kcli analog-in auto --set sampling_frequency=100000 trigger_source=channel_1
set-channel
Set the value of the attributes corresponding to the given channels.
Mandatory arguments:
Attributes:
Examples:
m2kcli analog-in auto --set-channel channel=1 range=high trigger_mode=analog
m2kcli analog-out <uri> [-h | --help] [-q | --quiet] [-C | --calibrate] [-9 | --generate channel=<index>,... cyclic=<value> raw=<value> [buffer_size=<size>] [format=<type>]] [-G | --get-channel channel=<index> <attribute>...] [-S | --set-channel channel=<index> <attribute>=<value>...]
analog-out command controls the analogical output component, having the main functions of a signal generator. The available channels for analog out are channel 0 and channel 1.
Pinout:
□ □ □ □ ▤ □ □ □ □ □ □ □ □ □ □
□ □ □ □ ▥ □ □ □ □ □ □ □ □ □ □
Options:
calibrate
Calibrate both DACs.
generate
Generate signals for the specified channels. The samples are read from the standard input.
Mandatory arguments:
Optional arguments:
Examples:
m2kcli analog-out auto --generate channel=0 cyclic=1 raw=0 buffer_size=1024 < file.csv
get-channel
Return the value of the attributes corresponding to the given channel.
Mandatory arguments:
Attributes:
Examples:
m2kcli analog-out auto -G channel=0 all
set-channel
Set the value of the attributes corresponding to the given channel.
Mandatory arguments:
Attributes:
Examples:
m2kcli analog-out auto -S channel=0,1 sampling_frequency=7500
m2kcli digital <uri> [-h | --help] [-q | --quiet] [-c | --capture buffer_size=<size> [nb_samples=<value>] [format=<type>]] [-9 | --generate channel=<index>,... cyclic=<value> [buffer_size=<size>] [format=<type>]] [-g | --get <attribute>...] [-G | --get-channel channel=<index>,... <attribute>...] [-s | --set <attribute>=<value>...] [-S | --set-channel channel=<index>,... <attribute>=<value>...]
digital command controls the digital input and output component, having two main functions: logic analyzer and pattern generator. The available channels for digital are between 0 and 15.
Pinout:
□ □ □ □ □ □ □ ■ ■ ■ ■ ■ ■ ■ ■
□ □ □ □ □ □ □ ■ ■ ■ ■ ■ ■ ■ ■
Options:
capture
Return a specific number of samples. The result is printed to standard output.
Mandatory arguments:
Optional arguments:
Examples:
m2kcli digital auto -c buffer_size=60 nb_samples=100
m2kcli digital auto -c buffer_size=1000 format=binary
generate
Generate digital signals for the specified channels.The samples are read from the standard input.
Mandatory arguments:
Optional arguments:
Examples:
m2kcli digital auto -9 channel=0,1,4,5,14 cyclic=1 < file.csv
get
Return the value of the global attributes.
Attributes:
Examples:
m2kcli digital auto -g all
get-channel
Return the value of the attributes corresponding the the given channels.
Mandatory arguments:
Attributes:
Examples:
m2kcli digital auto --get-channel channel=0,1,2,3,4 all
set
Set the value of the global attributes.
Attributes:
Examples:
m2kcli digital auto -s trigger_mode=or
set-channel
Set the value of the attributes corresponding to the given channels.
Mandatory attributes:
Attributes:
Examples:
m2kcli digital auto -S channel=7 trigger_condition=rising_edge
m2kcli power-supply <uri> [-h | --help] [-q | --quiet] [-C | --calibrate] [-c | --capture channel=<index>...] [-9 | --generate channel=<index>,... value=<value>]
power-supply command controls the power supply. The available channels for power supply are channel 0 and channel 1.
Pinout:
□ □ □ ▤ □ □ □ □ □ □ □ □ □ □ □
□ □ □ ▥ □ □ □ □ □ □ □ □ □ □ □
Options:
calibrate
Calibrate the ADC.
capture
Return the value, read by the power supply. The result is printed to standard output.
Mandatory arguments:
Examples:
m2kcli power-supply auto --capture channel=0,1
generate
Generate the specified value for the given channels.
Mandatory arguments:
Examples:
m2kcli power-supply auto --generate channel=0,1 value=4
m2kcli spi <uri> [-h | --help] [-i | --init [frequency=<value> clk=<value> mosi=<index> [miso=<index>] cs=<index> mode=<value> bit_numbering=<value>] [-w | --write data=<value>,...]
spi command communicates with an SPI device.
Options:
init
Initialize all channels used by the protocol to communicate.
Mandatory arguments:
Optional arguments:
write
Write the given data and display back the read data. Before writing, the SPI protocol must be initialized.
Mandatory arguments:
Examples:
m2kcli spi auto -i frequency=1000000 clk=1 mosi=2 miso=7 bit_numbering=MSB cs=0 mode=3 -w data=0x09,0xC4
m2kcli i2c <uri> [-h | --help] [-i | --init frequency=<value> address=<value> scl=<index> sda=<index> [write_only=<value>]] [-w | --write data=<value>,... option=<value> [write_only=<value>]] [-r | --read bytes_number=<value> option=<value>]
i2c command communicates with an I²C device.
Options:
init
Initialize all channels used by the protocol to communicate.
Mandatory arguments:
Optional arguments:
write
Write the given data. Before writing, the I²C protocol must be initialized.
Mandatory arguments:
read
Read a given number of bytes. Before reading, the I²C protocol must be initialized.
Mandatory arguments:
Examples:
m2kcli i2c ip:192.168.2.1 -i frequency=100000 address=0x48 scl=0 sda=1 -w data=0x0B option=3 m2kcli i2c ip:192.168.2.1 -i frequency=100000 address=0x48 scl=0 sda=1 -r bytes_number=1 option=1 m2kcli i2c ip:192.168.2.1 -i frequency=100000 address=0x48 scl=0 sda=1 -w data=0 option=3 m2kcli i2c ip:192.168.2.1 -i frequency=100000 address=0x48 scl=0 sda=1 -r bytes_number=2 option=1
m2kcli uart <uri> [-h | --help] [-i | --init device=<index> baud_rate=<value> parity=<value> bits_number=<value> stop_bits=<value>] [-w | --write data=<value>,...] [-r | --read bytes_number=<value> format=<value>]
uart command communicates with an UART device.
Options:
init
Initialize all channels used by the protocol to communicate.
Mandatory arguments:
write
Write the given data. Before writing, the UART protocol must be initialized.
Mandatory arguments:
read
Read a given number of bytes. Before reading, the UART protocol must be initialized.
Mandatory arguments:
Examples:
First terminal
m2kcli uart ip:192.168.2.1 -i device=1 baud_rate=9600 parity=none bits_number=8 stop_bits=1 -r bytes_number=3 format=text
Second terminal
m2kcli uart ip:192.168.2.1 -i device=0 baud_rate=9600 parity=none bits_number=8 stop_bits=1 -w data=ADI
m2kcli uart-terminal <uri> [-h | --help] [-i | --init rx=<index> tx=<index> baud_rate=<value> parity=<value> bits_number=<value> stop_bits=<value>]
uart-terminal command continuously communicates with an UART device, simulating a terminal.
Options:
init
Initialize the UART communication.
Mandatory arguments:
Examples:
m2kcli uart-terminal auto -i baud_rate=115200 rx=15 tx=7 stop_bits=1 parity=none bits_number=8
Sigrok is a portable, cross-platform, free open source signal analysis software. sigrok-cli is a command-line frontend for sigrok. A a much wider documentation about sigrok-cli can be found on this wiki page.
sigrok-cli can be used for decoding digital signals. m2kcli does not have the functionality of continuously decoding SPI or I²C signals. Using sigrok-cli for decoding the data and m2kcli for capturing the data, we can simulate this functionality.
How to get sigrok-cli?
Sigrok offers two main possibilities of getting the cli. Building from source or downloading the packages. All the steps are well described on their wiki page. For building sigrok-cli have a look at this page, while for downloading the binaries and the distribution packages have a lookhere.
Example:
In the following example ADALM-2000 is connected to an I²C device and we are using a Linux AppImage binary for sigrok-cli.
m2kcli digital auto -s sampling_frequency_in=1000000 m2kcli digital auto -c buffer_size=1000 format=binary | sigrok-cli -i - -I binary:numchannels=16:samplerate=1mhz -P i2c:scl=15:sda=7 -A i2c=address-read:address-write:data-read:data-write