You are here

transaction.exe

This program sends synchronous commands to USB-IO Interface Adapter and prints the responses received from the GPIO-24 device. The command to send should be provided as 8 hexadecimal numbers separated by space. For example to configure C.0 pin for pulse width modulation (PWM) you can run:

            transaction.exe 01 00 2 01 00 00 00 02
        

Use command.exe application to send asynchronous commands.

You can launch transaction.exe application from scripting languages (like Perl, ASP, bash, etc.).

Application can also be used as good SW example of interfacing USB-IO adapter from C++ language:

#include <stdio.h>
#include "../common/gpio_24.h"
#pragma comment (lib, "../bin/gpio_24.lib")

#include <string>

int main(int argc, char* argv[])
{
	if (argc != GPIO_COMMAND_LENGTH + 1)
	{
		printf("8-byte command has to be provided\r\n");
		return -1;
	}
	GPIO_COMMAND cmd;
	for (int i = 0; i < GPIO_COMMAND_LENGTH; i++)
	{
		char* end;
		errno  = 0;
		unsigned long value = strtoul(argv[i+1], &end, 16);
		if ((*end) || (errno != 0) || (value > 0xFF))
		{
			printf("Invalid parameter: \"%s\"\r\n", argv[i+1]);
			return -1;
		}
		cmd.command[i] = (unsigned char) value;
	}

	GPIO_NOTIFICATION notification;
	GPIO_RESULT pc;
	GPIO_EVENT response;
	HGPIO device;


	notification.type = ntNoNotification;
	if (GPIO_FAILED((pc = GPIO_Init(notification))))
	{
		printf("Failed to initialize library, Error = %d\r\n", pc);
		return pc;
	}
	if (GPIO_FAILED((pc = GPIO_OpenDevice(0, &device))))
	{
		printf("Failed to open device, Error = %d\r\n", pc);
		GPIO_Uninit();
		return pc;
	}
	if (GPIO_FAILED((pc = GPIO_Transaction(device, cmd, &response))))
	{
		printf("Failed to send transaction, Error = %d\r\n", pc);
		GPIO_CloseDevice(device);
		GPIO_Uninit();
		return pc;
	}

	printf("response – %02X %02X %02X %02X %02X %02X %02X %02X\r\n",
		response.event[0], response.event[1], response.event[2],
		response.event[3], response.event[4], response.event[5], 
		response.event[6], response.event[7]);

	GPIO_CloseDevice(device);
	GPIO_Uninit();
	return pc;
}