USB-DAQ-F1-D

Device pinout

USBDAQF1D

API function description

class pywpc.USBDAQF1D
  1. 3.3V digital I/O

  2. 26ch 3.3V (5V-tolerant)

  3. DIO/I2C/SPI/UART/PWM/pulse counter/encoder counter

  4. I2C: max. 400KHz

  5. USB 2.0 full-speed bus powered

Counter_close(channel, timeout=3)

Close counting on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Counter_close_async(channel)

Close counting on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Counter_open(channel, timeout=3)

Open counter on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Counter_open_async(channel)

Open counter on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Counter_readFrequency(channel, timeout=3)

Read the value of counter frequency on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
frequencyfloat

Counter frequency.

async Counter_readFrequency_async(channel)

Read the value of counter frequency on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
frequencyfloat

Counter frequency.

Counter_readPosition(channel, timeout=3)

Read the value of counter position on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
positionuint64

Counter position.

async Counter_readPosition_async(channel)

Read the value of counter position on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
positionuint64

Counter position.

Counter_setEdge(channel, edge, timeout=3)

Set counter edge on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

edgeint

0: Falling edge. 1: Rising edge.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Counter_setEdge_async(channel, edge)

Set counter edge on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

edgeint

0: Falling edge. 1: Rising edge.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Counter_setFreqWindow(channel, window_size, timeout=3)

Set moving window size on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

window_sizefloat

Moving window size. Default value is 100ms, and the minimum value is 20 ms.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Counter_setFreqWindow_async(channel, window_size)

Set moving window size on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

window_sizefloat

Moving window size. Default value is 100ms, and the minimum value is 20 ms.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Counter_setPosition(channel, position, timeout=3)

Set counter position on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

positionuint 64

The counter position.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Counter_setPosition_async(channel, position)

Set counter position on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

positionuint 64

The counter position.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Counter_start(channel, timeout=3)

Start counting on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Counter_start_async(channel)

Start counting on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Counter_stop(channel, timeout=3)

Stop counting on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Counter_stop_async(channel)

Stop counting on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DIO_loadStartup(port, timeout=3)

Load DIO values from EEPROM.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
enable_list
  • Get status about pin enable.

  • 0: disable, 1: enable

direction_list
  • Get status about pin direction.

  • 0: input, 1: output

state_list
  • Get status about pin state.

async DIO_loadStartup_async(port)

Load DIO values from EEPROM with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
enable_list
  • Get status about pin enable.

  • 0: disable, 1: enable

direction_list
  • Get status about pin direction.

  • 0: input, 1: output

state_list
  • Get status about pin state.

DI_closePins(port, pin, timeout=3)

Close the specific pin to digital intput.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DI_closePins_async(port, pin)

Close the specific pin to digital intput with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DI_closePort(port, timeout=3)

Close all pins in the specific port to digital input.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DI_closePort_async(port)

Close all pins in the specific port to digital input with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DI_getPinMap()

Get all available DI port numbers & the pins that are associated with them.

Returns:
Pinmapdictionary

Each key is an available port. Its associated value yields the corresponding pins of that port.

Each pin is an integer representing its number.

For example: {0: [0, 1, 2, 3, 4, 5, 6, 7], 1: [0, 1, 2, 3, 4, 5]} means that there are two DI ports.

They are numbered as 0 & 1. Port 0 has 8 pins: P0.0 to P0.7. Port 1 has 6 pins: P1.0 to P1.5.

General format: {DI_port: [pin, …, pin]}.

DI_openPins(port, pin, timeout=3)

Open the specific pin to digital intput.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DI_openPins_async(port, pin)

Open the specific pin to digital intput with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DI_openPort(port, timeout=3)

Open all pins in the specific port to digital input.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DI_openPort_async(port)

Open all pins in the specific port to digital input with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DI_readPins(port, pin, timeout=3)

Read the specefic pin state.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statelist

Get status about pin state.

async DI_readPins_async(port, pin)

Read the specefic pin state with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

Returns:
statelist

Get status about pin state.

