MSR API: Difference between revisions
No edit summary |
No edit summary |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== | == API Overview== | ||
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 ]] | ||
=== open === | === <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. | ||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
| int || The result code, >= 0, success; <0 [[Error_code|error code]]. | |||
|} | |||
=== <big>close</big> === | |||
<syntaxhighlight lang="c">int msr_close ()</syntaxhighlight > | |||
=== close === | |||
int msr_close () | |||
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. | ||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
| int || The result code, >= 0, success; <0 [[Error_code|error code]]. | |||
|} | |||
=== <big>register_notifier</big> === | |||
<syntaxhighlight lang="c">int msr_register_notifier(MSR_NOTIFIER pNotifier, void* pUserData)</syntaxhighlight > | |||
=== 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. | 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. | ||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2" | Parameters | |||
|- | |||
| pNotifier || '''MSR_NOTIFIER:''' Notifier of MSR card reader. | |||
|- | |||
| pUserData || '''void*:''' User data. | |||
|} | |||
Define it as follows: | |||
<syntaxhighlight lang="c">typedef void (*MSR_NOTIFIER)(void* pUserData)</syntaxhighlight > | |||
{| | |||
|- | |||
| | |||
|} | |||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
| int || The result code, >= 0, success; <0 [[Error_code|error code]]. | |||
|} | |||
=== <big>unregister_notifier</big>=== | |||
{| | <syntaxhighlight lang="c">int msr_unregister_notifier()</syntaxhighlight > | ||
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. | |||
{|class="wizarpostable" | |||
|- | |- | ||
| | ! scope="row" colspan="2"| Returns | ||
|- | |- | ||
| | | int || The result code, >= 0, success; <0 [[Error_code|error code]]. | ||
|} | |} | ||
=== <big>get_track_error</big>=== | |||
<syntaxhighlight lang="c">int msr_get_track_error(int nTrackIndex)</syntaxhighlight > | |||
=== get_track_error=== | |||
int msr_get_track_error(int nTrackIndex) | |||
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" | |||
|- | |||
! scope="row" colspan="2" | Parameters | |||
|- | |||
| nTrackIndex || '''int:''' Track index | |||
|} | |||
{| | |||
|- | |||
| | |||
|} | |||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |- | ||
| | | int || The result code, >= 0, success, no error; <0 [[Error_code|error code]]. | ||
|} | |} | ||
=== <big>get_track_data_length</big>=== | |||
=== get_track_data_length=== | <syntaxhighlight lang="c">int msr_get_track_data_length(int nTrackIndex)</syntaxhighlight > | ||
int msr_get_track_data_length(int nTrackIndex) | |||
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. | ||
{|class="wizarpostable" | |||
''' | |- | ||
! scope="row" colspan="2" | Parameters | |||
|- | |||
| nTrackIndex || '''int:''' Track index | |||
|} | |||
{| | {| | ||
|- | |- | ||
| | | | ||
|} | |||
{|class="wizarpostable" | |||
|- | |||
! scope="row" colspan="2"| Returns | |||
|- | |||
| int || The result code, >= 0, success, the data length of track data; <0 [[Error_code|error code]]. | |||
|} | |} | ||
=== <big>get_track_data</big>=== | |||
=== get_track_data=== | <syntaxhighlight lang="c">int msr_get_track_data (int nTrackIndex, unsigned char* pTrackData, int nLength)</syntaxhighlight > | ||
int msr_get_track_data (int nTrackIndex, unsigned char* pTrackData, int nLength) | |||
Get the data information from the selected track. | Get the data information from the selected track. | ||
{|class="wizarpostable" | |||
|- | |||
''' | ! scope="row" colspan="2" | Parameters | ||
|- | |||
| nTrackIndex || '''int:''' Track index | |||
|- | |||
| pTrackData || '''unsigned char*:''' Data buffer | |||
|- | |||
| nLength || '''int:''' Length of data buffer | |||
|} | |||
{| | {| | ||
|- | |- | ||
| | | | ||
|} | |||
{|class="wizarpostable" | |||
|- | |- | ||
| | ! scope="row" colspan="2"| Returns | ||
|- | |- | ||
| | | int || The result code, >= 0, success; <0 [[Error_code|error code]]. | ||
|} | |} | ||
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. |