C API for BALTECH SDK

§ brp_Lg_Select()

brp_errcode brp_Lg_Select ( brp_protocol  protocol,
unsigned  TO,
unsigned  Adr,
unsigned  Len,
unsigned  PollTime,
unsigned  CRCAdr,
unsigned  SafeDat,
unsigned  ChgSeg,
unsigned  ProtHead,
unsigned  CRCCalc,
unsigned  CRCChk,
unsigned  SegID,
brp_buf  Stamp,
size_t  Stamp_len,
brp_Lg_Select_MediaType MediaType,
unsigned *  FuncLevel,
unsigned *  OrgLevel,
brp_Lg_Select_EvStat EvStat,
unsigned *  ActSegID,
unsigned *  ActAdr,
brp_buf Data,
size_t *  Data_len,
brp_mempool mempool 
)

This command selects a specific segment of a LEGIC Prime card and reads some data from it.

This command can both access IM cards (standard LEGIC Prime cards containing user data) and SAM cards (used for security purposes).

If no label can be detected, the Lg.Idle command is implicitly called in order to switch off the HF field. Otherwise, the selected label will stay selected until either a new call of the Lg.Select command is performed, until the Lg.Idle command is called, if the selected MIM gets out of the HF field, or if the Lg.ErrDataCorrupt error occurs.

If several segments are present on the card, only the first segment is directly accessible by the reader. All other segments have to be found by "jumping" from segment to segment. Therefore the time for selecting a certain segment is:

t = 80 ms + SegID * 22 ms

If several segments on the selected card must be accessed, it is recommended to always start with the segment which has the lowest ID.

The protocol header-based addressing mode should always be used. The physical addressing mode is only applicable for unsegmented MIMs and is therefore deprecated.

If the desired data is protected against reading, then the first 5 Bytes of the segment, according to the protocol header addressing, will be returned in the Data variable instead of the requested data. It is recommended to check that the returned value of Data has a length unequal to 5 or to check the value of the returned address in the ActAdr variable to make sure that the requested data has been properly returned.

If an error status code is returned by this command, no card will be selected.

If Lg.ErrBusy is returned, the reader is still busy with reading a SAM card. This occurs when the TO parameter for this command is to small to wait for the end of this operation. In this case, the reader will reject any LEGIC command by returning the Lg.ErrBusy status code until the operation is finished and the stamp is stored in the reader's EEPROM.

To prevent unauthorized writing of stamp data to the reader's EEPROM, it is advisable to use a TO value below 0xA0 in your application software.

Parameters
[in]protocolused to execute the command
[in]TOThe command timeout is calculated by TO * 100 ms TO should be chosen depending on the location of the desired card segment. The default value (0x05) is sufficient for most purposes, but a value > 0xA0 is required to read SAM cards.
[in]AdrStart address of data on card to read. The default value (7) is the address of the card's serial number.
[in]LenLength of data to read, in Bytes. The default value (4) is the length of the card's serial number.
[in]PollTimeThe required poll time is calculated by Time * 20 ms The default value (0x01) is sufficient for most purposes.
[in]CRCAdrAddress of the CRC checksum of the data stored at Adr.
[in]SafeDatIf set, the safe data handling mechanism will be used. This mechanism detects if two cards are in the HF field at the same time and returns an error if this is the case.
[in]ChgSegIf set, a new segment on the already selected card is directly selected without going back to the idle state beforehand. This saves time and ensures that the new segment is located on the already selected card.
[in]ProtHeadIf set, use protocol header for addressing, otherwise use physical addresses. For segmented cards, protocol header is mandatory. The chosen addressing mode impacts all following commands working on the currently selected card.
[in]CRCCalcIf set, use 16 bit CRC checksum, otherwise 8 bit. 16 bit CRC is only available when the ProtHead flag is also set.
[in]CRCChkEnable/disable CRC check.
[in]SegIDID of desired segment (or start segment for segment search).
[in]StampStamp Bytes that may be used for selecting a certain segment instead of the segment ID. In this case, the SegID parameter will be used as the start segment for the search. Segments are always searched beginning from the lowest ID.
[in]Stamp_len
[out]MediaTypeIndicates the type of card that was selected.
[out]FuncLevelFunction level of the card. The function level depends on the type of card: * 1-16: GAM (General Authorization Media) * 1-64 (55-64 reserved by LEGIC): SAM (System Authorization Media) * 1-48 (40-48 reserved by LEGIC): IAM (Identification Authorization Media) * 0: IM (Identification Media, segmented/unsegmented) / NM (New Media) * 1: XAM (Extended Authorization Media)
[out]OrgLevelOrganization level of the card. The organization level depends on the type of card: * 1-12: AM (Authorization Media) / XAM (Extended Authorization Media) * 0: IM (Identification Media) / NM (New Media)
[out]EvStatEvent Status of operation.
[out]ActSegIDSelected segment, 0x01 - 0x7F for segmented card, 0x00 for unsegmented card.
[out]ActAdrAddress of read data.
[out]DataData read from card.
[out]Data_len
[in]mempoolis used to store response data. Maybe NULL to use an internal mempool, in this case the data is only available until another command uses the internal mempool
Deprecated:
This command may be removed in future!