Typical operation, Open a device, Query the device’s capabilities – MagTek 99875125 User Manual
Page 13: Prepare the device for work, Use the device
Section 1. Overview
TYPICAL OPERATION
This section describes a typical pattern that an application developer may use to operate a device.
Although it is the most typical pattern, it is by no means the only viable one. Refer to Section 5,
Example Applications, to see how to use the drivers in various applications.
Open a device
Access to the device is obtained by opening the comxx: port that the device was installed as.
This is not the hardware port that the device may be attached to, but a virtual comxx: port
presented by the driver (e.g., COM5 or higher). A handle is returned by the open function and is
required for all subsequent interactions with the driver. When opened, the driver initializes itself
and, where required, the device.
Some drivers support automatic settings. In this mode, the driver first attempts to communicate
with the device at the previous setting or at the default setting if it is the first time. (The setting
for the initial attempt is grayed out in the manual settings fields.) If the driver for certain devices
(e.g., Mini MICR) does not receive a response, it will adjust the settings and try again. This
sequence continues until the device responds or until all possible settings have been attempted.
If the driver is set for the automatic mode, it may take considerably longer for the device driver
to detect an error. In particular, if the device is not connected to the specified port or if its power
is off, the device driver may take several seconds attempting all possible settings before it returns
an error. The application program should be tolerant of this delay. Not all of the devices support
the automatic mode of detection.
Query the device’s capabilities
The application can query the device to determine if it can perform the required task. The
capability properties (
c_xxx
) are provided for this purpose. For example, if an application
requires the ability to read checks, it can
get
the
c_check
property to determine if the device
can read checks (e.g., /get c_check).
Prepare the device for work
The device is prepared for operation by setting one or more of the configuration properties. Its
mode of operation and other features are set up by these properties. Setting the
capitalize
property to
1
to cause all data written to or read from a card’s magnetic strip to be capitalized is
an example of this type of initialization. In some cases, modifying a property may cause the
driver to execute functions on the device.
Use the device
The device is now fully initialized ready for operation. Because most tasks with the device
require interaction with the user, the application operates the device using primarily the
interactive commands. A typical scenario is when, in response to some event, the user is
5