public bool ConnectRFID()//port:COM1, baudRate:9600 { //===================================================================== // This function opens the port(connection) to ACR120 reader // using BaudRate specified. //===================================================================== if (this.isConnected) { this._lastError = "Device is already connected."; return(false); } int iPort = int.Parse(Registry.GetKey("ComPort", "COM1").Substring(3)); g_rHandle = ACR120.ACR120_Open(iPort - 1, ACR120.ACR120_COM_BAUDRATE_9600); if (g_rHandle != 0) { this._lastError = "[X] " + ACR120.GetErrMsg(g_rHandle); } else { //Functions.MsgBox("Connected to COM" + String.Format("{0}", 1)); //g_isConnected = true; this.isConnected = true; // set Station ID = 1 this is factory default g_SID = 1; } return(this.isConnected); }
// Destruktor protected void Dispose() { if (this.isConnected) { ACR120.ACR120_Close(g_rHandle); } }
public void CloseConection() { ACR120.ACR120_Close(g_rHandle); }
public string ListTagRFID() { //===================================================================== // This function list the serial number of all tags within the // readable antenna range //===================================================================== //Variable Declarations byte[] Tag = new byte[50]; byte TagFound = 0; byte[] SN = new byte[255]; int ctr, ctr1, indx, ctr2; string snstr; g_retCode = ACR120.ACR120_ListTag(g_rHandle, g_SID, ref TagFound, ref pHaveTag, ref Tag[0], ref SN[0]); if (g_retCode != 0) { this._lastError = "[X] " + ACR120.GetErrMsg(g_retCode); return(""); } else { //Functions.MsgBox("List Tag Success: " + String.Format("{0}", g_retCode)); //Functions.MsgBox("Tag Found: " + String.Format("{0}", TagFound)); indx = 0; ctr2 = 0; snstr = ""; // Parse the serial number array for (ctr1 = 0; ctr1 < TagFound; ctr1++) { if (pHaveTag) { if ((Tag[ctr1] == 4) || (Tag[ctr1] == 5)) { snstr = ""; for (ctr = indx; ctr < 7; ctr++) { snstr = snstr + string.Format("{0:X2} ", SN[ctr]); indx++; } } else { snstr = ""; for (ctr = indx; ctr < 4; ctr++) { snstr = snstr + string.Format("{0:X2} ", SN[ctr]); indx++; } } } else { snstr = ""; for (ctr = indx; ctr < Tag[ctr1] + ctr2; ctr++) { snstr = snstr + string.Format("{0:X2} ", SN[ctr]); indx++; } return(snstr); } //Functions.MsgBox("Tag(" + string.Format("{0}", ctr1) + ") : " + snstr); ctr2 = indx; return(snstr); } return(""); } }