#include <stdio.h>
typedef int BOOL;
#include "PiUsb.h"

int main(int argc, char **argv)
{
	int serial_number = argc > 1 ? atoi(argv[0]) : 105;

	int result, position, velocity;
	void *handle = piConnectMotor(&result, serial_number);

	if (!handle) {
		fprintf(stderr, "Could not connect to motor: error code %d\n", result);
		return 1;
	}

	position = piGetMotorVelocity(&velocity, handle);
	piGetMotorHomeStatus(&result, handle);
	fprintf(stderr, "position: %d (velocity), is %sat home\n", position, handle, result ? "" : "not ");

	piDisconnectMotor(handle);

	return 0;
}