DI_readPort(port, timeout=3)

Read all pins state in the specific port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statelist

Get status about pin state.

async DI_readPort_async(port)

Read all pins state in the specific port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statelist

Get status about pin state.

DO_closePins(port, pin, timeout=3)

Close the specific pin to digital output.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DO_closePins_async(port, pin)

Close the specific pin to digital output with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

pinlist
  • Pin number you want to close.

  • For example, you want to close pin 0, pin 1 and pin 5.

  • pin [0,1,5].

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DO_closePort(port, timeout=3)

Close all pins in the specific port with digital output.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DO_closePort_async(port)

Close all pins in the specific port with digital output with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DO_getPinMap()

Get all available DO port numbers & the pins that are associated with them.

Returns:
Pinmapdictionary

Each key is an available port. Its associated value yields the corresponding pins of that port.

Each pin is an integer representing its number.

For example: {0: [0, 1, 2, 3, 4, 5, 6, 7], 1: [0, 1, 2, 3, 4, 5]} means that there are two DO ports.

They are numbered as 0 & 1. Port 0 has 8 pins: P0.0 to P0.7. Port 1 has 6 pins: P1.0 to P1.5.

General format: {DO_port: [pin, …, pin]}.

DO_openPins(port, pin, timeout=3)

Open the specific pin to digital output.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DO_openPins_async(port, pin)

Open the specific pin to digital output with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list
  • Pin number you want to set to digital output.

  • For example, you want to set pin 0, pin 1 and pin 5.

  • pin [0, 1, 5].

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DO_openPort(port, timeout=3)

Open all pins in the specific port to digital output.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DO_openPort_async(port)

Open all pins in the specific port to digital output with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DO_togglePins(port, pin, timeout=3)

Toggle the specific pin.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statelist
  • The list of pins state.

async DO_togglePins_async(port, pin)

Toggle the specific pin with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list

Pin number you want to set. For example, you want to set pin 0, pin 1 and pin 5. pin_index will be [0, 1, 5].

Returns:
statelist
  • The list of pins state.

DO_togglePort(port, timeout=3)

Toggle all pins in the specific port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statelist
  • The list of pins state.

async DO_togglePort_async(port)

Toggle all pins in the specific port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statelist
  • The list of pins state.

DO_writePins(port, pin, value, timeout=3)

Write high or low value to the specific pin.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list
  • Pin number you want to set.

  • For example, you want to set pin 0, pin 1 and pin 5.

  • pin = [0, 1, 5].

valueint or list
  • Pin number you want to set high or low.

  • High = 1, Low = 0.

  • For example, set pin 0 and pin 1 to high, and pin 5 to low.

  • value = [1, 1, 0].

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DO_writePins_async(port, pin, value)

Write high or low value to the specific pin with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

pinint or list
  • Pin number you want to set.

  • For example, you want to set pin 0, pin 1 and pin 5.

  • pin = [0, 1, 5].

valueint or list
  • Pin number you want to set high or low.

  • High = 1, Low = 0.

  • For example, set pin 0 and pin 1 to high, and pin 5 to low.

  • value = [1, 1, 0].

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

DO_writePort(port, value, timeout=3)

Write high or low value to all pins in the specefic port.

Parameters:
portint

See here for available ports of different WPC devices.

valueint or list
  • Pin number you want to set digital high or low.

  • High = 1, Low = 0.

  • For example if intput type is list

  • you want to write pin 0 and pin 2 to high, others to low.

  • [1, 0, 1, 0, 0, 0, 0, 0] in LSB.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async DO_writePort_async(port, value)

Write high or low value to all pins in the specefic port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

valueint or list
  • Pin number you want to set digital high or low.

  • High = 1, Low = 0.

  • For example if intput type is list

  • you want to write pin 0 and pin 2 to high, others to low.

  • [1, 0, 1, 0, 0, 0, 0 ,0] in LSB.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Encoder_close(channel, timeout=3)

Close encoder on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Encoder_close_async(channel)

