1. Home
  2. Docs
  3. J42 series
  4. J4210U, J4212U, J4220UX, ...
  5. DLL Functions

DLL Functions

Following DLL functions are available.

unsigned char AvailablePorts(char ports[2048]);

Auto detects avialable serial ports and copies them into the two dimensional array.
Parameters:
ports: com port name array. Must be of size 256 x 8 or a single dimension array of 2048.
Example: ports[0] = “COM4”, ports[1] = “COM7”, etc.
Returns: 1 on success.

unsigned char OpenPort(unsigned char* port, int baud);

Opens a COM port.
Parameters:
port: com port name.
Example “COM4”, etch
baud: baudrate; should be one of 57600, 115200.
Returns: 1 on success.

void ClosePort();

Closes COM port that was opened.

unsigned char LoadSettings(unsigned char* readerinfo);

Loads settings into the array. The array size should be sufficient enough to hold the data.
The data structure to hold the data is as follows:

struct ReaderInfo {
    // the following constants are reader constants
    // they cannot be changed.
    int Serial = 0;
    char VersionInfo[2] = {0,0};
    unsigned char Antenna = 0;
    unsigned char ComAdr;
    unsigned char ReaderType;

    // the following variables are reader parameters
    // which can be changed. Call SetSettings function
    // to change the settings.
    unsigned char Protocol;
    unsigned char Band;
    unsigned char Power;
    unsigned char ScanTime;
    unsigned char BeepOn;

    // unused
    unsigned char Reserved1;
    unsigned char Reserved2;

    // cannot be changed
    int MaxFreq  = 0;
    int MinFreq  = 0;
    int BaudRate = 0;
};

Parameters:
readerinfo: pointer to ReaderInfo structure.
Returns: 1 on success.

unsigned char SaveSettings(unsigned char* readerinfo);

Saves reader info. The ReaderInfo struct may be modified and passed to this function.
Only the Protocol, Band, Power, ScanTime, BeepOn can change.
Parameters:
readerinfo: pointer to ReaderInfo structure.
Returns: 1 on success.

int Inventory(unsigned char filter);

Performs inventory with or without filter. The filter parameters may be set by calling Filter function prior to calling this function. If the return value is non-zero (positive), then the inventory items could be retried by using zero based index by calling GetResult function.
Parameters:
filter: 1 to perform filtering, otherwise pass 0.
Returns: Number of unique tags found. Returns 0, if no tags found.

int InventoryOne();

Gets single tag inventory. This usually return the tag that responds to the inventory request.
This does not necessarily mean the closest tag. To find the closest tag, reduce the power and call this function.
Parameters: None
Returns: 1, if found, 0 otherwise.

unsigned char GetResult(unsigned char *scanresult, int index);

Gets the inventory item at index (zero based). If not found, returns 0. If found stores the scan data into scanresult array. ScanResult data structure is shown below.

struct ScanResult {
    unsigned char ant;  // 1 byte
    char RSSI;  // 1 byte
    unsigned char count; // 1 byte
    unsigned char epclen;
    unsigned char epc[12]; // 12 byte or 62 by7e
};
Parameters:
scanresult: pointer to the ScanResult structure.
index: index of the inventory item.
Returns: 1 on success.

unsigned char GetTID(unsigned char* epc, unsigned char epclen, unsigned char* tid, unsigned char* tidlen);

Gets TID for the tag with given EPC.
Parameters:
epc: EPC code of the tag for which TID is requested.
epclen: length of EPC.
tid: an array to hold the TID. Provide an array of sufficient size.
tidlen: actual number of bytes copied into the tid array.
Returns: 1 if successful.

unsigned char GetTagInfo(unsigned char* tid, unsigned char* info);


struct TagInfo {
    int type;
    int tidlen;
    unsigned char tid[64];
    char chip[16];
    int epclen;
    int userlen;
    int pwdlen;
};
Parameters:
tid: TID code of the tag for which TID is requested.
info: buffer to get the result returned.
Returns: 1, if successful.

unsigned char SetPassword(unsigned char* epc, unsigned char epclen, unsigned char* pwd, unsigned char pwdlen);

Sets password for the card with the given EPC.
Parameters:
epc: EPC code of the tag for which TID is requested.
epclen: length of EPC.
pwd: an array holding the password.
pwdlen: length of the password array. The length must be 4 bytes at least.
Returns: 1, if successful.

unsigned char SetKillPassword(unsigned char* epc, unsigned char epclen, unsigned char* kpwd, unsigned char kpwdlen);

Sets kill password for the card with the given EPC.
Parameters:
epc: EPC code of the tag for which TID is requested.
epclen: length of EPC.
kpwd: an array holding the password.
kpwdlen: length of the password array. The length must be 4 bytes at least.
Returns: 1, if successful.

void LastError(char* error);

Stores the last error.
Parameters:
error: an array to hold the error. Pass an array of sufficient length. 256 byte array recommended.
The error is a C type string, terminated by a NULL character.
Returns: none.

unsigned char Auth(unsigned char* pwd, unsigned char pwdlen);

