eth32_input_byte

int eth32_input_byte(eth32 handle, int port, int *value);

Summary

This function retrieves the current input value of a specified port on the device. When a port is configured as an input port (using the eth32_set_direction function), the input value represents the voltage levels on the port's pins. For each bit, a low voltage (close to 0V) yields a 0-bit in the input value and a high voltage (close to 5V) yields a 1-bit.

Parameters

  • handle - The value returned by the eth32_open function.

  • port - Specifies the port number (0-5) to read.

  • value - Pointer to a variable which will receive the current input value of the specified port.

Return Value

This function returns zero on success and a negative error code on failure. Please see the Error Codes section for possible error codes.

Example
eth32 handle;
int result;
int value;

// .... Your code that establishes a connection here

// Read the input value of port 2
result = eth32_input_byte(handle, 2, &value);
if(result)
{
	// Handle error
}

// See whether any of bits 0-3 are high (1)
if( (value & 0x0F) )
{
	// At least one of bits 0-3 are high
}
else
{
	// None of bits 0-3 are high
}
         
See Also

eth32_input_bit, eth32_output_byte, eth32_set_direction