MSR API: Difference between revisions

From wizarPOS
No edit summary
No edit summary
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)
<syntaxhighlight lang="c">typedef void (*MSR_NOTIFIER)(void* pUserData)</syntaxhighlight >
{|
{|
|-
|-
Line 51: Line 51:


=== <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 api to unregister the notifier.
If you have register a notifier and you don’t want to monitor swing, you can call this api to unregister the notifier.
Line 63: Line 63:


=== <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.
Line 88: Line 88:


=== <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 110: Line 110:


=== <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"

Revision as of 09:19, 2 May 2018

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.
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 apis can be called.

Parameters
nTrackIndex int: Track index
Returns
int 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
int The result code, >= 0, success; <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.