Close encoder on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Encoder_getDirection(channel, timeout=3)

Get encoder direction on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

The direction of encoder.

async Encoder_getDirection_async(channel)

Get encoder direction on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

The direction of encoder.

Encoder_open(channel, timeout=3)

Open encoder on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Encoder_open_async(channel)

Open encoder on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Encoder_readFrequency(channel, timeout=3)

Read the value of encoder frequency on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
frequencyfloat

Encoder frequency.

async Encoder_readFrequency_async(channel)

Read the value of encoder frequency on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
positionint

Encoder frequency.

Encoder_readPosition(channel, timeout=3)

Read the value of encoder position on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
positionint

Encoder position.

async Encoder_readPosition_async(channel)

Read the value of encoder position on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
positionint

Encoder position.

Encoder_setDirection(channel, direction, timeout=3)

Set encoder direction on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

directionint

1: Forward. -1: Reverse.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Encoder_setDirection_async(channel, direction)

Set encoder direction on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

directionint

1: Forward. -1: Reverse.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Encoder_setFreqWindow(channel, window_size, timeout=3)

Set moving window size on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

window_sizefloat

Moving window size. Default value is 100ms, and the minimum value is 20 ms.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Encoder_setFreqWindow_async(channel, window_size)

Set moving window size on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

window_sizefloat

Moving window size. Default value is 100ms, and the minimum value is 20 ms.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Encoder_setPosition(channel, position, timeout=3)

Set encoder position value on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

position: int 64

The encoder position.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Encoder_setPosition_async(channel, position)

Set encoder position value on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

position: int 64

The encoder position.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Encoder_start(channel, timeout=3)

Start reading encoder on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Encoder_start_async(channel)

Start reading encoder on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Encoder_stop(channel, timeout=3)

Stop reading encoder on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Encoder_stop_async(channel)

Stop reading encoder on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

I2C_close(port, timeout=3)

Close I2C on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async I2C_close_async(port)

Close I2C on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

I2C_getPinMap()

Get all available I2C port numbers & the pins that are associated with them.

Returns:
Pinmapdictionary

Each key is an available port. Its associated value yields the corresponding pins of that port.

Each pin is a tuple constituted of its physical port number & pin number.

For example: {1: [(2, 6), (2, 7)], 2: [(3, 0), (3, 1)]} means that there are two I2C ports.

They are numbered as 1 & 2. I2C1 has two pins: P2.6 & P2.7. I2C2 has two pins: P3.0 & P3.1.

General format: {I2C_port: [(port, pin), …, (port, pin)]}.

I2C_open(port, timeout=3)

Open I2C on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async I2C_open_async(port)

Open I2C on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

I2C_read(port, read_address, bytes_to_read, timeout=3)

Read data from the address via I2C.

Parameters:
portint

See here for available ports of different WPC devices.

read_addressint

7-bit slave address of the device to request bytes from.

bytes_to_readint

The number of bytes to receive.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
I2C_datalist of bytes

The received data.

async I2C_read_async(port, read_address, bytes_to_read)

Read data from the address via I2C with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

read_addressint

7-bit slave address of the device to request bytes from.

bytes_to_readint

The number of bytes to receive.

Returns:
I2C_datalist of bytes

The received data.

I2C_reset(port, timeout=3)

Reset I2C to the default setting on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async I2C_reset_async(port)

Reset I2C to the default setting on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

I2C_setAddressSize(port, mode, timeout=3)

Set I2C address size on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: 7-bit address.

  • 1: 10-bit address.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async I2C_setAddressSize_async(port, mode)

Set I2C address size on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: 7-bit address.

  • 1: 10-bit address.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

I2C_setClockRate(port, mode, timeout=3)

Set I2C clock on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

frequencyint
  • 0: standard (100000).

  • 1: fast (400000).

  • 2: fast Plus (1000000).

  • 3: high speed (3400000).

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async I2C_setClockRate_async(port, mode)

Set I2C clock on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

frequencyint
  • 0: standard (100000).

  • 1: fast (400000).

  • 2: fast Plus (1000000).

  • 3: high speed (3400000).

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

