//Find device port. private bool findPorts() { bool status = false; try { String[] ports = RS232.findPorts(); bcom.setBaudRate(19200); for (int count = 0; count < ports.Length; count++) { bcom.setCom(ports[count]); Info.COM = ports[count]; if (SendC56()) { status = true; break; } else { bcom.setCom(""); Info.COM = ""; } } } catch (Exception ex) { MITLog.PrintLn("findPorts" + ex.Message); status = false; } return(status); }
//Send Port RS232. private bool SendRS232() { bool ReadStatus = false; bcom.setCommContinue(false); try { //bcom.setTimeOut(0); if (!RS232.IsOpen()) { RS232.SetConfig(bcom.getCom(), bcom.getBaudRate()); } if (RS232.OpenPort()) { RS232.WritePort(); if (bcom.getCommContinue()) { RS232.ReadPort(); } } else { bcom.setfindDevice(false); return(false); } RS232.ClosePort(); if (bcom.getstatusRead()) { ReadStatus = true; } } catch (Exception ex) { MITLog.PrintLn("SendMsg:" + ex.Message); return(false); } return(ReadStatus); }