public bool Start() { bool blRet = false; try { int iRet = StaticClassReaderB.OpenNetPort(m_Port, m_IP, ref fComAdr, ref frmcomportindex); //int iRet = StaticClassReaderB.OpenNetPort(m_IP, m_Port, ref ComAddr); fOpenComIndex = frmcomportindex; if (iRet == 0) { blRet = true; } if ((iRet == 0x35) || (iRet == 0x30)) {//连接TCPIP错误 StaticClassReaderB.CloseNetPort(frmcomportindex); //StaticClassReaderB.CloseNetPort(); blRet = false; return(blRet); } if ((fOpenComIndex != -1) && (iRet != 0X35) && (iRet != 0X30)) { blRet = true; } } catch (Exception ex) { if (frmMain.blDebug) { MessageUtil.ShowTips(ex.Message); } } return(blRet); }
/// <summary> /// 打开读卡器网口连接 /// </summary> /// <param name="ip">IP地址</param> /// <param name="port">端口号</param> /// <param name="readerAddr">读卡器地址</param> /// <returns></returns> public bool OpenNetPort(string ip, int port, string readAddr = "FF") { readerAddr = Convert.ToByte(readAddr, 16); // $FF; int openresult = StaticClassReaderB.OpenNetPort(port, ip, ref readerAddr, ref portFrmIndex); if (openresult == 0) { if (OpenRF()) { SetStatus(true); return(true); } else { return(false); } } else if ((openresult == 0x35) || (openresult == 0x30)) { this.ErrorStr = "TCPIP error"; SetStatus(false); return(false); } return(false); }
//5.打开网口 private void openNetPort() { for (int i = 0; i < readerCount; i++) { backgroundWorker1.ReportProgress(i); //更新进度条 openResults[i] = StaticClassReaderB.OpenNetPort(readerPorts[i], readerIPAddrs[i], ref readerFComAdrs[i], ref readerFrmComPortIndexes[i]); } }
public void Connect(WebSocketSession res) { if (!READER_CONNECT) { try { Thread.Sleep(8000); if (READER_INIT) { StaticClassReaderB.CloseNetPort(HANDLE_PORT); READER_INIT = false; } StaticClassReaderB.OpenNetPort(Convert.ToInt32(READER_PORT), READER_IP, ref HANDLE_IP, ref HANDLE_PORT); READER_CONNECT = true; Detect(res); // res.Send("Conectando Dispositivo..."); res.Send(@"kyt = { 'type' : 'connect', 'payload': { 'state' : 'true', 'mensaje': 'Conectando Dispositivo...' } } "); } catch (Exception e) { // res.Send(e.Message); res.Send(@"kyt = { 'type' : 'connect', 'payload': { 'state' : 'false', 'mensaje': '" + e.Message + @"' } } "); } } else { // res.Send("Ya se encuentra conectado..."); res.Send(@"kyt = { 'type' : 'connect', 'payload': { 'state' : 'true', 'mensaje': 'Ya se encuentra conectado...' } } "); } }
public RFIDCL(string ip, string puerto, string tipo) { if (tipo == "RFID") { int existeConexionRFID = StaticClassReaderB.OpenNetPort(Convert.ToInt32(puerto), ip, ref readerAdress, ref fOpenComIndex); StaticClassReaderB.SetBeepNotification(ref readerAdress, 0, fOpenComIndex); if (existeConexionRFID != 0) //si ocurrio un error en la conexion TCP/IP.. cierro puerto de conexion. { StaticClassReaderB.CloseNetPort(fOpenComIndex); } } }
// Metodo de Conexion al RFID /// <summary> /// Conecta el dispositivo RFID /// </summary> /// <param name="ip">dirección ip del RFID</param> /// <param name="puerto">puerto el RFID</param> /// <returns>true si conecta el RFID o false si ocurre un error</returns> private bool conectarRFID() { int creaConexion = StaticClassReaderB.OpenNetPort(Convert.ToInt32(port), ip, ref ipHandle, ref portHandle); // Metodo que conecta con el RFID StaticClassReaderB.SetBeepNotification(ref ipHandle, 0, portHandle); // Notifica al RFID if (creaConexion != 0) // Si ocurre un error en la conexion TCP/IP, se cierra la conexion. { StaticClassReaderB.CloseNetPort(portHandle); // Metodo para cerrar la conexion. return(false); } else { return(true); } }
/// <summary> /// 连接 /// </summary> /// <returns></returns> public bool Connect() { int re = StaticClassReaderB.OpenNetPort((int)netPort, ipStr, ref comAddr, ref portHandle); if (re == 0x35) { StaticClassReaderB.CloseNetPort(portHandle); re = StaticClassReaderB.OpenNetPort((int)netPort, ipStr, ref comAddr, ref portHandle); } if (re == 0x00) { return(true); } else { return(false); } }
/// <summary> /// 连接 /// </summary> /// <returns></returns> public bool Connect() { this.comAddr = Convert.ToByte("FF", 16); // $FF; int re = StaticClassReaderB.OpenNetPort(this.readerPort, this.readerIP, ref this.comAddr, ref this.readHandle); if (re == 0) { this.isConnect = true; if (ChangeProtocol() == true) { return(true); } else { return(false); } } else { this.isConnect = false; return(false); } }
public static bool OpenPort() { bool ComOpen = false; int port = 0; int openresult, i; openresult = 30; if (!_IsUseNet) { port = Convert.ToInt32(_Com.Substring(3, _Com.Length - 3)); } int fOpenComIndex = 0; for (i = 6; i >= 0; i--) { fBaud = Convert.ToByte(i); if (fBaud == 3) { continue; } if (!_IsUseNet) { openresult = StaticClassReaderB.OpenComPort(port, ref fComAdr, fBaud, ref frmcomportindex); } else { LBErrorLog.InsertFileLog("OpenPort:" + _NetIPAddress + "_" + _NetPort + "_" + Rate); openresult = StaticClassReaderB.OpenNetPort(_NetPort, _NetIPAddress, ref fComAdr, ref frmcomportindex); } fOpenComIndex = frmcomportindex; if (openresult == 0x35) { LBErrorLog.InsertFileLog("网口已打开"); ComOpen = true; } if (openresult == 0) { ComOpen = true; byte[] TrType = new byte[2]; byte[] VersionInfo = new byte[2]; byte ReaderType = 0; byte ScanTime = 0; byte dmaxfre = 0; byte dminfre = 0; byte powerdBm = 0; int fCmdRet = StaticClassReaderB.GetReaderInformation(ref fComAdr, VersionInfo, ref ReaderType, TrType, ref dmaxfre, ref dminfre, ref powerdBm, ref ScanTime, frmcomportindex); if ((fCmdRet == 0x35) || (fCmdRet == 0x30)) { ComOpen = false; StaticClassReaderB.CloseSpecComPort(frmcomportindex); LBErrorLog.InsertFileLog("CloseSpecComPort串口通讯错误"); } fCmdRet = StaticClassReaderB.SetPowerDbm(ref fComAdr, powerDbm, frmcomportindex);//设置功率 break; } else if (_IsUseNet) { break; } } if ((fOpenComIndex == -1) && (openresult == 0x30)) { LBErrorLog.InsertFileLog("串口通讯错误"); } return(ComOpen); }
private int Connect(string ipAddress, int port) { _readerRef = StaticClassReaderB.OpenNetPort(port, ipAddress, ref _comAddress, ref _portHandle); Task.Delay(1000); return(_portHandle); }
/// <summary> /// Creates the connection to the RFID Reader /// </summary> /// <returns>PortHandle -- Success or failure of the connection</returns> public int OpenConnection() { StaticClassReaderB.OpenNetPort(Port, IP_Address.ToString(), ref ComAddrr, ref PortHandle); return(PortHandle); }