I2C_write(port, write_address, write_data, timeout=3)

Write data to the address via I2C.

Parameters:
portint

See here for available ports of different WPC devices.

write_addressint

7-bit slave address of the device to send bytes.

write_datalist of bytes

The list of data to be transferred.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async I2C_write_async(port, write_address, write_data)

Write data to the address via I2C with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

write_addressint

7-bit slave address of the device to send bytes.

write_datalist of bytes

The list of data to be transferred.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Logger_openFile(filename, clear_old=True, verbose=True)

Open CSV file.

Parameters:
filenamestr

The file name.

clear_oldbool, default: True

Whether to clear old data (if the file alread exists) or not.

verbosebool, default: True

Whether to print message out.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Logger_write2DList(value_mat)

Write list of list into file.

Parameters:
value_matlist of list

The list of list of data to be written.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Logger_writeHeader(header)

Write header into file.

Parameters:
headerlist of str

Header to be written.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Logger_writeList(value_list)

Write list into file.

Parameters:
value_listlist

The list of data to be written.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Logger_writeValue(value)

Write value into file.

Parameters:
valueobject

The data to be written.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

PWM_close(channel, timeout=3)

Close PWM on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async PWM_close_async(channel)

Close PWM on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

PWM_open(channel, timeout=3)

Open PWM on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async PWM_open_async(channel)

Open PWM on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

PWM_setDutyCycle(channel, duty_cycle, timeout=3)

Set PWM duty cycle on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

duty_cyclefloat

It is the amount of time a digital signal is in the active state relative to the period of the signal.(%)

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async PWM_setDutyCycle_async(channel, duty_cycle)

Set PWM duty cycle on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

duty_cyclefloat

It is the amount of time a digital signal is in the active state relative to the period of the signal. (%)

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

PWM_setFrequency(channel, frequency, timeout=3)

Set PWM frequency on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

frequencyfloat

frequency (HZ)

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async PWM_setFrequency_async(channel, frequency)

Set PWM frequency on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

frequencyfloat

frequency (HZ)

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

PWM_start(channel, timeout=3)

Start PWM on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async PWM_start_async(channel)

Start PWM on the specific channel with async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

PWM_stop(channel, timeout=3)

Stop PWM on the specific channel.

Parameters:
channelint

See here for available channel of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async PWM_stop_async(channel)

Stop PWM on the specific channel async mode.

Parameters:
channelint

See here for available channel of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

SPI_close(port, timeout=3)

Close SPI on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async SPI_close_async(port)

Close SPI on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

SPI_getPinMap()

Get all available SPI port numbers & the pins that are associated with them.

Returns:
Pinmapdictionary

Each key is an available port. Its associated value yields the corresponding pins of that port.

Each pin is a tuple constituted of its physical port number & pin number.

For example: {1: [(2, 1), (2, 2), (2, 3)], 2: [(3, 3), (3, 4), (3, 5)]} means that there are two SPI ports.

They are numbered as 1 & 2. SPI1 has three pins: P2.1 & P2.2 & P2.3.

SPI2 has three pins: P3.3 & P3.4 & P3.5.

General format: {SPI_port: [(port, pin), …, (port, pin)]}.

SPI_open(port, timeout=3)

Open SPI on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async SPI_open_async(port)

Open SPI on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

SPI_read(port, bytes_to_read, timeout=3)

Read data via SPI.

Parameters:
portint

See here for available ports of different WPC devices.

bytes_to_readint

The number of bytes to receive.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
datalist

The list of received data.

SPI_readAndWrite(port, write_data, timeout=3)

Write and read data via SPI.

Parameters:
portint

See here for available ports of different WPC devices.

write_datalist of bytes

The list of data to be transferred.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
SPI_datalist of bytes

The received data.

async SPI_readAndWrite_async(port, write_data)

Write and read data via SPI with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

write_datalist of bytes

The list of data to be transferred.

Returns:
datalist

The list of received data.

