GPIO Configurations Tutorial

RFID SDK for Android 2.0.2.124

Applicable Devices : Fixed Readers

Overview

This Tutorial provides a walk-through of the steps to perform GPIO configuration using RFID3 API

Create The Project

  • Start by creating a new project in Android Studio. For help, see the Android Studio tutorial.
  • Refer Hello RFID to prepare basic setup to work with RFID Reader and then follow this guide

Details

The set of functions are available for controlling the GPIO ports of the Reader. The number of GPIs and GPOs supported by the reader can be queried from the reader capabilities. In general sensors will be connected to input ports and indicator or lights will be connected to output ports.

Setting it up

Declarations and API calls to setup configuration

  • GPI (General Purpose Input) Port
  • The function getPortState gets the current GPI port state of the reader. The specified port can be accessed by passing the index. The function isPortEnabled can be used to get the current configuration and state of the specified port number. The specified port can be accessed by passing the index. The function enablePort enables the specified port number. It is possible to register for GPI Port state change notification. Before registering, the interested port must be enabled


// Get numer of GPI ports supported by Reader              

int numGPIPorts = reader.ReaderCapabilities.getNumGPIPorts();

// Enable GPI port 1              

reader.Config.GPI.enablePort(1, true);

// To Query the GPI Port 1

boolean portEnabled = reader.Config.GPI.isPortEnabled(1);

// To get the GPI Port State

GPI_PORT_STATE gpiPortState = reader.Config.GPI.getPortState(1);
  • GPO (General Purpose Output) Port
  • The function getPortState gets the current ouput port state of the reader. The specified port can be accessed by passing the index.


// Get numer of GPO ports supported by Reader              

int numGPOPorts = reader.ReaderCapabilities.getNumGPOPorts();

// Set GPO port 1              

reader.Config.GPO.setPortState(1, GPO_PORT_STATE.TRUE);

// To get the port state

GPO_PORT_STATE gpoPortState = reader.Config.GPO.getPortState(1);

Closer look

  • Get the port state using reader.Config.GPI.getPortState(1)
  • reader.Config.GPO.getPortState(1)

What's Next

  • Change setPortState values to change state of GPO ports