# mokucli command

Execute a single Moku API command.

This is not a substitute for running a full script, as the setup and teardown time can be quite long. It is useful for quickly running a single command, for example to generate a waveform, or for retrieving a specific measurement. It can also be used for device commands such as moku reboot.

Combine with jq to extract specific fields from the JSON response. For example: mokucli command Oscilloscope get_data --ip=192.168.1.100 measurements=True | jq '.measurements.ch1.amplitude'

# Usage

$ mokucli command [OPTIONS] OBJECT_NAME FUNCTION_NAME
1

# Constructor Options

  • --ip=<address>: IP address of the Moku device (required)
  • --force-connect: Force connection even if device is in use
  • --persist-state: Persist instrument state (default: True, use --persist-state=False to disable)
  • --ignore-busy: Ignore device busy errors
  • --connect-timeout=<int>: Connection timeout in seconds
  • --read-timeout=<int>: Read timeout in seconds

# Arguments

  • PATH: Optional path within the data directory to clear (e.g.,'instruments', 'instruments/18480', 'firmware/611'). If not specified, clears entire cache.
  • object_name: TEXT Moku object (e.g., 'Moku', 'Oscilloscope', 'WaveformGenerator') [required]
  • function_name: TEXT Function to call on the object [required]

# Options

  • --verbose, -v: Show detailed error messages
  • --help: Show this message and exit

# Examples

# Print the device serial number
mokucli command Moku serial_number --ip=192.168.1.100

# Show the oscilloscope timebase settings
mokucli command Oscilloscope get_timebase --ip=192.168.1.100

# Generate a 1 kHz sine waveform on channel 1 with 1.0 V amplitude and 0.0 V offset
mokucli command WaveformGenerator generate_waveform --ip=192.168.1.100 ch=1
   type=Sine frequency=1000 amplitude=1.0 offset=0.0

# Reboot the device (force connect if it's in use)
mokucli command Moku reboot --ip=192.168.1.100 --force-connect

# Retrieve oscilloscope data and extract channel 1 amplitude using jq
mokucli command Oscilloscope get_data --ip=192.168.1.100 measurements=True |
   jq '.measurements.ch1.amplitude'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# Output

# Printout the Oscilloscope timebase
$ mokucli command Oscilloscope get_timebase --ip=192.168.1.100
{
  "t1": -0.0005,
  "t2": 0.0005
}
1
2
3
4
5
6