va_io_device.hπŸ”—

#include <va_io_device.h>

Defines

VA_IO_MAX_CHANNELSπŸ”—

The maximum number of I/O channels.

Enums

enum va_io_channel_typeπŸ”—

Values:

enumerator va_io_channel_inputπŸ”—
enumerator va_io_channel_outputπŸ”—

Functions

const char *va_io_device_name(void)πŸ”—

Returns a human-readable name for the I/O device this server controls.

int va_io_device_init(void)πŸ”—

Initializes the I/O device.

This function will be called once when the server starts, before any of the functions that access the device.

Return

0 on success, -1 on failure. On error sets the error message to be retrieved with va_io_last_error().

const char *va_io_last_error(void)πŸ”—

Returns the last error message.

The returned memory address may point to a static storage that is overwritten on each error.

unsigned int va_io_channel_count(void)πŸ”—

Returns the total number of I/O channels.

void va_io_fill_config(unsigned int channel, struct va_io_channel_config *config)πŸ”—

Fills in the configuration for channel.

It is guaranteed by the caller that channel is smaller than va_io_device_channel_count(). The function must set all members of the config structure.

Parameters
  • channel: Index of channel.

  • value: A pointer to a channel config structure to fill.

int va_io_read_input(unsigned int channel, unsigned int *value)πŸ”—

Reads the value of an input channel and stores it to value.

It is guaranteed by the caller that channel is an input channel. Note that both the I/O protocol and the server implementation always treat β€œ1” as the active state of a binary input regardless of the input’s electrical polarity.

Return

0 on success. On I/O error returns -1 and sets the error message to be retrieved with va_io_last_error().

Parameters
  • channel: Index of channel.

  • value: A pointer to a memory location to store the value into.

int va_io_write_output(unsigned int channel, unsigned int value)πŸ”—

Sets the state of a digital output channel.

It is guaranteed by the caller that channel is an output channel and that value is at most the maximum allowed value for that channel. Note that β€œ1” is always considered as the active state of the output regardless of its electrical polarity.

Return

0 on success, -1 on failure. On error sets the error message to be retrieved with va_io_last_error().

Parameters
  • channel: Index of channel.

  • value: The new value of the channel.