async SPI_read_async(port, bytes_to_read)

Read data via SPI with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

bytes_to_readint

The number of bytes to receive.

Returns:
datalist

The list of received data.

SPI_reset(port, timeout=3)

Reset SPI to the default setting on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async SPI_reset_async(port)

Reset SPI to the default setting on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

SPI_setDataSize(port, mode, timeout=3)

Set data frame format on a given port. Please check SPI data size mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: 8-bit data.

  • 1: 16-bit data.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async SPI_setDataSize_async(port, mode)

Set data frame format on a given port with async mode. Please check SPI data size mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: 8-bit data.

  • 1: 16-bit data.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

SPI_setFirstBit(port, mode, timeout=3)

Set SPI first bit on a given port.. Please check SPI MSB/LSB mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: MSB first.

  • 1: LSB first.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async SPI_setFirstBit_async(port, mode)

Set SPI first bit on a given port. with async mode. Please check SPI MSB/LSB mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: MSB first.

  • 1: LSB first.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

SPI_setMode(port, mode, timeout=3)

Set clock phase and polarity with mode on a given port. Please check SPI mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: CPOL= 0, CPHA= 0.

  • 1: CPOL= 0, CPHA= 1.

  • 2: CPOL= 1, CPHA= 0.

  • 3: CPOL= 1, CPHA= 1.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async SPI_setMode_async(port, mode)

Set clock phase and polarity with mode on a given port with async mode. Please check SPI mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: CPOL= 0, CPHA= 0

  • 1: CPOL= 0, CPHA= 1

  • 2: CPOL= 1, CPHA= 0

  • 3: CPOL= 1, CPHA= 1

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

SPI_setPrescaler(port, prescaler, timeout=3)

Set SPI prescaler on a given port. Please check SPI clock.

Parameters:
portint

See here for available ports of different WPC devices.

prescalerint

Prescaler : 2, 4, 8, 16, 32, 64, 128, 256.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async SPI_setPrescaler_async(port, prescaler)

Set SPI prescaler on a given port with async mode. Please check SPI clock.

Parameters:
portint

See here for available ports of different WPC devices.

prescalerint

Prescaler : 2, 4, 8, 16, 32, 64, 128, 256.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

SPI_write(port, write_data, timeout=3)

Write data via SPI.

Parameters:
portint

See here for available ports of different WPC devices.

write_datalist of bytes

The list of data to be transferred.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async SPI_write_async(port, write_data)

Write data via SPI with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

write_datalist of bytes

The list of data to be transferred.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_getDeviceAlias(timeout=3)

Get device alias name.

Parameters:
timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
Alias namestring

The alias name of the device.

async Sys_getDeviceAlias_async()

Get device alias name with async mode.

Returns:
Alias namestring

The alias name of the device.

Sys_getDriverInfo(timeout=3)

Get device firmware information.

Parameters:
timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
driver_infolist of three string
  • driver_info[0]: Model name.

  • driver_info[1]: Mode.

  • driver_info[2]: Firmware version.

async Sys_getDriverInfo_async()

Get device firmware information with async mode.

Returns:
driver_infolist of three string
  • driver_info[0]: Model name.

  • driver_info[1]: Mode.

  • driver_info[2]: Firmware version.

Sys_getMode(slot, timeout=3)

Get the mode from a given slot.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
str_str

Mode of slot.

async Sys_getMode_async(slot)

Get the mode from a given slot with async mode.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

Returns:
str_str

Mode of slot.

Sys_getPinModeInPort(port, timeout=3)

Get pin mode in specific port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
pinsint

How many pins in specific port.

pin_modelist of 8 string
  • [pin0, pin1,……pin7]

  • pinmode : Disabled, Idle, DI, DO, UART, I2C, SPI, CAN, PWM and ADC.

async Sys_getPinModeInPort_async(port)

Get pin mode in specific port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
pinsint

How many pins in specific port.

pin_modelist of 8 string
  • [pin0, pin1,……pin7]

  • pinmode : Disabled, Idle, DI, DO, UART, I2C, SPI, CAN, PWM and ADC.

