private void UartDataReceiedCallback(BaseBPSPacket baseBPSPacket) { try { switch (baseBPSPacket.ResponseCmd) { case BPSPacketCommTest.RESPONSE_CMD: { BPSPacketCommTest p = baseBPSPacket as BPSPacketCommTest; UIDoBPSPacket(p); break; } case BPSPacketDevInfo.RESPONSE_CMD: { BPSPacketDevInfo p = baseBPSPacket as BPSPacketDevInfo; UIDoBPSPacket(p); break; } } } catch (Exception e) { } }
private void UIDoBPSPacket(BPSPacketCommTest bps) { if (null == bps) { return; } if (!devFound) { devFound = true; } }
private void SearchPort() { if (startNewSearch) { startNewSearch = false; bpsMngObj.UartClose(); if (bpsMngObj.UartOpen(currentPort, currentSearchBaudrate)) { /** do nothing */ } else { timeoutLeft = 0; } } if (bpsMngObj.IsUartOpen()) { BPSPacketCommTest bpsPacket = new BPSPacketCommTest(); bpsMngObj.SendBPSPacketReq(bpsPacket); } }
private BaseBPSPacket BpsParse() { BaseBPSPacket ret = null; try { switch (RecvBuffer[BpsUtils.DATA_INDEX]) { case BPSPacketCommTest.RESPONSE_CMD: { ret = new BPSPacketCommTest(); ret.ResponseParse(ref RecvBuffer); break; } case BPSPacketBaudrate.RESPONSE_CMD: { ret = new BPSPacketBaudrate(); ret.ResponseParse(ref RecvBuffer); break; } case BPSPacketReset.RESPONSE_CMD: { ret = new BPSPacketReset(); ret.ResponseParse(ref RecvBuffer); break; } case BPSPacketRestoreFac.RESPONSE_CMD: { ret = new BPSPacketRestoreFac(); ret.ResponseParse(ref RecvBuffer); break; } case BPSPacketAddrSet.RESPONSE_CMD: { ret = new BPSPacketAddrSet(); ret.ResponseParse(ref RecvBuffer); break; } /** System Parameter Commands */ case BPSPacketSysPara.RESPONSE_CMD: { ret = BPSPacketSysPara.CreateObj(ref RecvBuffer); if (null != ret) { ret.ResponseParse(ref RecvBuffer); } break; } } } catch (Exception e) { ret = null; } BpsHeaderClear(); return(ret); }