MSR API: Difference between revisions
No edit summary |
No edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
The calling sequence is [[#open|open]]>[[#register_notifier |register_notifier ]]>[[#get_track_error|get_track_error]]>[[#get_track_data_length|get_track_data_length]]>[[#get_track_data|get_track_data]]>[[#close|close ]] | The calling sequence is [[#open|open]]>[[#register_notifier |register_notifier ]]>[[#get_track_error|get_track_error]]>[[#get_track_data_length|get_track_data_length]]>[[#get_track_data|get_track_data]]>[[#close|close ]] | ||
=== <big>open</big> === | === <big>open</big> === | ||
int msr_open() | <syntaxhighlight lang="c">int msr_open()</syntaxhighlight > | ||
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. | 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. | This operation should be used before other operations in this chapter. | ||
Line 14: | Line 14: | ||
=== <big>close</big> === | === <big>close</big> === | ||
int msr_close () | <syntaxhighlight lang="c">int msr_close ()</syntaxhighlight > | ||
Close the opened MSR reader device. If you want to call other APIs, you should open the device again. | 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. | Open and close are pair operations. If you don’t want to use the device, you should call close to release the device. | ||
Line 26: | Line 26: | ||
=== <big>register_notifier</big> === | === <big>register_notifier</big> === | ||
int msr_register_notifier(MSR_NOTIFIER pNotifier, void* pUserData) | <syntaxhighlight lang="c">int msr_register_notifier(MSR_NOTIFIER pNotifier, void* pUserData)</syntaxhighlight > | ||
Register a notifier. As soon as data is ready, this notifier will be called. | 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. | This operation can be called if you want to monitor the swing card information after opening the device. | ||
Line 37: | Line 37: | ||
| pUserData || '''void*:''' User data. | | pUserData || '''void*:''' User data. | ||
|} | |} | ||
typedef void (*MSR_NOTIFIER)(void* pUserData) | Define it as follows: | ||
<syntaxhighlight lang="c">typedef void (*MSR_NOTIFIER)(void* pUserData)</syntaxhighlight > | |||
{| | {| | ||
|- | |- | ||
Line 51: | Line 52: | ||
=== <big>unregister_notifier</big>=== | === <big>unregister_notifier</big>=== | ||
int msr_unregister_notifier() | <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 63: | Line 64: | ||
=== <big>get_track_error</big>=== | === <big>get_track_error</big>=== | ||
int msr_get_track_error(int nTrackIndex) | <syntaxhighlight lang="c">int msr_get_track_error(int nTrackIndex)</syntaxhighlight > | ||
Get error information from the selected track. | Get error information from the selected track. | ||
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 83: | 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>=== | ||
int msr_get_track_data_length(int nTrackIndex) | <syntaxhighlight lang="c">int msr_get_track_data_length(int nTrackIndex)</syntaxhighlight > | ||
Get the length information from the selected track. | 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. | You can allocate the memory space for the information in the selected track which is used in the following api. | ||
Line 105: | 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>=== | ||
int msr_get_track_data (int nTrackIndex, unsigned char* pTrackData, int nLength) | <syntaxhighlight lang="c">int msr_get_track_data (int nTrackIndex, unsigned char* pTrackData, int nLength)</syntaxhighlight > | ||
Get the data information from the selected track. | Get the data information from the selected track. | ||
{|class="wizarpostable" | {|class="wizarpostable" |
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. |