MSR API: Difference between revisions
No edit summary |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 37: | Line 37: | ||
| pUserData || '''void*:''' User data. | | pUserData || '''void*:''' User data. | ||
|} | |} | ||
Define it as follows: | |||
<syntaxhighlight lang="c">typedef void (*MSR_NOTIFIER)(void* pUserData)</syntaxhighlight > | <syntaxhighlight lang="c">typedef void (*MSR_NOTIFIER)(void* pUserData)</syntaxhighlight > | ||
{| | {| | ||
Line 48: | Line 49: | ||
| int || The result code, >= 0, success; <0 [[Error_code|error code]]. | | int || The result code, >= 0, success; <0 [[Error_code|error code]]. | ||
|} | |} | ||
=== <big>unregister_notifier</big>=== | === <big>unregister_notifier</big>=== | ||
<syntaxhighlight lang="c">int msr_unregister_notifier()</syntaxhighlight > | <syntaxhighlight lang="c">int msr_unregister_notifier()</syntaxhighlight > | ||
Unregister a notifier. | Unregister a notifier. | ||
If you have register a notifier and you don’t want to monitor swing, you can call this | If you have register a notifier and you don’t want to monitor swing, you can call this API to unregister the notifier. | ||
{|class="wizarpostable" | {|class="wizarpostable" | ||
|- | |- | ||
Line 66: | Line 68: | ||
The track index should be 0, 1, 2. | 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 | 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 API can be called. | ||
{|class="wizarpostable" | {|class="wizarpostable" | ||
|- | |- | ||
Line 82: | Line 84: | ||
! scope="row" colspan="2"| Returns | ! scope="row" colspan="2"| Returns | ||
|- | |- | ||
| int || The result code, >= 0, success; <0 [[Error_code|error code]]. | | int || The result code, >= 0, success, no error; <0 [[Error_code|error code]]. | ||
|} | |} | ||
=== <big>get_track_data_length</big>=== | === <big>get_track_data_length</big>=== | ||
Line 104: | Line 106: | ||
! scope="row" colspan="2"| Returns | ! scope="row" colspan="2"| Returns | ||
|- | |- | ||
| int || The result code, >= 0, success; <0 [[Error_code|error code]]. | | int || The result code, >= 0, success, the data length of track data; <0 [[Error_code|error code]]. | ||
|} | |} | ||
=== <big>get_track_data</big>=== | === <big>get_track_data</big>=== |
Latest revision as of 09:36, 11 March 2019
API Overview
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.
Returns | |
---|---|
int | 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.
Returns | |
---|---|
int | 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. |
Define it as follows:
typedef void (*MSR_NOTIFIER)(void* pUserData)
Returns | |
---|---|
int | 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.
Returns | |
---|---|
int | 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 API can be called.
Parameters | |
---|---|
nTrackIndex | int: Track index |
Returns | |
---|---|
int | The result code, >= 0, success, no error; <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 | |
---|---|
int | The result code, >= 0, success, the data 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 | |
---|---|
int | The result code, >= 0, success; <0 error code. |