Sets the tag password to be used for all successive inventory and read/write operations.
Parameters:
pwd: an array containing password.
pwdlen: length of the password array. Minimum is 4 bytes (32 bits).
Returns: 1 if command was successful. If no card found, will return 0.

unsigned char WriteMemWord(unsigned char* epc, unsigned char epclen, unsigned char* data, unsigned char windex);

Writes the 2-byte word in the data to the Tag’s User memory at word index windex.
Parameters:
epc: EPC of the tag.
epclen: number of bytes in EPC.
data: 2 byte array with data, MSB byte first followed by LSB byte.
windex: word index. Tags are indexed by word, 2 two bytes are written simultaneously.
Returns: 1, if successful.

unsigned char ReadMemWord(unsigned char* epc, unsigned char epclen, unsigned char* data, unsigned char windex);

Reads 2-byte word into data from Tag’s User memory at word index windex.
Parameters:
epc: EPC of the tag.
epclen: number of bytes in EPC.
data: 2 byte array with data to be saved, MSB byte first followed by LSB byte.
windex: word index. Tags are indexed by word, 2 two bytes are written simultaneously.
Returns: 1, if successful.

unsigned char SetFilter(int maskAdrByte, int maskLenInByte, unsigned char* maskDataByte);

Sets Tag’s EPC filtering to be used during inventory.
Example: If there are tags with the following EPC:
ABCD1234FEDC5679
ABCD5679FEDC1234
FEDC1234ABCD5679

Then SetFilter(0, 2, [0xAB, 0xCD]) will return tags #1 and #2 upon inventory.SetFilter(2, 2, [0x12, 0x34]) will return tag #1 and #3. SetFilter(6, 2, [0x56, 0x78]). And if only a specific tag is required, the SetFilter(0, 8, [0xAB, 0xCD, 0x56, 0x79, 0xFE, 0xDC, 0x12, 0x34]) will return only #2.This operation is very useful to search inventory of products with know EPC prefix or suffix.

Parameters:
maskAdrByte: Number of bytes from the beginning of EPC code.
maskLenInByte: Number of bytes in the mask byte.
maskDataByte: mask bytes of length provided in second parameter.
Returns: 1, if successful.

int TagType();

Returns the Tag type, usually the chip used. The number returned is an index to an array of known tag chips.
This operation must be called after calling getTID().
Because, TID contains the tag’s manufacturer information for most chips.
Parameters: none.
Returns: a non zero index. If zero is returned, then tag chip could not be determined.

unsigned char TagName(char* name);

Stores the tag’s name identified by index returned by TagType().
Parameters:
name: an array to store the name. The array should at least be 64 byte. The array is C type NULL terminated string.
Returns: 1, if successful.

unsigned char WriteEpcWord(unsigned char* epc, unsigned char epclen, unsigned char* epcword, unsigned char windex);

Writes the 2-byte EPC word at word index windex. This function may be used if only a word is required to be changed in EPC.
Parameters:
epc: EPC of the tag.
epclen: number of bytes in EPC.
data: 2 byte array with EPC data, MSB byte first followed by LSB byte.
windex: word index. Tags are indexed by word, 2 two bytes are written simultaneously.
Returns: 1, if successful.

unsigned char WriteEpc(unsigned char* epc, unsigned char epclen, unsigned char* newepc);

Writes the whole EPC word. EPC is typically 12 byte.
Parameters:
epc: EPC of the tag.
epclen: number of bytes in EPC.
newepc: 12 byte array with EPC data, MSB byte first followed by LSB byte.
Returns: 1, if successful.

unsigned char TagExists(unsigned char* epc, unsigned char epclen);

Checks if the tag with the given EPC is found in the field.
Parameters :
epc : EPC of the tag.
epclen : number of bytes in EPC.
Returns: 1, if tag found.

unsigned char SetGPO(unsigned char gpono);

Sets output of the GPIO to the value assigned. There are two GPIO outputs. Bit zero of gpono send output to GPO-0 and bit 1 sends to GPO-1. So, SetGPO(2) means, GPO-0 = 0 and GPO-1 = 1.
Parameters :
gpono : bit wise assignment of state per GPO output port.
Returns : 1, if successful.

unsigned char GetGPI(unsigned char gpino);

gets input from GPIO. There are two GPIO, GPI-0 and GPI-1. To get input from GPI-0, send gpino = 1, to get input from GPI-2, send gpino = 2. All other values are invalid.
Parameters:
gpino : GPI input filtering bit.
Returns: GPI input from the given port.

unsigned char SetQ(unsigned char Q);

Sets the Q parameter. For a small number of tags, set this to 5. The best value should be found by trial and error.
Parameters:
Q : Optimal Q value.
Returns: 1 on failure.

unsigned char SetSession(unsigned char sess);

Sets inventory session. Sessions range from 0 to 3. If there are other RFID reader around, each reader should use a different session so the inventory scan will not affect the other readers.
Parameters:
sess : session number between 0 and 3.
Returns: 1 on failure