public TFBasicCom(bool isASCOM = false, Form parent = null) { fDeviceVersion = ""; fDeviceType = FDEV.FD_UNKNOWN; fIsASCOM = isASCOM; fParent = parent; fDeviceDbgMsgArray = new ConcurrentQueue <string>(); //fReadThread = new Thread(GetSerialData); fComPort = new SerialPort(); fBuffer = new ByteBuffer(); RTC = new TFDeviceRTC(this); }
protected virtual bool ParseCommand(byte[] cmd, int cmdlen) { if (cmd.Length == 0) { return(false); } if (RTC.OnCommand(cmd, cmdlen)) { return(true); } switch ((byte)cmd[0]) { case (byte)FBC.FBC_HANDSHAKE: fDeviceType = (FDEV)cmd[1]; OnHandshakeRouting(); Thread.Sleep(10); if ((OnHandshakeEvent != null) && (fParent != null)) { fParent.BeginInvoke(OnHandshakeEvent); } return(true); case (byte)FBC.FBC_PING: if ((OnPingEvent != null) && (fParent != null)) { fParent.BeginInvoke(OnPingEvent); } return(true); case (byte)FBC.FBC_GET_FIRMWARE_VERSION: fDeviceVersion = GetStringFormArray(cmd, cmdlen - 1, 1); if ((OnFirmwareEvent != null) && (fParent != null)) { fParent.BeginInvoke(OnFirmwareEvent); } return(true); case (byte)FBC.FBC_RCP: fIsRCP_ON = Convert.ToBoolean(cmd[1]); if ((OnRPCEvent != null) && (fParent != null)) { fParent.BeginInvoke(OnRPCEvent); } return(true); case (byte)FBC.FBC_DEBUG: fIsDebug = Convert.ToBoolean(cmd[1]); if ((OnDebugEvent != null) && (fParent != null)) { fParent.BeginInvoke(OnDebugEvent); } return(true); case (byte)FBC.FBC_DEBUG_MSG: { fDeviceDbgMsgArray.Enqueue(GetStringFormArray(cmd, cmdlen - 1, 1)); if ((OnDebugMsgEvent != null) && (fParent != null)) { fParent.BeginInvoke(OnDebugMsgEvent); } return(true); }; } return(false); }