Ejemplo n.º 1
0
            public ISerialPortPacket[] Unpack(byte[] bytes)
            {
                List <ISerialPortPacket> packets = new List <ISerialPortPacket>();

                buffer.Write(bytes, 0, bytes.Length);

                while (buffer != null && buffer.Position >= maxLength)
                {
                    ISerialPortPacket packet = Decode();

                    if (packet != null)
                    {
                        packets.Add(packet);
                    }
                }

                return(packets.ToArray());
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Dispatches the event of serial port received data.
 /// </summary>
 /// <param name="packet">The <see cref="ISerialPortPacket"/> unpacked.</param>
 protected override void DispatchDataReceivedEvent(ISerialPortPacket packet)
 {
     DispatchEvent(new SerialPortEvent(SerialPortEvent.DataReceived, this, packet));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SerialPortEvent"/> class with event type, <see cref="SerialPort"/> instance and <see
 /// cref="ISerialPortPacket"/> unpacked.
 /// </summary>
 /// <param name="eventType">The type of event.</param>
 /// <param name="serialPort">The <see cref="MonoSerialPort"/> instance.</param>
 /// <param name="packet">The <see cref="ISerialPortPacket"/> unpacked.</param>
 public SerialPortEvent(string eventType, MonoSerialPort serialPort, ISerialPortPacket packet = null)
     : base(eventType, serialPort)
 {
     SerialPortPacket = packet;
 }