Beispiel #1
0
        public CANError DecodePacket(byte[] buff, ref CANPacket packet)
        {
            CANError errorcode  = CANError.CAN_ERROR_NONE;
            UInt32   extendedID = ((UInt32)buff[0] << 24) + ((UInt32)buff[1] << 16) + ((UInt32)buff[2] << 8) + (UInt32)buff[3];

            packet.Packet_type         = (CANPacket.Pkt_Type_t)((extendedID >> 24) & 0x03);
            packet.Packet_id           = ((extendedID >> 16) & 0x0F);
            packet.Source_address      = (extendedID >> 8) & 0xFF;
            packet.Destination_address = extendedID & 0xFF;

            int idx = 4;

            packet.Length = buff[idx++];

            if (packet.Length > CANPacket.BufferSize)
            {
                return(CANError.CAN_ERROR_LENGTH);
            }

            for (int i = 0; i < packet.Length; i++)
            {
                packet.Buffer[i] = buff[idx++];
            }

            return(errorcode);
        }
Beispiel #2
0
 /// <summary>
 /// 显示错误信息对话框
 /// </summary>
 /// <param name="index">通道索引(从 0 开始)</param>
 /// <param name="error">错误码</param>
 public static void ShowErrorDialog(ref Int32 index, ref CANError error)
 {
     CanInteraction.CANError(index, error);
 }
Beispiel #3
0
 public static extern void CANError(Int32 index, CANError error);