Sys_getPythonVersion(timeout=3)

Get python software version.

Parameters:
timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
versionstring
async Sys_getPythonVersion_async()

Get python software version with async mode.

Returns:
versionstring
Sys_getRTC(timeout=3)

Get RTC date and time.

Parameters:
timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
str_str
Date and time represented by “A-B-C, D:E:F”.
  • “A” is year.

  • “B” is month.

  • “C” is day.

  • “D” is hour.

  • “E” is minute.

  • “F” is second.

async Sys_getRTC_async()

Get RTC date and time with async mode.

Returns:
str_str
Date and time represented by “A-B-C, D:E:F”.
  • “A” is year.

  • “B” is month.

  • “C” is day.

  • “D” is hour.

  • “E” is minute.

  • “F” is second.

Sys_getSerialNumber(timeout=3)

Get serial number.

Parameters:
timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
str_str

Serial number represented by string of 8 characters.

async Sys_getSerialNumber_async()

Get serial number with async mode.

Returns:
str_str

Serial number represented by string of 8 characters.

Sys_reboot(timeout=3)

Reboot the device.

Parameters:
timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_reboot_async()

Reboot the device with async mode.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setAIOMode(slot, timeout=3)

Set the AIO state on a given slot.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setAIOMode_async(slot)

Set the AIO state on a given slot with async mode.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setDIMode(slot, timeout=3)

Set the DI state on a given slot.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setDIMode_async(slot)

Set the DI state on a given slot with async mode.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setDIOMode(slot, timeout=3)

Set the DIO state for the slot in the connected WPC device.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setDIOMode_async(slot)

Set the DIO state for the slot in the connected WPC device with async mode.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setDOMode(slot, timeout=3)

Set the DO state for the slot in the connected WPC device.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setDOMode_async(slot)

Set the DO state for the slot in the connected WPC device with async mode.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setDeviceAlias(alias, timeout=3)

Set the alias name of the device.

Parameters:
aliasstr

The alias name of the device

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setDeviceAlias_async(alias)

Set the alias name of the device.

Parameters:
aliasstr

The alias name of the device

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setIdleMode(slot, timeout=3)

Set the IDLE state on a given slot.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setIdleMode_async(slot)

Set the IDLE state on a given slot with async mode.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setMotionMode(slot, timeout=3)

Set the motion state on a given slot.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setMotionMode_async(slot)

Set the motion state on a given slot with async mode.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setRTC(year, month, day, hour, minute, second, timeout=3)

Set RTC date and time.

Parameters:
yearint

year (CE).

monthint

month (1~12).

dayint

day (1~31).

hourint

hour (24-hour clock) (0~23).

minuteint

minute (0~59).

secondint

second (0~59).

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setRTC_async(year, month, day, hour, minute, second)

Set RTC date and time with async mode.

Parameters:
yearint

year (CE).

monthint

month (1~12).

dayint

day (1~31).

hourint

hour (24-hour clock) (0~23).

minuteint

minute (0~59).

secondint

second (0~59).

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_setSwitchMode(slot, timeout=3)

Set the switch state on a given slot.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_setSwitchMode_async(slot)

Set the switch state on a given slot with async mode.

Parameters:
slotint

Slot number. See here for available slot of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_startRTCAlarm(mode, day, hour, minute, second, timeout=3)

Start RTC time to alarm AI.

Parameters:
modeint

0: Day value interpreted as calendar day. 1: Day value interpreted as weekday.

dayint

Celendar day (1~31)/ Weekday (1~7).

hourint

hour (24-hour clock) (0~23).

minuteint

minute (0~59).

secondint

second (0~59).

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_startRTCAlarm_async(mode, day, hour, minute, second)

Start RTC time to alarm AI with async mode.

Parameters:
modeint

0: Day value interpreted as calendar day. 1: Day value interpreted as weekday.

dayint

Celendar day (1~31)/ Weekday (1~7).

hourint

hour (24-hour clock) (0~23).

