GPIO

General Purpose Input Output (GPIO)

Device Compatibility

Overview

The GPIO driver supports:<a

  • Pin input
  • Pin output
  • Updates for the current state of all GPIO pins

Device Pinouts:

Available ZeroMQ Ports

  • Base port: 20049
  • Keep-alive port: 20050
  • Error port: 20051
  • Data Update port: 20052

Protocol

Base Port This port accepts 3 configuration for communicating with the GPIO driver.

  • delay_between_updates - controls the output speed of messages from the Data Update port.

  • timeout_after_last_ping - stops sending messages from the Data Update port if nothing has been sent to the Keep-alive port after the specified amount of seconds.

  • gpio - the gpio configuration that's created from a GpioParams message.

message DriverConfig {
  // Delay between updates in seconds
  float delay_between_updates = 1;
  // Timeout after last ping
  float timeout_after_last_ping = 2;
  // Gpio service configuration
  matrix_io.malos.v1.io.GpioParams gpio = 8;
}

View the defined message here.

GpioParams

  • pin - Selects the pin you want to use on your MATRIX device.

  • EnumMode - Determines input or output mode for GPIO pins.

  • value - Set as 1 or 0 to signify on/off.

    Each pin will save its last set value until the next device boot.

// GPIO handler params
message GpioParams {
  // GPIO to config
  uint32 pin = 1;

  // GPIO mode input/output
  enum EnumMode {
    INPUT = 0;
    OUTPUT = 1;
  }
  EnumMode mode = 2;

  // GPIO value
  uint32 value = 3;
}

View the defined message here.

Keep-alive Port This driver needs keep-alive messages in order to send data to your application. It's recommended to send an empty string "" because the contents of a keep-alive message are never read.

Error Port Applications can subscribe to this port to receive driver related errors.

Data Update Port Applications can subscribe to this port for GPIO data. The output will be a serialized message of type GpioParams with the following information.

// GPIO handler params
message GpioParams {
  // Integer to represent all pin values (Convert to 16bit for readability)
  uint32 values = 4;
}

View the defined message here.