public void Start() { t = new SerialTransportAddress("COM1", false); transport = new SerialTransport(t, 9600); transport.Start(this); monitor = new object(); }
public SerialTransport(SerialTransportAddress sta, int baudRate) { this.sta = sta; this.port = CreateSerialPort(sta, baudRate); SendBuffer = new Dictionary(); headerACK = new SafeSerialHeader(); }
/// <summary> /// Check if a Tranport Address belongs to the same network as this one. /// </summary> public override bool IsSameNetwork(TransportAddress ta) { if (ta == null || GetType() != ta.GetType()) { return(false); } SerialTransportAddress t = (SerialTransportAddress)ta; return(serialport == t.serialport); }
/// <summary> /// Indicates if this object equals to an other object /// </summary> /// <param name="obj">Object used to compare</param> /// <returns></returns> public override bool Equals(object obj) { //Check for null and compare run-time types. if (obj == null || GetType() != obj.GetType()) { return(false); } SerialTransportAddress tm = (SerialTransportAddress)obj; return(transportMode.Equals(tm.transportMode) && serialport.Equals(tm.serialport)); }
/// <summary> /// Override this method in order to perform a custom Serial Port initialization. /// </summary> /// <param name="baudRate">Serial port baud rate.</param> /// <returns>Ready-to-use serial port.</returns> internal virtual SerialPort CreateSerialPort(SerialTransportAddress sta, int baudRate) { SerialPort port; port = new SerialPort(sta.serialport, baudRate, Parity.None, 8, StopBits.One); #if !MicroFramework port.ReadBufferSize = 65536; port.Encoding = Encoding.GetEncoding("iso-8859-1"); #endif return(port); }
/// <summary> /// Override this method in order to perform a custom Serial Port initialization. /// </summary> /// <param name="baudRate">Serial port baud rate.</param> /// <returns>Ready-to-use serial port.</returns> internal virtual SerialPort CreateSerialPort(SerialTransportAddress sta, int baudRate) { SerialPort port; port = new SerialPort(sta.serialport, baudRate, Parity.None, 8, StopBits.One); #if !MicroFramework port.ReadBufferSize = 65536; port.Encoding = Encoding.GetEncoding("iso-8859-1"); #endif return port; }