minuteint

minute (0~59).

secondint

second (0~59).

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

Sys_stopRTCAlarm(timeout=3)

Stop alarming.

Parameters:
timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async Sys_stopRTCAlarm_async()

Stop alarming with async mode.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

UART_close(port, timeout=3)

Close UART on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async UART_close_async(port)

Close UART on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

UART_getPinMap()

Get all available UART port numbers & the pins that are associated with them.

Returns:
Pinmapdictionary

Each key is an available port. Its associated value yields the corresponding pins of that port.

Each pin is a tuple constituted of its physical port number & pin number.

For example: {1: [(0, 3), (0, 4)], 2: [(1, 2), (1, 3)]} means that there are two UART ports.

They are numbered as 1 & 2. UART1 has two pins: P0.3 & P0.4. UART2 has two pins: P1.2 & P1.3.

General format: {UART_port: [(port, pin), …, (port, pin)]}.

UART_open(port, timeout=3)

Open UART on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async UART_open_async(port)

Open UART on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

UART_read(port, bytes_to_read, delay=0.005)

Read data via UART.

Parameters:
portint

See here for available ports of different WPC devices.

bytes_to_readint

The number of bytes to receive.

delayfloat

Time in seconds to wait for the indicated amount of data to arrive.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
datalist

The list of received data.

async UART_read_async(port, bytes_to_read, delay=0.005)

Read data via UART with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

bytes_to_readint

The number of bytes to receive.

delayfloat

Time in seconds to wait for the indicated amount of data to arrive.

Returns:
datalist

The list of received data.

UART_reset(port, timeout=3)

Reset UART to the default setting on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async UART_reset_async(port)

Reset UART to the default setting on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

UART_setBaudRate(port, baud_rate, timeout=3)

Set UART baudrate on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

baud_rate: int

In bits per second (baud).

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async UART_setBaudRate_async(port, baud_rate)

Set UART baudrate on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

baud_rate: int

In bits per second (baud).

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

UART_setDataBit(port, mode, timeout=3)

Set UART data size on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: 8-bit data.

  • 1: 9-bit data.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async UART_setDataBit_async(port, mode)

Set UART data size on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: 8-bit data.

  • 1: 9-bit data.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

UART_setNumStopBit(port, mode, timeout=3)

Set UART stop bits on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: 1 bit

  • 1: 0.5 bits

  • 2: 2 bits

  • 3: 1.5 bits

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async UART_setNumStopBit_async(port, mode)

Set UART stop bits on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: 1 bit

  • 1: 0.5 bits

  • 2: 2 bits

  • 3: 1.5 bits

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

UART_setParity(port, mode, timeout=3)

Set UART parity on a given port.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: none.

  • 1: reserved.

  • 2: even parity.

  • 3: odd parity.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async UART_setParity_async(port, mode)

Set UART parity on a given port with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

modeint
  • 0: none.

  • 1: reserved.

  • 2: even parity.

  • 3: odd parity.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

UART_write(port, write_data, timeout=3)

Write data via UART.

Parameters:
portint

See here for available ports of different WPC devices.

write_datastring or list of characters

Data to be transferred.

timeoutint

Specify the time (sec) to wait before reporting a timeout error. The default is 3 s.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

async UART_write_async(port, write_data)

Write data via UART with async mode.

Parameters:
portint

See here for available ports of different WPC devices.

write_datastring or list of characters

Data to be transferred.

Returns:
statusint

Return 0 if executed successfully; return error code otherwise. See here for corresponding error messages.

close()

Close USB device handle.

Parameters:
verbose: bool, default: True

Whether to print out messages or not.

Returns:
None
connect(serial_num='default', verbose=True)

Connect handle to USB device.

Parameters:
serial_numstr

Serial number of the WPC device to connect to.

verbose: bool, default: True

Whether to print out messages or not

Returns:
None
disconnect(verbose=True)

Disconnect handle from USB device.

Parameters:
verbose: bool, default: True

Whether to print out messages or not.

Returns:
None