MSR API
Functions
The calling sequence is open>register_notifier >get_track_error>get_track_data_length>get_track_data>close
open
int msr_open()
Open the MSR reader device. If success, the device object establishes a connection with the MSR so that it can carry out the following operations. This operation should be used before other operations in this chapter.
Parameters
Returns
The result code, >= 0, success; <0 error code.
close
int msr_close ()
Close the opened MSR reader device. If you want to call other APIs, you should open the device again. Open and close are pair operations. If you don’t want to use the device, you should call close to release the device.
Parameters
Returns
The result code, >= 0, success; <0 error code.
register_notifier
int msr_register_notifier(MSR_NOTIFIER pNotifier, void* pUserData)
Register a notifier. As soon as data is ready, this notifier will be called. This operation can be called if you want to monitor the swing card information after opening the device.
Parameters
pNotifier | MSR_NOTIFIER | Notifier of MSR card reader. |
pUserData | void* | User data. |
typedef void (*MSR_NOTIFIER)(void* pUserData)
Returns
The result code, >= 0, success; <0 error code.
unregister_notifier
int msr_unregister_notifier()
Unregister a notifier. If you have register a notifier and you don’t want to monitor swing, you can call this api to unregister the notifier.
Parameters
Returns
The result code, >= 0, success; <0 error code.
get_track_error
int msr_get_track_error(int nTrackIndex)
Get error information from the selected track. The track index should be 0, 1, 2.
After the notifier found a card, if you want to get information from the selected track of the card, you should firstly call this api. If the result value is more than 0, the following apis can be called.
Parameters
nTrackIndex | int | Track index |
Returns
The result code, >= 0, success; <0 error code.
get_track_data_length
int msr_get_track_data_length(int nTrackIndex)
Get the length information from the selected track. You can allocate the memory space for the information in the selected track which is used in the following api.
Parameters
nTrackIndex | int | Track index |
Returns
The result code, >= 0, length of track data; <0 error code.
get_track_data
int msr_get_track_data (int nTrackIndex, unsigned char* pTrackData, int nLength)
Get the data information from the selected track.
Parameters
nTrackIndex | int | Track index |
pTrackData | unsigned char* | Data buffer |
nLength | int | Length of data buffer |
Returns
The result code, >= 0, length of track data; <0 error code.