Example #1
0
        public int SendMessage(CanPacket canPacket)
        {
            if (ReceivedCanPacketCallBack == null)
            {
                return(-1);
            }

            ReceivedCanPacketCallBack?.Invoke(canPacket);
            return(1);
        }
        private void SplitCanPackets(byte[] data, IPAddress sourceIPAddress, int sourcePort)
        {
            Byte[] header     = data.Take(16).ToArray();
            Byte[] body       = data.Skip(16).ToArray();
            int    numPackets = body.Length / 14;

            for (int i = 0; i < numPackets; i++)
            {
                CanPacket canPacket = new CanPacket(header.Concat(body.Take(14).ToArray()).ToArray())
                {
                    SourceIPAddress = sourceIPAddress,
                    SourceIPPort    = sourcePort
                };

                ReceivedCanPacketCallBack?.Invoke(canPacket);

                body = body.Skip(14).ToArray();
            }
        }