| Top |
| mccr_device_t ** | mccr_enumerate_devices () |
| mccr_device_t * | mccr_device_new () |
| mccr_device_t * | mccr_device_ref () |
| void | mccr_device_unref () |
| const char * | mccr_device_get_path () |
| uint16_t | mccr_device_get_vid () |
| uint16_t | mccr_device_get_pid () |
| const wchar_t * | mccr_device_get_serial_number () |
| const wchar_t * | mccr_device_get_manufacturer () |
| const wchar_t * | mccr_device_get_product () |
| mccr_status_t | mccr_device_open () |
| bool | mccr_device_is_open () |
| void | mccr_device_close () |
| mccr_status_t | mccr_device_reset () |
This section defines the MCCR device type as well as methods to create and use them.
Example 2. Opening and closing the device
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
mccr_status_t st; mccr_device_t *device; device = mccr_device_new (NULL); if (!device) { fprintf (stderr, "error: couldn't find a MagTek credit card reader\n"); return EXIT_FAILURE; } if ((st = mccr_device_open (device)) != MCCR_STATUS_OK) { fprintf (stderr, "error: couldn't open MagTek credit card reader: %s\n", mccr_status_to_string (st)); return EXIT_FAILURE; } // Use the device here mccr_device_close (device); mccr_device_unref (device); |
mccr_device_t **
mccr_enumerate_devices (void);
Enumerates all available MagTek credit card reader devices.
a newly allocated NULL-terminated array of mccr_device_t
instances or NULL if no devices found. When no longer needed,
mccr_device_unref() should be called on each mccr_device_t in the
array, and free() for the array itself.
mccr_device_t *
mccr_device_new (const char *path);
Creates a mccr_device_t from the given path.
There is no predefined format for the path, the user should use a path
previously returned by mccr_enumerate_devices().
If a NULL path
is given, the mccr_device_t is created from the first
device found.
mccr_device_t *
mccr_device_ref (mccr_device_t *device);
Increases the reference count on the mccr_device_t.
void
mccr_device_unref (mccr_device_t *device);
Decreases the reference count on the mccr_device_t. When the count reaches zero, the instance is disposed.
const char *
mccr_device_get_path (mccr_device_t *device);
Get USB path of the device.
This method doesn't require the device to be open previously with
mccr_device_open().
uint16_t
mccr_device_get_vid (mccr_device_t *device);
Get the USB vendor ID.
This method doesn't require the device to be open previously with
mccr_device_open().
uint16_t
mccr_device_get_pid (mccr_device_t *device);
Get the USB product ID.
This method doesn't require the device to be open previously with
mccr_device_open().
const wchar_t *
mccr_device_get_serial_number (mccr_device_t *device);
Get the serial number of the device.
This method doesn't require the device to be open previously with
mccr_device_open().
const wchar_t *
mccr_device_get_manufacturer (mccr_device_t *device);
Get the manufacturer string of the device.
This method doesn't require the device to be open previously with
mccr_device_open().
const wchar_t *
mccr_device_get_product (mccr_device_t *device);
Get the product string of the device.
This method doesn't require the device to be open previously with
mccr_device_open().
bool
mccr_device_is_open (mccr_device_t *device);
Checks whether the mccr_device_t is open.
mccr_status_t
mccr_device_reset (mccr_device_t *device);
Request a power cycle of the mccr_device_t.