📄 mc900.h
字号:
/***********************************************************************
MC900.H: MAGCARD (R) MC-900 Support Library (TM) Header File
Copyright (C) 1995-96 MAGCARD International. All Rights Reserved.
***********************************************************************/
#ifndef _MC900_H_
#define _MC900_H_
/* General status code */
#define OK 0
#define myERROR -1
/* Reader status */
#define ERR_TYPE 0x10 /* Card type unrecognized */
#define NO_CARD 0x08 /* No card in the reader */
#define ERR_WRITE 0x04 /* Error in writing the card */
#define ERR_READ 0x02 /* Error in reading the card */
#define ERR_EVEN 0x01 /* Error in parity check */
/* COM port RECEIVING status */
#define OVER_RIDE 0x80 /* Over-ride happened */
#define PARITY_ERR 0x40 /* Error in parity check */
#define OVER_TIME 0x20 /* Having waited too long */
#define NO_READER 0x20 /* No reader connected */
/* Card type definition */
enum CardType {
CPUCard=2,
GPM256=3, /*GPM 256, F256 */
GPM416=4, /*GPM416,SLE 4404,GPM 896 */
GFM2K=6, /*GFM4K, GFM8K and I2C compatible cards */
GPM103=7, /*GPM 103,SLE4406*/
SLE4432=8, /*SLE 4432,SLE 4442*/
SLE4442=8,
SLE4418=9, /*SLE 4418,SLE 4428*/
SLE4428=9,
SLE4428B=10,
AT1604=0x0E, /*ATMEL 1604*/
AT2464=0x6 /*ATMEL 2464*/
};
/*MC900 status definition */
enum MC900Status {
COUPLER_OK=0,
/*Coupler is OK. No error occurs*/
COUPLER_COMMAND_UNKNOWN=0x4,
/*Coupler command unknown. The first byte of the
request is not a valid commmand code. */
COMMU_PROTOCOL_ERROR=0x9,
/*communication protocol error. The header of a
message is neither ACK nor NACK(60h or E0h). */
RESPONSE_ERROR_RESET=0x10,
/*Response error at the card reset. The first byte
of the response (TS) is not valid. */
COMMAND_ISO_HEADER_ERROR=0x11,
/*Command ISO header error. The byte INS in the ISO header
is not valid(6x or 9x). */
MESSAGE_TOO_LONG=0x12,
/*Message too long. The coupler buffer is limited in standard to 198
bytes of which 129 bytes are for the data exchanged with the card. */
BYTE_READ_ERROR_ASYN=0x13,
/*Byte reading error coming from an asynchronous card. */
CARD_TYPE_UNKOWN=0x14,
/*Card type unknown. The parameter T in a command "definition of
card type" is not valid. */
CARD_TURNED_OFF=0x15,
/*Card turned off. A command "Power on" must be applied to the
card prior to any other operation. */
PROGRAM_VOL_NOTAVAIL=0x16,
/*Programming voltage not available. The parameter V in a command
"definition of card type" is not valid. */
COMMU_PRO_UNKOWN=0x17,
/*Communication protocol unknown or incorrectly initialized. */
COMMU_PRO_INIT_WRONG=0x18,
/*Communication protocol unknown or incorrectly initialized. */
ILLEGAL_ACCESS_EXT_BUS=0x19,
/*Illegal access to external bus. This error only applies to those
versions of couplers without an external memory. */
ISO_COMMAND_ERR=0x1A,
/*Error in an ISO-formatted card command. The parameter LN in the
ISO header does not correspond to the actual length of the data. */
ROS_COMMAND_ARGU_ERR=0x1B,
/*Sending of a command to the ROS with an incorrect number of
arguments. */
UNKNOWN_SUBFUNCTION=0x1C,
/*Unknown subfunction. This error only occurs when the command
"Configuration" is called with an invalid SOP parameter. */
ERROR_TCK=0x1D,
/*The check byte TCK of the reset response of ans asynchronous card
is erroreous. */
WRITE_EXT_MEM_FORBIDDEN=0x1E,
/*Writing in external memory is forbidden: write protected (the error
occurs when,for example,one tries to download code in EPROM).*/
WRITE_EXT_MEM_ERROR=0x1F,
/*Incorrect writing in external memory (signalled at the time of write
check during a downloading operation.) */
COUPLER_NO_SWITCH=0x20,
/*The coupler does not include any mircroswtich. */
ERROR_IN_RESET=0xA0,
/*Error in the card reset response(unknown exchange protocol,byte
TA1 not recognized, etc...) The card is not supported by the coupler.
The card reset response is nervertheless returned. */
DEAD_CARD=0xA2,
/*Dead card. The card does not respond to the reset or has interrupted
an exchange(by "timeout"). */
PARRITY_ERROR=0xA3,
/*Parity error(in the course of an exchange asynchronous card<->coupler).
The error only occurs after several unsuccessful attempts at
retransmission. */
INVALID_PROCEDURE_BYTE=0xE4,
/*The card has just set to the coupler an invalid "Procedure Byte"
(see norm ISO 7816-3). */
EXCHANGE_INTERRUPTED=0xE5,
/*The card has interrupted an exchange with the coupler(the card
sends an SW1 byte whereas the coupler has more data to send or
receive). */
CARD_ERROR=0xE7,
/*Error returned by the card. The bytes SW1 and SW2 returned by the
card are different from 90h 00. */
CARD_REMOVED=0xF7,
/*Card removed. The card has been withdrawn in the course of the
carrying out of an instruction. Check that the card instruction is
not partially carried out(a possibility which depends upon the card
type an the operation). */
CARD_ABSEND=0xFB
/*Card absent. There is no card in the commnector. The card may have
been removed when powered on, but no instruction has been interrupted.*/
};
/*communication status*/
/*
enum MC900_ReplyStatus
{
SEND_RECEIVE_OK=0, // Send & Receive process is complemented
SEND_OVER_TIME, // Send buffer is not empty after a period of time.
// This is often happens when the handshake is
// not satisfied or the transmit interrupt is closed.
RETRY_OVER_TIME, // Retry over times
RECEIVE_OVER_TIME, // not enough charactors received in a period of time
CHANNEL_NOT_DEFINED,// specified channel not defined
MACHINE_NOT_READY // machine not ready
};
*/
/*
Function: Get MC-900 support library version number.
Syntax: const char *GetVer()
Returns: MC-900 support library version number.
*/
#ifdef __cplusplus
extern "C" {
#endif
const char * WINAPI GetVer();
/*
Function: Activates serial communication port.
Syntax: int OpenCom(port,unsigned long baud)
int port; // port selected (1 through 4)
unsigned long baud; //baud rate
Remarks: OpenCom allocates communication support classes and turns
up handshaking signals. This sets up transmitter/receiver
interrupts and MUST BE CALLED before PowerOn or any IC functions
on the selected port.
Returns: OK: Success.
ERROR: Failed.
*/
int FAR PASCAL OpenCom(int port,unsigned long baud);
/*
Function: Deactivates serial communication port.
Syntax: int CloseCom(port)
int port; // port selected (1 through 4)
Remarks: CloseCom shuts down handshaking signals and deallocates
communication support classes. This resets serial controller
into query mode and MUST BE CALLED after IC functions completed on
the selected port. Each OpenCom should has AT LEAST ONE matching
CloseCom in the application.
Returns: OK: Success.
ERROR: Failed.
*/
int FAR PASCAL CloseCom(int port);
/*
Function: Get the version of card reader.
Syntax: void GetVersion (int port, unsigned char *data,
unsigned char *me1, unsigned char *me2,int *status, int *line)
port // port selected (1 through 4)
data //version data.
me1,me2 //IC card status.
status //mc900 status.
line //comunication status.
IC card status: For CPU card when no error occurs,
me1,me2=(0x90,0), when error occurs the me1,me2
will be set according to the error. For memory
card, me1,me2=(0x90,0) is always true.
MC900 status: The coupler status. (See enum MC900Status).
communication status: The computer communication status.
(See enum MC900_ReplyStatus).
*/
void FAR PASCAL myGetVersion (int com, unsigned char *data, unsigned char *me1,
unsigned char *me2,int *status, int *line);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -