Crate kwr103

source ·
Expand description

KWR103 remote controllable power supply

This crate provides remote control access to Korad KWR103 type power supplies implementing both, serial/USB and ethernet/UDP based, communication channels.

Example

use kwr103::{command::*, Kwr103, TransactionError, UsbConnection};

fn main() -> Result<(), TransactionError> {
    // Establish USB connection
    let mut kwr103: Kwr103 = UsbConnection::new("/dev/ttyACM0", 115200, None)?.into();

    // Adjust voltage and current settings
    kwr103.command(Voltage(42.0))?;
    kwr103.command(Current(1.2))?;
     
    // Switch output on
    kwr103.command(Output(Switch::On))?;

    // Query status, prints e.g. "Output: On, Voltage[V]: 42.000, Current[A]: 0.131"
    println!("{}", kwr103.query::<Status>()?);

    Ok(())
}

Command Line Interface

To control the power supply from a terminal, you can use the kwr103 command line tool. Use kwr103 --help for the full specification.

> kwr103 status
Output: Off, Voltage[V]: 0.000, Current[A]: 0.000

> kwr103 output on
> kwr103 status
Output: On, Voltage[V]: 42.000, Current[A]: 0.131

Automatic connection discovery

The kwr103 command line tool will attempt to automatically find the connection details for the attached power supply, whether it is serial or ethernet connected.

In case you want to specify the connection details explicitly instead, use the corresponding CLI parameters, i.e.

  • --device=<PATH> for a serial connected power supply
  • --ip=<IPv4ADDR> for an ethernet connected power supply

In case the automatic discovery finds more than a single power supply unit, no action will be taken for safety reasons. In this case you will be prompted to specify the connection details explicitly.

Re-exports

Modules

  • Command and query types to interact with the power supply
  • Error types for the KWR103 power supply crate
  • UDP communication for ethernet connected power supplies
  • Serial communication for USB connected power supplies

Structs

  • A KWR103 type power supply

Traits

  • A command to be issued to the power supply.
  • A query to be issued to the power supply.
  • A type implementing Transport defines how to physically communicate with the power supply