public SerialRelay(string name, IEmissionProcessor receiver_in) { this.TranmissionFormatter = new ApiFrameTransmissionObjectFormatter(); // this.receiver = receiver_in; // this.workerWrite.DoWork += this.workerWrite_DoWork; // port = new SerialPort(name); port.BaudRate = 115200; port.DataBits = 8; port.Parity = Parity.None; port.StopBits = StopBits.One; port.Handshake = Handshake.None; port.Encoding = Encoding.Unicode; port.DataReceived += SerialPort_DataReceived; port.ErrorReceived += SerialPort_ErrorReceived; port.ReadBufferSize = 100000; port.WriteBufferSize = 100000; port.Open(); port.DiscardInBuffer(); if (!port.IsOpen) { throw new Exception("Failed to connect to serial port " + name); } }
internal BluetoothRelay(IDevice device_in, string password, IEmissionProcessor receiver_in) { // this.TranmissionFormatter = new MicropyEmissionObjectFormatter(); this.receiver = receiver_in; this.device = new XBeeBLEDevice(device_in, null); //this.device.PacketReceived += Device_PacketReceived; //this.device.SerialDataReceived += Device_SerialDataReceived; //this.device.UserDataRelayReceived += Device_UserDataRelayReceived; this.device.ReceiveTimeout = 1000; this.device.SetBluetoothPassword(password); this.device.Open(); this.device.EnableBluetooth(); return; }