// TAMS USB Switch Controller Example
// Readback the position of a switch


// The Agilent 1810, 1811, 1812, and 87222 switches, for example, all support
// readback of the switch position.


#include <stdio.h>

#include "tamsSC.h"

main ()

{
	tHANDLE	handle;
	int	position;

	if (INVALID_HANDLE_VALUE == (handle = tamsSCstart (""))) {
		fprintf (stderr, tamsSCerror ());
		exit (1);
	}

	// Read back the position of switch 4

	tamsSCreadbackSwitch (handle, SWITCH_4, &position);

	// position is now POSITION_A or POSITION_B, also known as POSITION_1 or POSITION_2.

	// Optionally, with error checking.

	if (FAIL == tamsSCreadbackSwitch (handle, SWITCH_4, &position))
		fprintf (stderr, tamsSCerror ());
}