protected override void OnRxChar(byte ch) { CommBase.ASCII ascii = (CommBase.ASCII)ch; if (ascii == m_RxTerm || m_RxIndex >= m_RxBuffer.Length) { lock (m_RxString) { m_RxString = Encoding.ASCII.GetString(m_RxBuffer, 0, m_RxIndex); } m_RxIndex = 0; if (m_TransFlag.WaitOne(0, false)) { OnRxLine(m_RxString); } else { m_TransFlag.Set(); } } else { if (m_RxFilter != null) { for (int idx = 0; idx < m_RxFilter.Length; ++idx) { if (m_RxFilter[idx] == ascii) { return; } } } m_RxBuffer[m_RxIndex] = ch; ++m_RxIndex; } }
protected void Setup(CommLine.CommLineSettings s) { RxBuffer = new byte[s.rxStringBufferSize]; RxTerm = s.rxTerminator; RxFilter = s.rxFilter; TransTimeout = (uint)s.transactTimeout; TxTerm = s.txTerminator; }
protected void Setup(CommLine.CommLineSettings settings) { m_RxBuffer = new byte[settings.RxStringBufferSize]; m_RxTerm = settings.RxTerminator; m_RxFilter = settings.RxFilter; m_TransTimeout = settings.TransactTimeout; m_TxTerm = settings.TxTerminator; }
public void SetStandard(string Port, int Baud, CommBase.Handshake Hs) { dataBits = 8; stopBits = CommBase.StopBits.one; parity = CommBase.Parity.none; port = Port; baudRate = Baud; switch (Hs) { case CommBase.Handshake.none: txFlowCTS = false; txFlowDSR = false; txFlowX = false; rxFlowX = false; useRTS = CommBase.HSOutput.online; useDTR = CommBase.HSOutput.online; txWhenRxXoff = true; rxGateDSR = false; break; case CommBase.Handshake.XonXoff: txFlowCTS = false; txFlowDSR = false; txFlowX = true; rxFlowX = true; useRTS = CommBase.HSOutput.online; useDTR = CommBase.HSOutput.online; txWhenRxXoff = true; rxGateDSR = false; XonChar = CommBase.ASCII.DC1; XoffChar = CommBase.ASCII.DC3; break; case CommBase.Handshake.CtsRts: txFlowCTS = true; txFlowDSR = false; txFlowX = false; rxFlowX = false; useRTS = CommBase.HSOutput.handshake; useDTR = CommBase.HSOutput.online; txWhenRxXoff = true; rxGateDSR = false; break; case CommBase.Handshake.DsrDtr: txFlowCTS = false; txFlowDSR = true; txFlowX = false; rxFlowX = false; useRTS = CommBase.HSOutput.online; useDTR = CommBase.HSOutput.handshake; txWhenRxXoff = true; rxGateDSR = false; break; } }
public void SetStandard(string port, int baudrate, CommBase.Handshake handshake) { DataBits = 8; StopBits = CommBase.StopBits.One; Parity = CommBase.Parity.None; Port = port; BaudRate = baudrate; switch (handshake) { case CommBase.Handshake.None: TxFlowCTS = false; TxFlowDSR = false; TxFlowX = false; RxFlowX = false; UseRTS = CommBase.HSOutput.Online; UseDTR = CommBase.HSOutput.Online; TxWhenRxXoff = true; RxGateDSR = false; break; case CommBase.Handshake.XonXoff: TxFlowCTS = false; TxFlowDSR = false; TxFlowX = true; RxFlowX = true; UseRTS = CommBase.HSOutput.Online; UseDTR = CommBase.HSOutput.Online; TxWhenRxXoff = true; RxGateDSR = false; XonChar = CommBase.ASCII.DC1; XoffChar = CommBase.ASCII.DC3; break; case CommBase.Handshake.CtsRts: TxFlowCTS = true; TxFlowDSR = false; TxFlowX = false; RxFlowX = false; UseRTS = CommBase.HSOutput.Handshake; UseDTR = CommBase.HSOutput.Online; TxWhenRxXoff = true; RxGateDSR = false; break; case CommBase.Handshake.DsrDtr: TxFlowCTS = false; TxFlowDSR = true; TxFlowX = false; RxFlowX = false; UseRTS = CommBase.HSOutput.Online; UseDTR = CommBase.HSOutput.Handshake; TxWhenRxXoff = true; RxGateDSR = false; break; } }
public CommBaseSettings() { this.port = "COM1:"; this.baudRate = 0xe100; this.dataBits = 8; this.txWhenRxXoff = true; this.XonChar = CommBase.ASCII.DC1; this.XoffChar = CommBase.ASCII.DC3; this.checkAllSends = true; }
protected override void OnRxChar(byte ch) { unsafe { CommBase.ASCII aSCII = (CommBase.ASCII)ch; if (aSCII == this.RxTerm || this.RxBufferP > this.RxBuffer.GetUpperBound(0)) { lock (this.RxString) { this.RxString = Encoding.ASCII.GetString(this.RxBuffer, 0, (int)this.RxBufferP); } this.RxBufferP = 0; if (!this.TransFlag.WaitOne(0, false)) { this.TransFlag.Set(); return; } else { this.OnRxLine(this.RxString); return; } } else { bool flag = true; if (this.RxFilter != null) { for (int i = 0; i <= this.RxFilter.GetUpperBound(0); i++) { if (this.RxFilter[i] == aSCII) { flag = false; } } } if (flag) { this.RxBuffer[this.RxBufferP] = ch; CommLine rxBufferP = this; rxBufferP.RxBufferP = rxBufferP.RxBufferP + 1; } return; } } }
protected override void OnRxChar(byte ch) { CommBase.ASCII ascii = (CommBase.ASCII)ch; if ((ascii == this.RxTerm) || (this.RxBufferP > this.RxBuffer.GetUpperBound(0))) { lock (this.RxString) { this.RxString = Encoding.ASCII.GetString(this.RxBuffer, 0, (int)this.RxBufferP); } this.RxBufferP = 0; if (this.TransFlag.WaitOne(0, false)) { this.OnRxLine(this.RxString); } else { this.TransFlag.Set(); } } else { bool flag = true; if (this.RxFilter != null) { for (int i = 0; i <= this.RxFilter.GetUpperBound(0); i++) { if (this.RxFilter[i] == ascii) { flag = false; } } } if (flag) { this.RxBuffer[this.RxBufferP] = ch; this.RxBufferP++; } } }
protected override void OnRxChar(byte ch) { CommBase.ASCII ascii = (CommBase.ASCII)ch; if (ascii == RxTerm || (long)RxBufferP > (long)RxBuffer.GetUpperBound(0)) { lock (RxString) RxString = Encoding.ASCII.GetString(RxBuffer, 0, (int)RxBufferP); RxBufferP = 0U; if (TransFlag.WaitOne(0, false)) { OnRxLine(RxString); } else { TransFlag.Set(); } } else { bool flag = true; if (RxFilter != null) { for (int index = 0; index <= RxFilter.GetUpperBound(0); ++index) { if (RxFilter[index] == ascii) { flag = false; } } } if (!flag) { return; } RxBuffer[RxBufferP] = ch; ++RxBufferP; } }
public void setRxTerminator(CommBase.ASCII chr) { OBDCommELM.m_asciiRxTerm = chr; }
public void setRxTerminator(CommBase.ASCII ch) { m_asciiRxTerm = ch; }
public CommLineSettings() { this.rxStringBufferSize = 0x100; this.rxTerminator = CommBase.ASCII.CR; this.transactTimeout = 0x1f4; }
public void SetStandard(string Port, uint Baud, CommBase.Handshake Hs) { this.dataBits = 8; this.stopBits = CommBase.StopBits.one; this.parity = CommBase.Parity.none; this.port = Port; this.baudRate = Baud; CommBase.Handshake hs = Hs; switch (hs) { case CommBase.Handshake.none: { this.txFlowCTS = false; this.txFlowDSR = false; this.txFlowX = false; this.rxFlowX = false; this.useRTS = CommBase.HSOutput.online; this.useDTR = CommBase.HSOutput.online; this.txWhenRxXoff = true; this.rxGateDSR = false; return; } case CommBase.Handshake.XonXoff: { this.txFlowCTS = false; this.txFlowDSR = false; this.txFlowX = true; this.rxFlowX = true; this.useRTS = CommBase.HSOutput.online; this.useDTR = CommBase.HSOutput.online; this.txWhenRxXoff = true; this.rxGateDSR = false; this.XonChar = CommBase.ASCII.DC1; this.XoffChar = CommBase.ASCII.DC3; return; } case CommBase.Handshake.CtsRts: { this.txFlowCTS = true; this.txFlowDSR = false; this.txFlowX = false; this.rxFlowX = false; this.useRTS = CommBase.HSOutput.handshake; this.useDTR = CommBase.HSOutput.online; this.txWhenRxXoff = true; this.rxGateDSR = false; return; } case CommBase.Handshake.DsrDtr: { this.txFlowCTS = false; this.txFlowDSR = true; this.txFlowX = false; this.rxFlowX = false; this.useRTS = CommBase.HSOutput.online; this.useDTR = CommBase.HSOutput.handshake; this.txWhenRxXoff = true; this.rxGateDSR = false; return; } default: { return; } } }