// PCAN-ISO-TP-CLR_2016.h // // ~~~~~~~~~~~~ // // PCAN-ISO-TP API // // ~~~~~~~~~~~~ // // ------------------------------------------------------------------ // Author : Fabrice Vergnaud // Last changed by: $Author: Catherine $ // Last changed date: $Date: 2021-01-27 14:43:15 +0100 (mer., 27 janv. 2021) $ // // Language: C++.Net CLR // ------------------------------------------------------------------ // // Copyright (C) 2020 PEAK-System Technik GmbH, Darmstadt // more Info at http://www.peak-system.com // // To use PCAN-ISO-TP_2004 and PCAN-ISO-TP_2016 together: do define PCANTP_API_COMPATIBILITY_ISO_2004" // #define PCANTP_API_COMPATIBILITY_ISO_2004 using namespace System; using namespace System::Text; using namespace System::Runtime::InteropServices; using namespace Peak::Can::Basic; namespace Peak { namespace Can { namespace IsoTp { //////////////////////////////////////////////////////////// // Types definition //////////////////////////////////////////////////////////// using cantp_bitrate = String^; // Represents a PCAN-FD bit rate string using cantp_timestamp = UInt64; // Timestamp using cantp_pcanstatus = UInt32; // Represents the PCAN error and status codes // Reserved extra information using cantp_msginfo_flag = UInt32; using cantp_msginfo_extra = UIntPtr; using cantp_isotp_info = UIntPtr; #pragma region Enumerations /// /// Represents currently defined and supported PCANTP handle (a.k.a. channels) /// public enum cantp_handle : UInt32 { /// /// Undefined/default value for a PCAN bus /// PCANTP_HANDLE_NONEBUS = PCANBasic::PCAN_NONEBUS, /// /// PCAN-ISA interface, channel 1 /// PCANTP_HANDLE_ISABUS1 = PCANBasic::PCAN_ISABUS1, /// /// PCAN-ISA interface, channel 2 /// PCANTP_HANDLE_ISABUS2 = PCANBasic::PCAN_ISABUS2, /// /// PCAN-ISA interface, channel 3 /// PCANTP_HANDLE_ISABUS3 = PCANBasic::PCAN_ISABUS3, /// /// PCAN-ISA interface, channel 4 /// PCANTP_HANDLE_ISABUS4 = PCANBasic::PCAN_ISABUS4, /// /// PCAN-ISA interface, channel 5 /// PCANTP_HANDLE_ISABUS5 = PCANBasic::PCAN_ISABUS5, /// /// PCAN-ISA interface, channel 6 /// PCANTP_HANDLE_ISABUS6 = PCANBasic::PCAN_ISABUS6, /// /// PCAN-ISA interface, channel 7 /// PCANTP_HANDLE_ISABUS7 = PCANBasic::PCAN_ISABUS7, /// /// PCAN-ISA interface, channel 8 /// PCANTP_HANDLE_ISABUS8 = PCANBasic::PCAN_ISABUS8, /// /// PCAN-Dongle/LPT interface, channel 1 /// PCANTP_HANDLE_DNGBUS1 = PCANBasic::PCAN_DNGBUS1, /// /// PCAN-PCI interface, channel 1 /// PCANTP_HANDLE_PCIBUS1 = PCANBasic::PCAN_PCIBUS1, /// /// PCAN-PCI interface, channel 2 /// PCANTP_HANDLE_PCIBUS2 = PCANBasic::PCAN_PCIBUS2, /// /// PCAN-PCI interface, channel 3 /// PCANTP_HANDLE_PCIBUS3 = PCANBasic::PCAN_PCIBUS3, /// /// PCAN-PCI interface, channel 4 /// PCANTP_HANDLE_PCIBUS4 = PCANBasic::PCAN_PCIBUS4, /// /// PCAN-PCI interface, channel 5 /// PCANTP_HANDLE_PCIBUS5 = PCANBasic::PCAN_PCIBUS5, /// /// PCAN-PCI interface, channel 6 /// PCANTP_HANDLE_PCIBUS6 = PCANBasic::PCAN_PCIBUS6, /// /// PCAN-PCI interface, channel 7 /// PCANTP_HANDLE_PCIBUS7 = PCANBasic::PCAN_PCIBUS7, /// /// PCAN-PCI interface, channel 8 /// PCANTP_HANDLE_PCIBUS8 = PCANBasic::PCAN_PCIBUS8, /// /// PCAN-PCI interface, channel 9 /// PCANTP_HANDLE_PCIBUS9 = PCANBasic::PCAN_PCIBUS9, /// /// PCAN-PCI interface, channel 10 /// PCANTP_HANDLE_PCIBUS10 = PCANBasic::PCAN_PCIBUS10, /// /// PCAN-PCI interface, channel 11 /// PCANTP_HANDLE_PCIBUS11 = PCANBasic::PCAN_PCIBUS11, /// /// PCAN-PCI interface, channel 12 /// PCANTP_HANDLE_PCIBUS12 = PCANBasic::PCAN_PCIBUS12, /// /// PCAN-PCI interface, channel 13 /// PCANTP_HANDLE_PCIBUS13 = PCANBasic::PCAN_PCIBUS13, /// /// PCAN-PCI interface, channel 14 /// PCANTP_HANDLE_PCIBUS14 = PCANBasic::PCAN_PCIBUS14, /// /// PCAN-PCI interface, channel 15 /// PCANTP_HANDLE_PCIBUS15 = PCANBasic::PCAN_PCIBUS15, /// /// PCAN-PCI interface, channel 16 /// PCANTP_HANDLE_PCIBUS16 = PCANBasic::PCAN_PCIBUS16, /// /// PCAN-USB interface, channel 1 /// PCANTP_HANDLE_USBBUS1 = PCANBasic::PCAN_USBBUS1, /// /// PCAN-USB interface, channel 2 /// PCANTP_HANDLE_USBBUS2 = PCANBasic::PCAN_USBBUS2, /// /// PCAN-USB interface, channel 3 /// PCANTP_HANDLE_USBBUS3 = PCANBasic::PCAN_USBBUS3, /// /// PCAN-USB interface, channel 4 /// PCANTP_HANDLE_USBBUS4 = PCANBasic::PCAN_USBBUS4, /// /// PCAN-USB interface, channel 5 /// PCANTP_HANDLE_USBBUS5 = PCANBasic::PCAN_USBBUS5, /// /// PCAN-USB interface, channel 6 /// PCANTP_HANDLE_USBBUS6 = PCANBasic::PCAN_USBBUS6, /// /// PCAN-USB interface, channel 7 /// PCANTP_HANDLE_USBBUS7 = PCANBasic::PCAN_USBBUS7, /// /// PCAN-USB interface, channel 8 /// PCANTP_HANDLE_USBBUS8 = PCANBasic::PCAN_USBBUS8, /// /// PCAN-USB interface, channel 9 /// PCANTP_HANDLE_USBBUS9 = PCANBasic::PCAN_USBBUS9, /// /// PCAN-USB interface, channel 10 /// PCANTP_HANDLE_USBBUS10 = PCANBasic::PCAN_USBBUS10, /// /// PCAN-USB interface, channel 11 /// PCANTP_HANDLE_USBBUS11 = PCANBasic::PCAN_USBBUS11, /// /// PCAN-USB interface, channel 12 /// PCANTP_HANDLE_USBBUS12 = PCANBasic::PCAN_USBBUS12, /// /// PCAN-USB interface, channel 13 /// PCANTP_HANDLE_USBBUS13 = PCANBasic::PCAN_USBBUS13, /// /// PCAN-USB interface, channel 14 /// PCANTP_HANDLE_USBBUS14 = PCANBasic::PCAN_USBBUS14, /// /// PCAN-USB interface, channel 15 /// PCANTP_HANDLE_USBBUS15 = PCANBasic::PCAN_USBBUS15, /// /// PCAN-USB interface, channel 16 /// PCANTP_HANDLE_USBBUS16 = PCANBasic::PCAN_USBBUS16, /// /// PCAN-PC Card interface, channel 1 /// PCANTP_HANDLE_PCCBUS1 = PCANBasic::PCAN_PCCBUS1, /// /// PCAN-PC Card interface, channel 2 /// PCANTP_HANDLE_PCCBUS2 = PCANBasic::PCAN_PCCBUS2, /// /// PCAN-LAN interface, channel 1 /// PCANTP_HANDLE_LANBUS1 = PCANBasic::PCAN_LANBUS1, /// /// PCAN-LAN interface, channel 2 /// PCANTP_HANDLE_LANBUS2 = PCANBasic::PCAN_LANBUS2, /// /// PCAN-LAN interface, channel 3 /// PCANTP_HANDLE_LANBUS3 = PCANBasic::PCAN_LANBUS3, /// /// PCAN-LAN interface, channel 4 /// PCANTP_HANDLE_LANBUS4 = PCANBasic::PCAN_LANBUS4, /// /// PCAN-LAN interface, channel 5 /// PCANTP_HANDLE_LANBUS5 = PCANBasic::PCAN_LANBUS5, /// /// PCAN-LAN interface, channel 6 /// PCANTP_HANDLE_LANBUS6 = PCANBasic::PCAN_LANBUS6, /// /// PCAN-LAN interface, channel 7 /// PCANTP_HANDLE_LANBUS7 = PCANBasic::PCAN_LANBUS7, /// /// PCAN-LAN interface, channel 8 /// PCANTP_HANDLE_LANBUS8 = PCANBasic::PCAN_LANBUS8, /// /// PCAN-LAN interface, channel 9 /// PCANTP_HANDLE_LANBUS9 = PCANBasic::PCAN_LANBUS9, /// /// PCAN-LAN interface, channel 10 /// PCANTP_HANDLE_LANBUS10 = PCANBasic::PCAN_LANBUS10, /// /// PCAN-LAN interface, channel 11 /// PCANTP_HANDLE_LANBUS11 = PCANBasic::PCAN_LANBUS11, /// /// PCAN-LAN interface, channel 12 /// PCANTP_HANDLE_LANBUS12 = PCANBasic::PCAN_LANBUS12, /// /// PCAN-LAN interface, channel 13 /// PCANTP_HANDLE_LANBUS13 = PCANBasic::PCAN_LANBUS13, /// /// PCAN-LAN interface, channel 14 /// PCANTP_HANDLE_LANBUS14 = PCANBasic::PCAN_LANBUS14, /// /// PCAN-LAN interface, channel 15 /// PCANTP_HANDLE_LANBUS15 = PCANBasic::PCAN_LANBUS15, /// /// PCAN-LAN interface, channel 16 /// PCANTP_HANDLE_LANBUS16 = PCANBasic::PCAN_LANBUS16, }; /// /// Represents the baudrate register for the PCANTP channel /// public enum cantp_baudrate : UInt32 { /// /// Channel Baudrate 1 MBit/s /// PCANTP_BAUDRATE_1M = (UInt32)TPCANBaudrate::PCAN_BAUD_1M, /// /// Channel Baudrate 800 kBit/s /// PCANTP_BAUDRATE_800K = (UInt32)TPCANBaudrate::PCAN_BAUD_800K, /// /// Channel Baudrate 500 kBit/s /// PCANTP_BAUDRATE_500K = (UInt32)TPCANBaudrate::PCAN_BAUD_500K, /// /// Channel Baudrate 250 kBit/s /// PCANTP_BAUDRATE_250K = (UInt32)TPCANBaudrate::PCAN_BAUD_250K, /// /// Channel Baudrate 125 kBit/s /// PCANTP_BAUDRATE_125K = (UInt32)TPCANBaudrate::PCAN_BAUD_125K, /// /// Channel Baudrate 100 kBit/s /// PCANTP_BAUDRATE_100K = (UInt32)TPCANBaudrate::PCAN_BAUD_100K, /// /// Channel Baudrate 95,238 kBit/s /// PCANTP_BAUDRATE_95K = (UInt32)TPCANBaudrate::PCAN_BAUD_95K, /// /// Channel Baudrate 83,333 kBit/s /// PCANTP_BAUDRATE_83K = (UInt32)TPCANBaudrate::PCAN_BAUD_83K, /// /// Channel Baudrate 50 kBit/s /// PCANTP_BAUDRATE_50K = (UInt32)TPCANBaudrate::PCAN_BAUD_50K, /// /// Channel Baudrate 47,619 kBit/s /// PCANTP_BAUDRATE_47K = (UInt32)TPCANBaudrate::PCAN_BAUD_47K, /// /// Channel Baudrate 33,333 kBit/s /// PCANTP_BAUDRATE_33K = (UInt32)TPCANBaudrate::PCAN_BAUD_33K, /// /// Channel Baudrate 20 kBit/s /// PCANTP_BAUDRATE_20K = (UInt32)TPCANBaudrate::PCAN_BAUD_20K, /// /// Channel Baudrate 10 kBit/s /// PCANTP_BAUDRATE_10K = (UInt32)TPCANBaudrate::PCAN_BAUD_10K, /// /// Channel Baudrate 5 kBit/s /// PCANTP_BAUDRATE_5K = (UInt32)TPCANBaudrate::PCAN_BAUD_5K, }; /// /// Type of PCAN (non plug-n-play) hardware /// public enum cantp_hwtype : UInt32 { /// /// PCAN-ISA 82C200 /// PCANTP_HWTYPE_ISA = (UInt32)TPCANType::PCAN_TYPE_ISA, /// /// PCAN-ISA SJA1000 /// PCANTP_HWTYPE_ISA_SJA = (UInt32)TPCANType::PCAN_TYPE_ISA_SJA, /// /// PHYTEC ISA /// PCANTP_HWTYPE_ISA_PHYTEC = (UInt32)TPCANType::PCAN_TYPE_ISA_PHYTEC, /// /// PCAN-Dongle 82C200 /// PCANTP_HWTYPE_DNG = (UInt32)TPCANType::PCAN_TYPE_DNG, /// /// PCAN-Dongle EPP 82C200 /// PCANTP_HWTYPE_DNG_EPP = (UInt32)TPCANType::PCAN_TYPE_DNG_EPP, /// /// PCAN-Dongle SJA1000 /// PCANTP_HWTYPE_DNG_SJA = (UInt32)TPCANType::PCAN_TYPE_DNG_SJA, /// /// PCAN-Dongle EPP SJA1000 /// PCANTP_HWTYPE_DNG_SJA_EPP = (UInt32)TPCANType::PCAN_TYPE_DNG_SJA_EPP, }; /// /// PCAN devices /// public enum cantp_device : UInt32 { /// /// Undefined, unknown or not selected PCAN device value /// PCANTP_DEVICE_NONE = (UInt32)TPCANDevice::PCAN_NONE, /// /// PCAN Non-Plug&Play devices. NOT USED WITHIN PCAN-Basic API /// PCANTP_DEVICE_PEAKCAN = (UInt32)TPCANDevice::PCAN_PEAKCAN, /// /// PCAN-ISA, PCAN-PC/104, and PCAN-PC/104-Plus /// PCANTP_DEVICE_ISA = (UInt32)TPCANDevice::PCAN_ISA, /// /// PCAN-Dongle /// PCANTP_DEVICE_DNG = (UInt32)TPCANDevice::PCAN_DNG, /// /// PCAN-PCI, PCAN-cPCI, PCAN-miniPCI, and PCAN-PCI Express /// PCANTP_DEVICE_PCI = (UInt32)TPCANDevice::PCAN_PCI, /// /// PCAN-USB and PCAN-USB Pro /// PCANTP_DEVICE_USB = (UInt32)TPCANDevice::PCAN_USB, /// /// PCAN-PC Card /// PCANTP_DEVICE_PCC = (UInt32)TPCANDevice::PCAN_PCC, /// /// PCAN Virtual hardware. NOT USED WITHIN PCAN-Basic API /// PCANTP_DEVICE_VIRTUAL = (UInt32)TPCANDevice::PCAN_VIRTUAL, /// /// PCAN Gateway devices /// PCANTP_DEVICE_LAN = (UInt32)TPCANDevice::PCAN_LAN, }; //////////////////////////////////////////////////////////// // Enums definition for ISO-TP API //////////////////////////////////////////////////////////// /// /// Represents each group of errors a status can hold /// public enum cantp_statustype : UInt32 { /// /// no error /// PCANTP_STATUSTYPE_OK = 0x00, /// /// general error /// PCANTP_STATUSTYPE_ERR = 0x01, /// /// bus status /// PCANTP_STATUSTYPE_BUS = 0x02, /// /// network status /// PCANTP_STATUSTYPE_NET = 0x04, /// /// extra information /// PCANTP_STATUSTYPE_INFO = 0x08, /// /// encapsulated PCAN-Basic status /// PCANTP_STATUSTYPE_PCAN = 0x10, }; /// /// Represents the network result of the communication of an ISO-TP message (used in cantp_status). /// public enum cantp_netstatus : UInt32 { // ISO-TP network errors: /// /// No network error /// PCANTP_NETSTATUS_OK = 0x00, /// /// timeout occured between 2 frames transmission (sender and receiver side) /// PCANTP_NETSTATUS_TIMEOUT_A = 0x01, /// /// sender side timeout while waiting for flow control frame /// PCANTP_NETSTATUS_TIMEOUT_Bs = 0x02, /// /// receiver side timeout while waiting for consecutive frame /// PCANTP_NETSTATUS_TIMEOUT_Cr = 0x03, /// /// unexpected sequence number /// PCANTP_NETSTATUS_WRONG_SN = 0x04, /// /// invalid or unknown FlowStatus /// PCANTP_NETSTATUS_INVALID_FS = 0x05, /// /// unexpected protocol data unit /// PCANTP_NETSTATUS_UNEXP_PDU = 0x06, /// /// reception of flow control WAIT frame that exceeds the maximum counter defined by PCANTP_PARAMETER_WFT_MAX /// PCANTP_NETSTATUS_WFT_OVRN = 0x07, /// /// buffer on the receiver side cannot store the data length (server side only) /// PCANTP_NETSTATUS_BUFFER_OVFLW = 0x08, /// /// general error /// PCANTP_NETSTATUS_ERROR = 0x09, /// /// message was invalid and ignored /// PCANTP_NETSTATUS_IGNORED = 0x0A, /// /// sender side timeout while transmitting /// PCANTP_NETSTATUS_TIMEOUT_As = 0x0B, /// /// receiver side timeout while transmitting /// PCANTP_NETSTATUS_TIMEOUT_Ar = 0x0C, // NON ISO-TP related network results: /// /// transmit queue is full (failed too many times) /// PCANTP_NETSTATUS_XMT_FULL = 0x0D, /// /// CAN bus error /// PCANTP_NETSTATUS_BUS_ERROR = 0x0E, /// /// memory allocation error /// PCANTP_NETSTATUS_NO_MEMORY = 0x0F, }; /// /// Represents the status of a CAN bus (used in cantp_status). /// public enum cantp_busstatus : UInt32 { /// /// Bus is in active state /// PCANTP_BUSSTATUS_OK = 0x00, /// /// Bus error: an error counter reached the 'light' limit /// PCANTP_BUSSTATUS_LIGHT = 0x01, /// /// Bus error: an error counter reached the 'heavy' limit /// PCANTP_BUSSTATUS_HEAVY = 0x02, /// /// Bus error: an error counter reached the 'warning/heavy' limit /// PCANTP_BUSSTATUS_WARNING = PCANTP_BUSSTATUS_HEAVY, /// /// Bus error: the CAN controller is error passive /// PCANTP_BUSSTATUS_PASSIVE = 0x04, /// /// Bus error: the CAN controller is in bus-off state /// PCANTP_BUSSTATUS_OFF = 0x08, /// /// Mask for all bus errors /// PCANTP_BUSSTATUS_ANY = PCANTP_BUSSTATUS_LIGHT | PCANTP_BUSSTATUS_HEAVY | PCANTP_BUSSTATUS_WARNING | PCANTP_BUSSTATUS_PASSIVE | PCANTP_BUSSTATUS_OFF, }; /// /// Represents an general error (used in cantp_status). /// public enum cantp_errstatus : UInt32 { /// /// No error /// PCANTP_ERRSTATUS_OK = 0x00, /// /// Not Initialized /// PCANTP_ERRSTATUS_NOT_INITIALIZED = 0x01, /// /// Already Initialized /// PCANTP_ERRSTATUS_ALREADY_INITIALIZED = 0x02, /// /// Could not obtain memory /// PCANTP_ERRSTATUS_NO_MEMORY = 0x03, /// /// Input buffer overflow /// PCANTP_ERRSTATUS_OVERFLOW = 0x04, /// /// No Message available /// PCANTP_ERRSTATUS_NO_MESSAGE = 0x07, /// /// Parameter has an invalid or unexpected type /// PCANTP_ERRSTATUS_PARAM_INVALID_TYPE = 0x08, /// /// Parameter has an invalid value /// PCANTP_ERRSTATUS_PARAM_INVALID_VALUE = 0x09, /// /// PCANTP mapping not initialized /// PCANTP_ERRSTATUS_MAPPING_NOT_INITIALIZED = 0x0D, /// /// PCANTP mapping parameters are invalid /// PCANTP_ERRSTATUS_MAPPING_INVALID = 0x0E, /// /// PCANTP mapping already defined /// PCANTP_ERRSTATUS_MAPPING_ALREADY_INITIALIZED = 0x0F, /// /// /// PCANTP_ERRSTATUS_PARAM_BUFFER_TOO_SMALL = 0x10, /// /// Tx queue is full /// PCANTP_ERRSTATUS_QUEUE_TX_FULL = 0x11, /// /// Failed to get an access to the internal lock /// PCANTP_ERRSTATUS_LOCK_TIMEOUT = 0x12, /// /// Invalid cantp_handle /// PCANTP_ERRSTATUS_INVALID_HANDLE = 0x13, /// /// unknown/generic error /// PCANTP_ERRSTATUS_UNKNOWN = 0xFF, }; /// /// Represents additional status information (used in cantp_status). /// public enum cantp_infostatus : UInt32 { /// /// no extra information /// PCANTP_INFOSTATUS_OK = 0x00, /// /// input was modified by the API /// PCANTP_INFOSTATUS_CAUTION_INPUT_MODIFIED = 0x01, /// /// DLC value was modified by the API /// PCANTP_INFOSTATUS_CAUTION_DLC_MODIFIED = 0x02, /// /// Data Length value was modified by the API /// PCANTP_INFOSTATUS_CAUTION_DATA_LENGTH_MODIFIED = 0x04, /// /// FD related flags value were modified by the API /// PCANTP_INFOSTATUS_CAUTION_FD_FLAG_MODIFIED = 0x08, /// /// Message receive queue is full (oldest messages may be lost) /// PCANTP_INFOSTATUS_CAUTION_RX_QUEUE_FULL = 0x10, /// /// Buffer is used by another thread or API /// PCANTP_INFOSTATUS_CAUTION_BUFFER_IN_USE = 0x20, /// /// Internal queue read too late (a frame was lost) /// PCANTP_INFOSTATUS_CAUTION_RX_QUEUE_OVERRUN = 0x30, }; /// /// Defines constants used by the next enum: cantp_status /// public enum cantp_status_offset : Byte { PCANTP_STATUS_OFFSET_BUS = 8, PCANTP_STATUS_OFFSET_NET = (PCANTP_STATUS_OFFSET_BUS + 5), PCANTP_STATUS_OFFSET_INFO = (PCANTP_STATUS_OFFSET_NET + 5), }; /// /// Represent the PCANTP error and status codes . /// /// Bits information: /// 32| 28| 24| 20| 16| 12| 8| 4| 0| /// | | | | | | | | | /// 0000 0000 0000 0000 0000 0000 0000 0000 /// | | | | | [0000 0000] => PCAN-ISO-TP API errors /// | | | | | [0 0000] => CAN Bus status /// | | | | [00 000] => Networking message status /// | | [0000 00] => API extra information /// |[000 0000] => Reserved /// [0] => PCANBasic error flag (overrides the meaning of all bits) /// public enum cantp_status : UInt32 { PCANTP_STATUS_OK = cantp_errstatus::PCANTP_ERRSTATUS_OK, PCANTP_STATUS_NOT_INITIALIZED = cantp_errstatus::PCANTP_ERRSTATUS_NOT_INITIALIZED, PCANTP_STATUS_ALREADY_INITIALIZED = cantp_errstatus::PCANTP_ERRSTATUS_ALREADY_INITIALIZED, PCANTP_STATUS_NO_MEMORY = cantp_errstatus::PCANTP_ERRSTATUS_NO_MEMORY, PCANTP_STATUS_OVERFLOW = cantp_errstatus::PCANTP_ERRSTATUS_OVERFLOW, PCANTP_STATUS_NO_MESSAGE = cantp_errstatus::PCANTP_ERRSTATUS_NO_MESSAGE, PCANTP_STATUS_PARAM_INVALID_TYPE = cantp_errstatus::PCANTP_ERRSTATUS_PARAM_INVALID_TYPE, PCANTP_STATUS_PARAM_INVALID_VALUE = cantp_errstatus::PCANTP_ERRSTATUS_PARAM_INVALID_VALUE, PCANTP_STATUS_MAPPING_NOT_INITIALIZED = cantp_errstatus::PCANTP_ERRSTATUS_MAPPING_NOT_INITIALIZED, PCANTP_STATUS_MAPPING_INVALID = cantp_errstatus::PCANTP_ERRSTATUS_MAPPING_INVALID, PCANTP_STATUS_MAPPING_ALREADY_INITIALIZED = cantp_errstatus::PCANTP_ERRSTATUS_MAPPING_ALREADY_INITIALIZED, PCANTP_STATUS_PARAM_BUFFER_TOO_SMALL = cantp_errstatus::PCANTP_ERRSTATUS_PARAM_BUFFER_TOO_SMALL, PCANTP_STATUS_QUEUE_TX_FULL = cantp_errstatus::PCANTP_ERRSTATUS_QUEUE_TX_FULL, PCANTP_STATUS_LOCK_TIMEOUT = cantp_errstatus::PCANTP_ERRSTATUS_LOCK_TIMEOUT, PCANTP_STATUS_HANDLE_INVALID = cantp_errstatus::PCANTP_ERRSTATUS_INVALID_HANDLE, PCANTP_STATUS_UNKNOWN = cantp_errstatus::PCANTP_ERRSTATUS_UNKNOWN, #pragma region Bus status flags(bits[8..11]) /// /// PCANTP Channel is in BUS-LIGHT error state /// PCANTP_STATUS_FLAG_BUS_LIGHT = (cantp_busstatus::PCANTP_BUSSTATUS_LIGHT << cantp_status_offset::PCANTP_STATUS_OFFSET_BUS), /// /// PCANTP Channel is in BUS-HEAVY error state /// PCANTP_STATUS_FLAG_BUS_HEAVY = (cantp_busstatus::PCANTP_BUSSTATUS_HEAVY << cantp_status_offset::PCANTP_STATUS_OFFSET_BUS), /// /// PCANTP Channel is in BUS-HEAVY error state /// PCANTP_STATUS_FLAG_BUS_WARNING = PCANTP_STATUS_FLAG_BUS_HEAVY, /// /// PCANTP Channel is error passive state /// PCANTP_STATUS_FLAG_BUS_PASSIVE = (cantp_busstatus::PCANTP_BUSSTATUS_PASSIVE << cantp_status_offset::PCANTP_STATUS_OFFSET_BUS), /// /// PCANTP Channel is in BUS-OFF error state /// PCANTP_STATUS_FLAG_BUS_OFF = (cantp_busstatus::PCANTP_BUSSTATUS_OFF << cantp_status_offset::PCANTP_STATUS_OFFSET_BUS), /// /// /// PCANTP_STATUS_FLAG_BUS_ANY = (cantp_busstatus::PCANTP_BUSSTATUS_ANY << cantp_status_offset::PCANTP_STATUS_OFFSET_BUS), #pragma endregion #pragma region Network status(bits[13..17]) /// /// This flag states if one of the following network errors occured with the fetched message /// PCANTP_STATUS_FLAG_NETWORK_RESULT = (1 << cantp_status_offset::PCANTP_STATUS_OFFSET_NET), /// /// timeout occured between 2 frames transmission (sender and receiver side) /// PCANTP_STATUS_NETWORK_TIMEOUT_A = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_TIMEOUT_A << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// sender side timeout while waiting for flow control frame /// PCANTP_STATUS_NETWORK_TIMEOUT_Bs = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_TIMEOUT_Bs << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// receiver side timeout while waiting for consecutive frame /// PCANTP_STATUS_NETWORK_TIMEOUT_Cr = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_TIMEOUT_Cr << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// unexpected sequence number /// PCANTP_STATUS_NETWORK_WRONG_SN = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_WRONG_SN << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// invalid or unknown FlowStatus /// PCANTP_STATUS_NETWORK_INVALID_FS = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_INVALID_FS << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// unexpected protocol data unit /// PCANTP_STATUS_NETWORK_UNEXP_PDU = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_UNEXP_PDU << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// reception of flow control WAIT frame that exceeds the maximum counter defined by PCANTP_PARAMETER_WFT_MAX /// PCANTP_STATUS_NETWORK_WFT_OVRN = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_WFT_OVRN << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// buffer on the receiver side cannot store the data length (server side only) /// PCANTP_STATUS_NETWORK_BUFFER_OVFLW = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_BUFFER_OVFLW << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// general error /// PCANTP_STATUS_NETWORK_ERROR = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_ERROR << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// message was invalid and ignored /// PCANTP_STATUS_NETWORK_IGNORED = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (cantp_netstatus::PCANTP_NETSTATUS_IGNORED << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), #pragma endregion #pragma region ISO - TP extra information flags /// /// Receiver side timeout while transmitting /// PCANTP_STATUS_NETWORK_TIMEOUT_Ar = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (PCANTP_NETSTATUS_TIMEOUT_Ar << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// Sender side timeout while transmitting /// PCANTP_STATUS_NETWORK_TIMEOUT_As = (PCANTP_STATUS_FLAG_NETWORK_RESULT | (PCANTP_NETSTATUS_TIMEOUT_As << (cantp_status_offset::PCANTP_STATUS_OFFSET_NET + 1))), /// /// input was modified /// PCANTP_STATUS_CAUTION_INPUT_MODIFIED = (cantp_infostatus::PCANTP_INFOSTATUS_CAUTION_INPUT_MODIFIED << cantp_status_offset::PCANTP_STATUS_OFFSET_INFO), /// /// DLC value of the input was modified /// PCANTP_STATUS_CAUTION_DLC_MODIFIED = (cantp_infostatus::PCANTP_INFOSTATUS_CAUTION_DLC_MODIFIED << cantp_status_offset::PCANTP_STATUS_OFFSET_INFO), /// /// Data Length value of the input was modified /// PCANTP_STATUS_CAUTION_DATA_LENGTH_MODIFIED = (cantp_infostatus::PCANTP_INFOSTATUS_CAUTION_DATA_LENGTH_MODIFIED << cantp_status_offset::PCANTP_STATUS_OFFSET_INFO), /// /// FD flags of the input was modified /// PCANTP_STATUS_CAUTION_FD_FLAG_MODIFIED = (cantp_infostatus::PCANTP_INFOSTATUS_CAUTION_FD_FLAG_MODIFIED << cantp_status_offset::PCANTP_STATUS_OFFSET_INFO), /// /// Receive queue is full /// PCANTP_STATUS_CAUTION_RX_QUEUE_FULL = (cantp_infostatus::PCANTP_INFOSTATUS_CAUTION_RX_QUEUE_FULL << cantp_status_offset::PCANTP_STATUS_OFFSET_INFO), /// /// Buffer is used by another thread or API /// PCANTP_STATUS_CAUTION_BUFFER_IN_USE = (cantp_infostatus::PCANTP_INFOSTATUS_CAUTION_BUFFER_IN_USE << cantp_status_offset::PCANTP_STATUS_OFFSET_INFO), /// /// Internal queue read too late (a frame was lost) /// PCANTP_STATUS_CAUTION_RX_QUEUE_OVERRUN = (cantp_infostatus::PCANTP_INFOSTATUS_CAUTION_RX_QUEUE_OVERRUN << cantp_status_offset::PCANTP_STATUS_OFFSET_INFO), #pragma endregion #pragma region Lower API status code : see also PCANTP_STATUS_xx macros /// /// PCAN error flag, remove flag to get a usable PCAN error/status code (cf. PCANBasic API) /// PCANTP_STATUS_FLAG_PCAN_STATUS = 0x80000000U, #pragma endregion #pragma region Masks to merge / retrieve different PCANTP status by type in a cantp_status /// /// filter by PCANTP_STATUSTYPE_ERR type /// PCANTP_STATUS_MASK_ERROR = 0x000000FFU, /// /// filter by PCANTP_STATUSTYPE_BUS type /// PCANTP_STATUS_MASK_BUS = 0x00001F00U, /// /// filter by PCANTP_STATUSTYPE_NET type /// PCANTP_STATUS_MASK_ISOTP_NET = 0x0003E000U, /// /// filter by PCANTP_STATUSTYPE_INFO type /// PCANTP_STATUS_MASK_INFO = 0x00FC0000U, /// /// filter by PCANTP_STATUSTYPE_PCAN type /// PCANTP_STATUS_MASK_PCAN = ~PCANTP_STATUS_FLAG_PCAN_STATUS, #pragma endregion }; /// /// List of parameters handled by PCAN-ISO-TP (rev. 2016) /// Note: PCAN-Basic parameters (PCAN_PARAM_xxx) are compatible via casting. /// public enum cantp_parameter : UInt32 { /// /// PCAN-ISO-TP API version parameter /// PCANTP_PARAMETER_API_VERSION = 0x101, /// /// 1 BYTE data describing the condition of a channel. /// PCANTP_PARAMETER_CHANNEL_CONDITION = 0x102, /// /// 1 BYTE data describing the debug mode /// PCANTP_PARAMETER_DEBUG = 0x103, /// /// data is pointer to a HANDLE created by CreateEvent function /// PCANTP_PARAMETER_RECEIVE_EVENT = 0x104, /// /// 1 BYTE data stating if unsegmented (NON-ISO-TP) CAN frames can be received /// PCANTP_PARAMETER_FRAME_FILTERING = 0x105, /// /// 1 BYTE data stating the default DLC to use when transmitting messages with CAN FD /// PCANTP_PARAMETER_CAN_TX_DL = 0x106, /// /// 1 BYTE data stating if CAN frame DLC uses padding or not /// PCANTP_PARAMETER_CAN_DATA_PADDING = 0x107, /// /// 1 BYTE data stating the value used for CAN data padding /// PCANTP_PARAMETER_CAN_PADDING_VALUE = 0x108, /// /// 1 BYTE data stating which revision of ISO 15765-2 to use (see PCANTP_ISO_REV_*). /// PCANTP_PARAMETER_ISO_REV = 0x109, /// /// 1 BYTE data stating the default priority value for normal fixed, mixed and enhanced addressing (default=6) /// PCANTP_PARAMETER_J1939_PRIORITY = 0x10A, /// /// 1 BYTE data stating if pending messages are displayed/hidden /// PCANTP_PARAMETER_MSG_PENDING = 0x10B, /// /// 1 BYTE data describing the block size parameter (BS) /// PCANTP_PARAMETER_BLOCK_SIZE = 0x10C, /// /// 2 BYTE data describing the transmit block size parameter (BS_TX) /// PCANTP_PARAMETER_BLOCK_SIZE_TX = 0x10D, /// /// 1 BYTE data describing the seperation time parameter (STmin) /// PCANTP_PARAMETER_SEPARATION_TIME = 0x10E, /// /// 2 BYTE data describing the transmit seperation time parameter (STmin_TX) /// PCANTP_PARAMETER_SEPARATION_TIME_TX = 0x10F, /// /// 4 BYTE data describing the Wait Frame Transmissions parameter. /// PCANTP_PARAMETER_WFT_MAX = 0x110, /// /// 4 BYTE data describing ISO-15765-2:Timeout As. /// PCANTP_PARAMETER_TIMEOUT_AS = 0x111, /// /// 4 BYTE data describing ISO-15765-2:Timeout Ar. /// PCANTP_PARAMETER_TIMEOUT_AR = 0x112, /// /// 4 BYTE data describing ISO-15765-2:Timeout Bs. /// PCANTP_PARAMETER_TIMEOUT_BS = 0x113, /// /// 4 BYTE data describing ISO-15765-2:Timeout Cr. /// PCANTP_PARAMETER_TIMEOUT_CR = 0x114, /// /// 1 BYTE data describing the tolerence to apply to all timeout as a percentage ([0..100]. /// PCANTP_PARAMETER_TIMEOUT_TOLERANCE = 0x115, /// /// 1 BYTE data to set predefined ISO values for timeouts (see PCANTP_ISO_TIMEOUTS_*). /// PCANTP_PARAMETER_ISO_TIMEOUTS = 0x116, /// /// 1 BYTE data to set optimization options to improve delay between ISO-TP consecutive frames. /// PCANTP_PARAMETER_SELFRECEIVE_LATENCY = 0x117, /// /// 2 BYTE data describing the maximum number of messages in the Rx queue. /// PCANTP_PARAMETER_MAX_RX_QUEUE = 0x118, /// /// 1 BYTE data stating if messages handled by higher layer APIs are still available in this API (default=0). /// PCANTP_PARAMETER_KEEP_HIGHER_LAYER_MESSAGES = 0x119, /// /// 1 BYTE data stating if the white-list CAN IDs filtering mechanism is enabled. /// PCANTP_PARAMETER_FILTER_CAN_ID = 0x11A, /// /// 1 BYTE data stating if the 29 bit Enhanced Diagnostic CAN identifier is supported (ISO-15765-3:2004, default is false with ISO revision 2016). /// PCANTP_PARAMETER_SUPPORT_29B_ENHANCED = 0x11B, /// /// 1 BYTE data stating if the 29 bit Fixed Normal addressing CAN identifier is supported (default is true). /// PCANTP_PARAMETER_SUPPORT_29B_FIXED_NORMAL = 0x11C, /// /// 1 BYTE data stating if the 29 bit Mixed addressing CAN identifier is supported (default is true). /// PCANTP_PARAMETER_SUPPORT_29B_MIXED = 0x11D, /// /// Pointer to a cantp_msg, checks if the message is valid and can be sent (ex. if a mapping is needed) and corrects input if needed. /// PCANTP_PARAMETER_MSG_CHECK = 0x11E, /// /// 1 BYTE data stating to clear Rx/Tx queues and CAN controller (channel is unitialized and re-initialized but settings and mappings are kept) /// PCANTP_PARAMETER_RESET_HARD = 0x11F, /// /// 1 BYTE data stating if network is full-duplex (default) or half-duplex /// PCANTP_PARAMETER_NETWORK_LAYER_DESIGN = 0x120, /// /// 1 BYTE data stating if API allows receiption PCANTP_MSGTYPE_CANINFO from lower layer APIs /// PCANTP_PARAMETER_ALLOW_MSGTYPE_CANINFO = 0x124, /// /// Data is a pointer to a user-defined callback triggered when a message is received. /// PCANTP_PARAMETER_RECEIVE_EVENT_CALLBACK = 0x125, /// /// Data is a pointer to a user-defined structure. It can be used to pass user arguments to the reception callback function. /// PCANTP_PARAMETER_RECEIVE_EVENT_CALLBACK_USER_CONTEXT = 0x126, /// /// PCAN hardware name parameter /// PCANTP_PARAMETER_HARDWARE_NAME = (UInt32)TPCANParameter::PCAN_HARDWARE_NAME, /// /// PCAN-USB device identifier parameter /// PCANTP_PARAMETER_DEVICE_ID = (UInt32)TPCANParameter::PCAN_DEVICE_NUMBER, /// /// Deprecated use PCANTP_PARAMETER_DEVICE_ID instead /// PCANTP_PARAMETER_DEVICE_NUMBER = (UInt32)TPCANParameter::PCAN_DEVICE_NUMBER, /// /// CAN-Controller number of a PCAN-Channel /// PCANTP_PARAMETER_CONTROLLER_NUMBER = (UInt32)TPCANParameter::PCAN_CONTROLLER_NUMBER, /// /// Capabilities of a PCAN device (FEATURE_***) /// PCANTP_PARAMETER_CHANNEL_FEATURES = (UInt32)TPCANParameter::PCAN_CHANNEL_FEATURES }; /// /// Represents the type of a CANTP message (see field "cantp_msg.type"). /// public enum cantp_msgtype : UInt32 { /// /// uninitialized message (data is NULL) /// PCANTP_MSGTYPE_NONE = 0, /// /// standard CAN frame /// PCANTP_MSGTYPE_CAN = 1, /// /// CAN frame with FD support /// PCANTP_MSGTYPE_CANFD = 2, /// /// ISO-TP message (ISO:15765) /// PCANTP_MSGTYPE_ISOTP = 4, /// /// CAN bus information /// PCANTP_MSGTYPE_CANINFO = 8, /// /// frame only: unsegmented messages /// PCANTP_MSGTYPE_FRAME = PCANTP_MSGTYPE_CAN | PCANTP_MSGTYPE_CANFD, /// /// any supported message type /// PCANTP_MSGTYPE_ANY = PCANTP_MSGTYPE_FRAME | PCANTP_MSGTYPE_ISOTP | 0xFFFFFFFF }; /// /// Represents the flags common to all types of cantp_msg (see field "cantp_msg.msgdata.flags"). /// public enum cantp_msgflag : UInt32 { /// /// no flag /// PCANTP_MSGFLAG_NONE = 0, /// /// message is the confirmation of a transmitted message /// PCANTP_MSGFLAG_LOOPBACK = 1, /// /// message is a frame of a segmented ISO-TP message /// PCANTP_MSGFLAG_ISOTP_FRAME = 2, }; /// /// Represents the flags of a CAN or CAN FD frame (must be used as flags for ex. EXTENDED|FD|BRS.) (see field "cantp_msg.can_info.can_msgtype") /// public enum cantp_can_msgtype : UInt32 { /// /// The PCAN message is a CAN Standard Frame (11-bit identifier) /// PCANTP_CAN_MSGTYPE_STANDARD = (UInt32)TPCANMessageType::PCAN_MESSAGE_STANDARD, /// /// The PCAN message is a CAN Remote-Transfer-Request Frame /// PCANTP_CAN_MSGTYPE_RTR = (UInt32)TPCANMessageType::PCAN_MESSAGE_RTR, /// /// The PCAN message is a CAN Extended Frame (29-bit identifier) /// PCANTP_CAN_MSGTYPE_EXTENDED = (UInt32)TPCANMessageType::PCAN_MESSAGE_EXTENDED, /// /// The PCAN message represents a FD frame in terms of CiA Specs /// PCANTP_CAN_MSGTYPE_FD = (UInt32)TPCANMessageType::PCAN_MESSAGE_FD, /// /// The PCAN message represents a FD bit rate switch (CAN data at a higher bit rate) /// PCANTP_CAN_MSGTYPE_BRS = (UInt32)TPCANMessageType::PCAN_MESSAGE_BRS, /// /// The PCAN message represents a FD error state indicator(CAN FD transmitter was error active) /// PCANTP_CAN_MSGTYPE_ESI = (UInt32)TPCANMessageType::PCAN_MESSAGE_ESI, /// /// The PCAN message represents an error frame. /// PCANTP_CAN_MSGTYPE_ERRFRAME = (UInt32)TPCANMessageType::PCAN_MESSAGE_ERRFRAME, /// /// The PCAN message represents a PCAN status message. /// PCANTP_CAN_MSGTYPE_STATUS = (UInt32)TPCANMessageType::PCAN_MESSAGE_STATUS, /// /// Echo messages reception status within a PCAN-Channel /// PCANTP_CAN_MSGTYPE_ECHO = (UInt32)TPCANMessageType::PCAN_MESSAGE_ECHO, /// /// Flag stating that the message is not a CAN Frame /// PCANTP_CAN_MSGTYPE_FLAG_INFO = ((UInt32)TPCANMessageType::PCAN_MESSAGE_ERRFRAME | (UInt32)TPCANMessageType::PCAN_MESSAGE_STATUS) }; /// /// Represents the type of an ISO-TP message (see field "cantp_msg.msgdata.isotp.netaddrinfo.msgtype"). /// public enum cantp_isotp_msgtype : UInt32 { /// /// Unknown (non-ISO-TP) message /// PCANTP_ISOTP_MSGTYPE_UNKNOWN = 0x00, /// /// Diagnostic message (request or confirmation) /// PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC = 0x01, /// /// Remote Diagnostic message (request or confirmation) /// PCANTP_ISOTP_MSGTYPE_REMOTE_DIAGNOSTIC = 0x02, /// /// Multi-Frame Message is being received /// PCANTP_ISOTP_MSGTYPE_FLAG_INDICATION_RX = 0x10, /// /// Multi-Frame Message is being transmitted /// PCANTP_ISOTP_MSGTYPE_FLAG_INDICATION_TX = 0x20, /// /// Multi-Frame Message is being communicated (Tx or Rx) /// PCANTP_ISOTP_MSGTYPE_FLAG_INDICATION = (0x10 | 0x20), /// /// Mask to remove Indication flags /// PCANTP_ISOTP_MSGTYPE_MASK_INDICATION = 0x0F }; /// /// Represents the addressing format of an ISO-TP message (see field "cantp_msg.msgdata.isotp.netaddrinfo.format"). /// public enum cantp_isotp_format : UInt32 { /// /// unknown adressing format /// PCANTP_ISOTP_FORMAT_UNKNOWN = 0xFF, /// /// unsegmented CAN frame /// PCANTP_ISOTP_FORMAT_NONE = 0x00, /// /// normal adressing format from ISO 15765-2 /// PCANTP_ISOTP_FORMAT_NORMAL = 0x01, /// /// fixed normal adressing format from ISO 15765-2 /// PCANTP_ISOTP_FORMAT_FIXED_NORMAL = 0x02, /// /// extended adressing format from ISO 15765-2 /// PCANTP_ISOTP_FORMAT_EXTENDED = 0x03, /// /// mixed adressing format from ISO 15765-2 /// PCANTP_ISOTP_FORMAT_MIXED = 0x04, /// /// enhanced adressing format from ISO 15765-3 /// PCANTP_ISOTP_FORMAT_ENHANCED = 0x05, }; /// /// Represents the type of target of an ISO-TP message (see field "cantp_msg.msgdata.isotp.netaddrinfo.target_type"). /// public enum cantp_isotp_addressing : UInt32 { /// /// Unknown adressing format /// PCANTP_ISOTP_ADDRESSING_UNKNOWN = 0x00, /// /// Physical addressing ("peer to peer") /// PCANTP_ISOTP_ADDRESSING_PHYSICAL = 0x01, /// /// Functional addressing ("peer to any") /// PCANTP_ISOTP_ADDRESSING_FUNCTIONAL = 0x02, }; /// /// Represents the options of a message (mainly supported for ISO-TP message) (see field "cantp_msg.msgdata.options"). /// public enum cantp_option : UInt32 { /// /// 1 BYTE data stating if unsegmented (NON-ISO-TP) CAN frames can be received /// PCANTP_OPTION_FRAME_FILTERING = cantp_parameter::PCANTP_PARAMETER_FRAME_FILTERING, /// /// 1 BYTE data stating if CAN frame DLC uses padding or not /// PCANTP_OPTION_CAN_DATA_PADDING = cantp_parameter::PCANTP_PARAMETER_CAN_DATA_PADDING, /// /// 1 BYTE data stating the value used for CAN data padding /// PCANTP_OPTION_CAN_PADDING_VALUE = cantp_parameter::PCANTP_PARAMETER_CAN_PADDING_VALUE, /// /// 1 BYTE data stating the default priority value for normal fixed, mixed and enhanced addressing (default=6) /// PCANTP_OPTION_J1939_PRIORITY = cantp_parameter::PCANTP_PARAMETER_J1939_PRIORITY, /// /// 1 BYTE data stating if pending messages are displayed/hidden /// PCANTP_OPTION_MSG_PENDING = cantp_parameter::PCANTP_PARAMETER_MSG_PENDING, /// /// 1 BYTE data describing the block size parameter (BS) /// PCANTP_OPTION_BLOCK_SIZE = cantp_parameter::PCANTP_PARAMETER_BLOCK_SIZE, /// /// 2 BYTE data describing the transmit block size parameter (BS_TX) /// PCANTP_OPTION_BLOCK_SIZE_TX = cantp_parameter::PCANTP_PARAMETER_BLOCK_SIZE_TX, /// /// 1 BYTE data describing the seperation time parameter (STmin) /// PCANTP_OPTION_SEPARATION_TIME = cantp_parameter::PCANTP_PARAMETER_SEPARATION_TIME, /// /// 2 BYTE data describing the transmit seperation time parameter (STmin_TX) /// PCANTP_OPTION_SEPARATION_TIME_TX = cantp_parameter::PCANTP_PARAMETER_SEPARATION_TIME_TX, /// /// 4 BYTE data describing the Wait Frame Transmissions parameter.µ /// PCANTP_OPTION_WFT_MAX = cantp_parameter::PCANTP_PARAMETER_WFT_MAX, /// /// 1 BYTE data to set optimization options to improve delay between ISO-TP consecutive frames. /// PCANTP_OPTION_SELFRECEIVE_LATENCY = cantp_parameter::PCANTP_PARAMETER_SELFRECEIVE_LATENCY }; /// /// Represents the status for a message whose transmission is in progress. /// public enum cantp_msgprogress_state : UInt32 { /// /// Message is not yet handled. /// PCANTP_MSGPROGRESS_STATE_QUEUED = 0, /// /// Message is being processed (received or transmitted). /// PCANTP_MSGPROGRESS_STATE_PROCESSING = 1, /// /// Message is completed. /// PCANTP_MSGPROGRESS_STATE_COMPLETED = 2, /// /// Message is unknown/not found. /// PCANTP_MSGPROGRESS_STATE_UNKNOWN = 3 }; /// /// Represents the direction of a message's communication. /// public enum cantp_msgdirection : UInt32 { /// /// Message is being received. /// PCANTP_MSGDIRECTION_RX = 0, /// /// Message is being transmitted. /// PCANTP_MSGDIRECTION_TX = 1, }; #pragma endregion #pragma region Structures //////////////////////////////////////////////////////////// // miscellaneous message related definitions //////////////////////////////////////////////////////////// /// /// Internal information about cantp_msg message (reserved). /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_msginfo { /// /// (read-only) size of the message object /// UInt32 size; /// /// (read-only) reserved /// cantp_msginfo_flag flags; /// /// (read-only) reserved /// cantp_msginfo_extra extra; }; /// /// Represents message's options to override. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_msgoption { /// /// Name of the option. /// [MarshalAs(UnmanagedType::U4)] cantp_option name; /// /// Value of the option. /// UInt32 value; }; /// /// Represents a list of message's options to override. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_msgoption_list { /// /// Pointer to an array of cantp_msgoption. /// cantp_msgoption *buffer; /// /// Number of options in the array. /// UInt32 count; }; /// /// Represents common CAN information. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_can_info { /// /// CAN identifier /// UInt32 can_id; /// /// Types and flags of the CAN/CAN-FD frame (see cantp_can_msgtype) /// [MarshalAs(UnmanagedType::U4)] cantp_can_msgtype can_msgtype; /// /// Data Length Code of the frame (0..15) /// Byte dlc; }; /// /// Represents the network address information of an ISO-TP message. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_netaddrinfo { /// /// ISO-TP message type /// [MarshalAs(UnmanagedType::U4)] cantp_isotp_msgtype msgtype; /// /// ISO-TP format addressing /// [MarshalAs(UnmanagedType::U4)] cantp_isotp_format format; /// /// ISO-TP addressing/target type /// [MarshalAs(UnmanagedType::U4)] cantp_isotp_addressing target_type; /// /// source address /// UInt16 source_addr; /// /// target address /// UInt16 target_addr; /// /// extension address /// Byte extension_addr; }; /// /// Represents a mapping between an ISO-TP network address information and a CAN ID. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_mapping { /// /// Mapping's unique ID /// UIntPtr uid; /// /// CAN ID mapped to the Network Address Information /// UInt32 can_id; /// /// CAN ID used for the flow control frame (formerly 'can_id_resp') /// UInt32 can_id_flow_ctrl; /// /// CAN frame msgtype (only PCANTP_CAN_MSGTYPE_STANDARD or PCANTP_CAN_MSGTYPE_EXTENDED is mandatory) /// [MarshalAs(UnmanagedType::U4)] cantp_can_msgtype can_msgtype; /// /// Default CAN DLC value to use with segmented messages /// Byte can_tx_dlc; /// /// ISO-TP Network Address Information /// cantp_netaddrinfo netaddrinfo; }; /// /// Represents a message rule for filtering. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_msgrule { /// /// Unique ID (read-only) /// UIntPtr uid; /// /// Type of the message /// [MarshalAs(UnmanagedType::U4)] cantp_msgtype type; /// /// common CAN information /// cantp_can_info can_info; /// /// ISO-TP network address information /// cantp_netaddrinfo netaddrinfo; /// /// specific options to override global CAN configuration /// cantp_msgoption_list options; /// /// reserved /// UIntPtr reserved; }; //////////////////////////////////////////////////////////// // Message definitions //////////////////////////////////////////////////////////// /// /// Represents the content of a generic message. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_msgdata { /// /// structure specific flags /// [MarshalAs(UnmanagedType::U4)] cantp_msgflag flags; /// /// Length of the message /// UInt32 length; /// /// Data of the message /// Byte *data; /// /// Network status /// [MarshalAs(UnmanagedType::U4)] cantp_netstatus netstatus; /// /// Defines specific options to override global message configuration /// cantp_msgoption_list *options; }; /// /// Represents the content of a standard CAN frame. /// public struct cantp_msgdata_can { /// /// structure specific flags /// [MarshalAs(UnmanagedType::U4)] cantp_msgflag flags; /// /// Length of the message (0..8) /// UInt32 length; /// /// Data of the message /// Byte *data; /// /// Network status /// [MarshalAs(UnmanagedType::U4)] cantp_netstatus netstatus; /// /// Defines specific options to override global CAN configuration (not used yet) /// cantp_msgoption_list *options; /// /// Data of the message (DATA[0]..DATA[7]) /// [MarshalAs(UnmanagedType::ByValArray, SizeConst = 8)] Byte data_max[]; }; /// /// Represents the content of a CAN FD frame. /// public struct cantp_msgdata_canfd { /// /// structure specific flags /// [MarshalAs(UnmanagedType::U4)] cantp_msgflag flags; /// /// Length of the message (0..64) /// UInt32 length; /// /// Data of the message /// Byte *data; /// /// Network status /// [MarshalAs(UnmanagedType::U4)] cantp_netstatus netstatus; /// /// Defines specific options to override global CAN configuration (not used yet) /// cantp_msgoption_list *options; /// /// Data of the message (DATA[0]..DATA[63]) /// [MarshalAs(UnmanagedType::ByValArray, SizeConst = 64)] Byte data_max[]; }; /// /// Represents the content of an ISO-TP message. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_msgdata_isotp { /// /// structure specific flags /// [MarshalAs(UnmanagedType::U4)] cantp_msgflag flags; /// /// Length of the data /// UInt32 length; /// /// Data of the message /// Byte *data; /// /// Network status /// [MarshalAs(UnmanagedType::U4)] cantp_netstatus netstatus; /// /// Defines specific options to override global CAN configuration (not used yet) /// cantp_msgoption_list *options; /// /// ISO-TP network address information /// cantp_netaddrinfo netaddrinfo; /// /// Reserved ISO-TP information /// cantp_isotp_info reserved; }; [StructLayout(LayoutKind::Explicit)] public value struct cantp_msg_union_msgdata { [FieldOffset(0)] cantp_msgdata *any; // shortcut to access msgdata as Generic content [FieldOffset(0)] cantp_msgdata_can *can; // shortcut to access msgdata as CAN content [FieldOffset(0)] cantp_msgdata_canfd *canfd; // shortcut to access msgdata as CAN-FD content [FieldOffset(0)] cantp_msgdata_isotp *isotp; // shortcut to access msgdata as ISO-TP content }; /// /// A cantp_msg message is a generic CAN related message than can be either a standard CAN frame, /// a CAN FD frame, an ISO-TP message, etc. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_msg { public: /// /// type of the message /// [MarshalAs(UnmanagedType::U4)] cantp_msgtype type; /// /// misc. read-only information /// cantp_msginfo reserved; /// /// common CAN information /// cantp_can_info can_info; cantp_msg_union_msgdata msgdata; }; /// /// Holds information on the communication progress of a message. /// [StructLayout(LayoutKind::Sequential, Pack = 8)] public value struct cantp_msgprogress { /// /// State of the message /// [MarshalAs(UnmanagedType::U4)] cantp_msgprogress_state state; /// /// Progress of the transmission/reception in percent. /// Byte percentage; /// /// pending message /// If this is not needed, set it to null. /// cantp_msg *buffer; }; #pragma endregion #pragma region operators // extra operator for cantp_statustype inline cantp_statustype operator| (cantp_statustype a, cantp_statustype b) { return static_cast(static_cast(a) | static_cast(b)); }; inline cantp_statustype& operator|= (cantp_statustype& a, cantp_statustype b) { return (a = (a | b)); }; inline cantp_statustype operator& (cantp_statustype a, cantp_statustype b) { return static_cast(static_cast(a)& static_cast(b)); }; inline cantp_statustype& operator&= (cantp_statustype& a, cantp_statustype b) { return (a = (a & b)); }; inline cantp_statustype operator~ (cantp_statustype a) { return static_cast(~static_cast(a)); }; // extra operator for cantp_status inline cantp_status operator| (cantp_status a, cantp_status b) { return static_cast(static_cast(a) | static_cast(b)); }; inline cantp_status& operator|= (cantp_status& a, cantp_status b) { return (a = (a | b)); }; inline cantp_status operator& (cantp_status a, cantp_status b) { return static_cast(static_cast(a)& static_cast(b)); }; inline cantp_status& operator&= (cantp_status& a, cantp_status b) { return (a = (a & b)); }; inline cantp_status operator~ (cantp_status a) { return static_cast(~static_cast(a)); }; // extra operator for cantp_msgflag inline cantp_msgflag operator| (cantp_msgflag a, cantp_msgflag b) { return static_cast(static_cast(a) | static_cast(b)); }; inline cantp_msgflag& operator|= (cantp_msgflag& a, cantp_msgflag b) { return (a = (a | b)); }; inline cantp_msgflag operator& (cantp_msgflag a, cantp_msgflag b) { return static_cast(static_cast(a)& static_cast(b)); }; inline cantp_msgflag& operator&= (cantp_msgflag& a, cantp_msgflag b) { return (a = (a & b)); }; inline cantp_msgflag operator~ (cantp_msgflag a) { return static_cast(~static_cast(a)); }; // extra operator for cantp_msgflag inline cantp_can_msgtype operator| (cantp_can_msgtype a, cantp_can_msgtype b) { return static_cast(static_cast(a) | static_cast(b)); }; inline cantp_can_msgtype& operator|= (cantp_can_msgtype& a, cantp_can_msgtype b) { return (a = (a | b)); }; inline cantp_can_msgtype operator& (cantp_can_msgtype a, cantp_can_msgtype b) { return static_cast(static_cast(a)& static_cast(b)); }; inline cantp_can_msgtype& operator&= (cantp_can_msgtype& a, cantp_can_msgtype b) { return (a = (a & b)); }; inline cantp_can_msgtype operator~ (cantp_can_msgtype a) { return static_cast(~static_cast(a)); }; // extra operator for cantp_isotp_msgtype inline cantp_isotp_msgtype operator| (cantp_isotp_msgtype a, cantp_isotp_msgtype b) { return static_cast(static_cast(a) | static_cast(b)); }; inline cantp_isotp_msgtype& operator|= (cantp_isotp_msgtype& a, cantp_isotp_msgtype b) { return (a = (a | b)); }; inline cantp_isotp_msgtype operator& (cantp_isotp_msgtype a, cantp_isotp_msgtype b) { return static_cast(static_cast(a)& static_cast(b)); }; inline cantp_isotp_msgtype& operator&= (cantp_isotp_msgtype& a, cantp_isotp_msgtype b) { return (a = (a & b)); }; inline cantp_isotp_msgtype operator~ (cantp_isotp_msgtype a) { return static_cast(~static_cast(a)); }; // extra operator for cantp_infostatus inline cantp_infostatus operator| (cantp_infostatus a, cantp_infostatus b) { return static_cast(static_cast(a) | static_cast(b)); }; inline cantp_infostatus& operator|= (cantp_infostatus& a, cantp_infostatus b) { return (a = (a | b)); }; inline cantp_infostatus operator& (cantp_infostatus a, cantp_infostatus b) { return static_cast(static_cast(a)& static_cast(b)); }; inline cantp_infostatus& operator&= (cantp_infostatus& a, cantp_infostatus b) { return (a = (a & b)); }; inline cantp_infostatus operator~ (cantp_infostatus a) { return static_cast(~static_cast(a)); }; #pragma endregion #pragma region PCANTP Api #if defined(PCANTP_API_COMPATIBILITY_ISO_2004) public ref class CanTpApi_2016 #else public ref class CanTpApi #endif { public: #pragma region bitrate // Represents the configuration for a CAN bit rate // Note: // * Each parameter and its value must be separated with a '='. // * Each pair of parameter/value must be separated using ','. // // Example: // f_clock=80000000,nom_brp=10,nom_tseg1=5,nom_tseg2=2,nom_sjw=1,data_brp=4,data_tseg1=7,data_tseg2=2,data_sjw=1 // static const String^ PCANTP_BITRATE_CLOCK = PCANBasic::PCAN_BR_CLOCK; static const String^ PCANTP_BITRATE_CLOCK_MHZ = PCANBasic::PCAN_BR_CLOCK_MHZ; static const String^ PCANTP_BITRATE_NOM_BRP = PCANBasic::PCAN_BR_NOM_BRP; static const String^ PCANTP_BITRATE_NOM_TSEG1 = PCANBasic::PCAN_BR_NOM_TSEG1; static const String^ PCANTP_BITRATE_NOM_TSEG2 = PCANBasic::PCAN_BR_NOM_TSEG2; static const String^ PCANTP_BITRATE_NOM_SJW = PCANBasic::PCAN_BR_NOM_SJW; static const String^ PCANTP_BITRATE_NOM_SAMPLE = PCANBasic::PCAN_BR_NOM_SAMPLE; static const String^ PCANTP_BITRATE_DATA_BRP = PCANBasic::PCAN_BR_DATA_BRP; static const String^ PCANTP_BITRATE_DATA_TSEG1 = PCANBasic::PCAN_BR_DATA_TSEG1; static const String^ PCANTP_BITRATE_DATA_TSEG2 = PCANBasic::PCAN_BR_DATA_TSEG2; static const String^ PCANTP_BITRATE_DATA_SJW = PCANBasic::PCAN_BR_DATA_SJW; static const String^ PCANTP_BITRATE_DATA_SAMPLE = PCANBasic::PCAN_BR_DATA_SAMPLE; #pragma endregion #pragma region PCANTP parameter values static const Byte PCANTP_VALUE_PARAMETER_OFF = PCANBasic::PCAN_PARAMETER_OFF; static const Byte PCANTP_VALUE_PARAMETER_ON = PCANBasic::PCAN_PARAMETER_ON; /// /// Enable debug messages (only notices, informations, warnings, errors) /// static const Byte PCANTP_DEBUG_NOTICE = 0xF4; /// /// Enable debug messages (only informations, warnings, errors) /// static const Byte PCANTP_DEBUG_INFO = 0xF3; /// /// Enable debug messages (only warnings, errors) /// static const Byte PCANTP_DEBUG_WARNING = 0xF2; /// /// Enable debug messages (only errors) /// static const Byte PCANTP_DEBUG_ERROR = 0xF1; #if !defined(PCANTP_API_COMPATIBILITY_ISO_2004) /// /// No debug messages /// static const Byte PCANTP_DEBUG_NONE = 0x00; /// /// Puts CAN debug messages to stdout /// static const Byte PCANTP_DEBUG_CAN = 0x01; /// /// The Channel is illegal or not available /// static const Byte PCANTP_CHANNEL_UNAVAILABLE = 0x00; /// /// The Channel is available /// static const Byte PCANTP_CHANNEL_AVAILABLE = 0x01; /// /// The Channel is valid, and is being used /// static const Byte PCANTP_CHANNEL_OCCUPIED = 0x02; /// /// if set Flow Control frame shall not use the WT flow status value /// static const Byte PCANTP_WFT_MAX_UNLIMITED = 0x00; /// /// an integer describing the Wait Frame Transmissions parameter. /// static const Byte PCANTP_WFT_MAX_DEFAULT = 0x10; /// /// hide messages with type PCANTP_MESSAGE_INDICATION from CANTP_Read function /// static const Byte PCANTP_MSG_PENDING_HIDE = 0x00; /// /// show messages with type PCANTP_MESSAGE_INDICATION from CANTP_Read function /// static const Byte PCANTP_MSG_PENDING_SHOW = 0x01; /// /// uses CAN frame data optimization /// static const Byte PCANTP_CAN_DATA_PADDING_NONE = 0x00; /// /// uses CAN frame data padding (default, i.e. CAN DLC = 8) /// static const Byte PCANTP_CAN_DATA_PADDING_ON = 0x01; /// /// default value used if CAN data padding is enabled /// static const Byte PCANTP_CAN_DATA_PADDING_VALUE = 0x55; #endif /// /// disable reception of unformatted (NON-ISO-TP) CAN frames (default) /// only ISO 15765 messages will be received /// static const Byte PCANTP_FRAME_FILTERING_ISOTP = 0x00; /// /// enable reception of unformatted (NON-ISO-TP) CAN frames /// received messages will be treated as either ISO 15765 or as an unformatted CAN frame /// static const Byte PCANTP_FRAME_FILTERING_CAN = 0x01; /// /// enable reception of unformatted (NON-ISO-TP) CAN frames /// received messages will be treated as ISO 15765, unformatted CAN frame, or both (user will able to read fragmented CAN frames) /// static const Byte PCANTP_FRAME_FILTERING_VERBOSE = 0x02; #if !defined (PCANTP_API_COMPATIBILITY_ISO_2004) /// /// default priority for ISO-TP messages (only available fot normal fixed, mixed and enhanced addressing) /// static const Byte PCANTP_J1939_PRIORITY_DEFAULT = 0x06; #endif /// /// maximum size of a CAN (non-FD) frame (8) /// static const Byte PCANTP_MAX_LENGTH_CAN_STANDARD = 0x08; /// /// maximum size of a CAN FD frame (64) /// static const Byte PCANTP_MAX_LENGTH_CAN_FD = 0x40; /// /// maximum size of an ISO-TP rev. 2004 frame (4095) /// static const UInt32 PCANTP_MAX_LENGTH_ISOTP2004 = 0xFFF; /// /// maximum size of an ISO-TP rev. 2016 frame (4294967295) /// static const UInt32 PCANTP_MAX_LENGTH_ISOTP2016 = 0xFFFFFFFF; /// /// maximum size before using virtual allocation for ISO-TP messages /// static const UInt32 PCANTP_MAX_LENGTH_ALLOC = 0xFFFFFFU; /// /// default DLC for fragmented frames when transmiting ISO-TP messages /// static const Byte PCANTP_CAN_TX_DL_DEFAULT = PCANTP_MAX_LENGTH_CAN_STANDARD; /// /// ISO-15765-2:2004(E) /// static const Byte PCANTP_ISO_REV_2004 = 0x01; /// /// ISO-15765-2:2016(E) /// static const Byte PCANTP_ISO_REV_2016 = 0x02; /// /// disables the feature "ignore received BlockSize value" /// static const UInt32 PCANTP_BLOCK_SIZE_TX_IGNORE = 0xFFFF; /// /// disables the feature "ignore received STMin value" /// static const UInt32 PCANTP_SEPERATION_TIME_TX_IGNORE = 0xFFFF; /// /// sets timeouts according to ISO-15765-2 /// static const Byte PCANTP_ISO_TIMEOUTS_15765_2 = 0; /// /// sets timeouts according to ISO-15765-4 (OBDII) /// static const Byte PCANTP_ISO_TIMEOUTS_15765_4 = 1; /// /// no optimization (use this parameter if ECU requires strict respect of Minimum Separation Time) /// static const Byte PCANTP_SELFRECEIVE_LATENCY_NONE = 0; /// /// (DEFAULT) fragmented self-receive frame mechanism is ignored when STmin is set to = 0xF3 and lower (<300µs) /// static const Byte PCANTP_SELFRECEIVE_LATENCY_LIGHT = 1; /// /// as LIGHT value plus optimize self-receive latency by predicting the time to effectively write frames on bus /// static const Byte PCANTP_SELFRECEIVE_LATENCY_OPTIMIZED = 2; /// /// (DEFAULT) maxinum number of items in the receive queue /// static const UInt32 PCANTP_MAX_RX_QUEUE_DEFAULT = 32767; /// /// (DEFAULT) Network layer design is full-duplex /// static const Byte PCANTP_NETWORK_LAYER_FULL_DUPLEX = 0; /// /// Network layer design is half-duplex (only one transmission/reception of the same NAI at a time) /// static const Byte PCANTP_NETWORK_LAYER_HALF_DUPLEX = 1; // Standard ISO-15765-2 values /// /// Default value for Separation time /// static const Byte PCANTP_STMIN_ISO_15765_2 = 10; /// /// Default value for BlockSize /// static const Byte PCANTP_BS_ISO_15765_2 = 10; /// /// Default value for Timeout Ar in µs /// static const UInt32 PCANTP_TIMEOUT_AR_ISO_15765_2 = (1000 * 1000); /// /// Default value for Timeout As in µs /// static const UInt32 PCANTP_TIMEOUT_AS_ISO_15765_2 = (1000 * 1000); /// /// Default value for Timeout Br in µs /// static const UInt32 PCANTP_TIMEOUT_BR_ISO_15765_2 = (1000 * 1000); /// /// Default value for Timeout Bs in µs /// static const UInt32 PCANTP_TIMEOUT_BS_ISO_15765_2 = (1000 * 1000); /// /// Default value for Timeout Cr in µs /// static const UInt32 PCANTP_TIMEOUT_CR_ISO_15765_2 = (1000 * 1000); /// /// Default value for Timeout Cs in µs /// static const UInt32 PCANTP_TIMEOUT_CS_ISO_15765_2 = (1000 * 1000); /// /// Default value for timeout tolerance [0..100] (timeout = t * (1 + tolerance/100)) /// static const Byte PCANTP_TIMEOUT_TOLERANCE = 0; // Standard ISO-15765-4 (OBDII) values /// /// OBDII value for Separation time /// static const Byte PCANTP_STMIN_ISO_15765_4 = 0; /// /// OBDII value for BlockSize /// static const Byte PCANTP_BS_ISO_15765_4 = 0; /// /// OBDII value for Timeout Ar in µs /// static const UInt32 PCANTP_TIMEOUT_AR_ISO_15765_4 = (1000 * 25); /// /// OBDII value for Timeout As in µs /// static const UInt32 PCANTP_TIMEOUT_AS_ISO_15765_4 = (1000 * 25); /// /// OBDII value for Timeout Br in µs /// static const UInt32 PCANTP_TIMEOUT_BR_ISO_15765_4 = (1000 * 75); /// /// OBDII value for Timeout Bs in µs /// static const UInt32 PCANTP_TIMEOUT_BS_ISO_15765_4 = (1000 * 75); /// /// OBDII value for Timeout Cr in µs /// static const UInt32 PCANTP_TIMEOUT_CR_ISO_15765_4 = (1000 * 150); /// /// OBDII value for Timeout Cs in µs /// static const UInt32 PCANTP_TIMEOUT_CS_ISO_15765_4 = (1000 * 150); // Values for cfg_value /// /// Mask for the 29bits ISOTP priority value (stored in bits [0..2]) /// static const Byte PCANTP_FLAG_MASK_PRIORITY = 0x07; /// /// Padding is enabled /// static const Byte PCANTP_FLAG_PADDING_ON = 0x08; /// /// Message's indication is enabled /// static const Byte PCANTP_FLAG_INDICATION_ON = 0x10; /// /// Echo of fragmented frames is enabled /// static const Byte PCANTP_FLAG_ECHO_FRAMES_ON = 0x20; #pragma endregion #pragma region constants //////////////////////////////////////////////////////////// // Constants definition //////////////////////////////////////////////////////////// /// /// Mapping does not require a Flow Control frame. /// static const UInt32 PCANTP_MAPPING_FLOW_CTRL_NONE = 0xFFFFFFFF; #pragma endregion #pragma region PCAN ISO - TP API Implementation /// /// Initializes a PCANTP-Client based on a CANTP handle (without CAN-FD support) /// /// Only one PCANTP-Client can be initialized per CAN-Channel /// A PCANTP Channel Handle representing a PCANTP-Client /// The CAN Hardware speed /// NON PLUG-N-PLAY: The type of hardware and operation mode /// NON PLUG-N-PLAY: The I/O address for the parallel port /// NON PLUG-N-PLAY: Interrupt number of the parallel port /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_Initialize_2016")] static cantp_status Initialize_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_baudrate baudrate, [MarshalAs(UnmanagedType::U4)] cantp_hwtype hw_type, UInt32 io_port, UInt16 interrupt); /// /// Initializes a PCANTP-Client based on a CANTP handle (without CAN-FD support) /// /// Only one PCANTP-Client can be initialized per CAN-Channel /// A PCANTP Channel Handle representing a PCANTP-Client /// The CAN Hardware speed /// NON PLUG-N-PLAY: The type of hardware and operation mode /// NON PLUG-N-PLAY: The I/O address for the parallel port /// A cantp_status code. PCANTP_STATUS_OK is returned on success static cantp_status Initialize_2016( cantp_handle channel, cantp_baudrate baudrate, cantp_hwtype hw_type, UInt32 io_port) { return Initialize_2016(channel, baudrate, hw_type, io_port, 0); } /// /// Initializes a PCANTP-Client based on a CANTP handle (without CAN-FD support) /// /// Only one PCANTP-Client can be initialized per CAN-Channel /// A PCANTP Channel Handle representing a PCANTP-Client /// The CAN Hardware speed /// NON PLUG-N-PLAY: The type of hardware and operation mode /// A cantp_status code. PCANTP_STATUS_OK is returned on success static cantp_status Initialize_2016( cantp_handle channel, cantp_baudrate baudrate, cantp_hwtype hw_type) { return Initialize_2016(channel, baudrate, hw_type, 0, 0); } /// /// Initializes a PCANTP-Client based on a CANTP handle (without CAN-FD support) /// /// Only one PCANTP-Client can be initialized per CAN-Channel /// A PCANTP Channel Handle representing a PCANTP-Client /// The CAN Hardware speed /// A cantp_status code. PCANTP_STATUS_OK is returned on success static cantp_status Initialize_2016( cantp_handle channel, cantp_baudrate baudrate) { return Initialize_2016(channel, baudrate, (cantp_hwtype)0, 0, 0); } /// /// Initializes a PCANTP-Client based on a CANTP Channel (including CAN-FD support) /// /// "The handle of a FD capable PCAN Channel" /// "The speed for the communication (FD bit rate string)" /// Only one PCANTP-Client can be initialized per CAN-Channel. /// See PCAN_BR_* values /// * Parameter and values must be separated by '=' /// * Couples of Parameter/value must be separated by ',' /// * Following Parameter must be filled out: f_clock, data_brp, data_sjw, data_tseg1, data_tseg2, /// nom_brp, nom_sjw, nom_tseg1, nom_tseg2. /// * Following Parameters are optional (not used yet): data_ssp_offset, nom_samp /// /// f_clock_mhz=80,nom_brp=0,nom_tseg1=13,nom_tseg2=0,nom_sjw=0,data_brp=0, /// data_tseg1=13,data_tseg2=0,data_sjw=0 /// "A cantp_status code" [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_InitializeFD_2016")] static cantp_status InitializeFD_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::LPStr)] cantp_bitrate bitrate_fd); /// /// Uninitializes a PCANTP-Client initialized before /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_Uninitialize_2016")] static cantp_status Uninitialize_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel); /// /// Resets the receive and transmit queues of a PCANTP-Client /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_Reset_2016")] static cantp_status Reset_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel); /// /// Gets information about the internal BUS status of a PCANTP-Channel. /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_GetCanBusStatus_2016")] static cantp_status GetCanBusStatus_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel); /// /// Reads a PCANTP message from the receive queue of a PCANTP-Client /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A cantp_msg structure buffer to store the PUDS message /// A cantp_timestamp structure buffer to get /// the reception time of the message. /// A cantp_msgtype structure buffer to filter the message to read. /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_Read_2016")] static cantp_status Read_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, cantp_msg %msg_buffer, cantp_timestamp %timestamp_buffer, [MarshalAs(UnmanagedType::U4)] cantp_msgtype msg_type); /// /// Reads a PCANTP message from the receive queue of a PCANTP-Client /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A cantp_msg structure buffer to store the PUDS message /// A cantp_timestamp structure buffer to get /// the reception time of the message. /// A cantp_status code. PCANTP_STATUS_OK is returned on success static cantp_status Read_2016( cantp_handle channel, cantp_msg %msg_buffer, cantp_timestamp %timestamp_buffer) { return Read_2016(channel, msg_buffer, timestamp_buffer, cantp_msgtype::PCANTP_MSGTYPE_ANY); } private: [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_Read_2016")] static cantp_status Read_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, cantp_msg %msg_buffer, IntPtr timestamp_buffer, [MarshalAs(UnmanagedType::U4)] cantp_msgtype msg_type); public: /// /// Reads a PCANTP message from the receive queue of a PCANTP-Client /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A cantp_msg structure buffer to store the PUDS message /// A cantp_status code. PCANTP_STATUS_OK is returned on success static cantp_status Read_2016( cantp_handle channel, cantp_msg %msg_buffer) { return Read_2016(channel, msg_buffer, IntPtr::Zero, cantp_msgtype::PCANTP_MSGTYPE_ANY); } /// /// Gets progress information on a specific message /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A cantp_msg structure buffer matching the message to look for /// The expected direction (incoming/outgoing) of the message /// A cantp_msgprogress structure buffer to store the progress information /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_GetMsgProgress_2016")] static cantp_status GetMsgProgress_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [In] cantp_msg %msg_buffer, [MarshalAs(UnmanagedType::U4)] cantp_msgdirection direction, cantp_msgprogress %msgprogress_buffer); /// /// Adds a PCANTP message to the Transmit queue /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A cantp_msg buffer with the message to be sent /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_Write_2016")] static cantp_status Write_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, cantp_msg %msg_buffer); /// /// Retrieves a PCANTP-Client value /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The cantp_parameter parameter to get /// Buffer for the parameter value /// Size in bytes of the buffer /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_GetValue_2016")] static cantp_status GetValue_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_parameter parameter, StringBuilder ^StringBuffer, UInt32 BufferLength); /// /// Retrieves a PCANTP-Client value /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The cantp_parameter parameter to get /// Buffer for the parameter value /// Size in bytes of the buffer /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_GetValue_2016")] static cantp_status GetValue_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_parameter parameter, UInt32% NumericBuffer, UInt32 BufferLength); /// /// Retrieves a PCANTP-Client value /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The cantp_parameter parameter to get /// Buffer for the parameter value /// Size in bytes of the buffer /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_GetValue_2016")] static cantp_status GetValue_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_parameter parameter, UInt64% NumericBuffer, UInt32 BufferLength); /// /// Retrieves a PCANTP-Client value /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The cantp_parameter parameter to get /// Buffer for the parameter value /// Size in bytes of the buffer /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_GetValue_2016")] static cantp_status GetValue_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_parameter parameter, [MarshalAs(UnmanagedType::LPArray)] [Out] array^ Buffer, UInt32 BufferLength); /// /// Configures or sets a PCANTP-Client value /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The cantp_parameter parameter to set /// Buffer with the value to be set /// Size in bytes of the buffer /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_SetValue_2016")] static cantp_status SetValue_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_parameter parameter, UInt32 %NumericBuffer, UInt32 BufferLength); /// /// Configures or sets a PCANTP-Client value /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The cantp_parameter parameter to set /// Buffer with the value to be set /// Size in bytes of the buffer /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_SetValue_2016")] static cantp_status SetValue_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_parameter parameter, UInt64% NumericBuffer, UInt32 BufferLength); /// /// Configures or sets a PCANTP-Client value /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The cantp_parameter parameter to set /// Buffer with the value to be set /// Size in bytes of the buffer /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_SetValue_2016")] static cantp_status SetValue_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_parameter parameter, [MarshalAs(UnmanagedType::LPStr, SizeParamIndex = 3)] String ^StringBuffer, UInt32 BufferLength); /// /// Configures or sets a PCANTP-Client value /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The cantp_parameter parameter to set /// Buffer with the value to be set /// Size in bytes of the buffer /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_SetValue_2016")] static cantp_status SetValue_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::U4)] cantp_parameter parameter, [MarshalAs(UnmanagedType::LPArray, SizeParamIndex = 3)] array^ Buffer, UInt32 BufferLength); /// /// Adds a user-defined PCAN-TP mapping between CAN ID and Network Address Information /// /// /// Defining a mapping enables ISO-TP communication with 11BITS CAN ID or /// with opened Addressing Formats (like PCANTP_ISOTP_FORMAT_NORMAL or PCANTP_ISOTP_FORMAT_EXTENDED). /// /// A PCANTP Channel Handle representing a PCANTP-Client /// Buffer to the mapping to be added /// A cantp_status code : PCANTP_STATUS_OK is returned on success, /// PCANTP_STATUS_WRONG_PARAM states invalid Network Address Information parameters. [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_AddMapping_2016")] static cantp_status AddMapping_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, cantp_mapping %mapping); /// /// Removes all user-defined PCAN-TP mappings corresponding to a CAN ID /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The mapped CAN ID to search for /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_RemoveMappings_2016")] static cantp_status RemoveMappings_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, UInt32 can_id); /// /// Removes a user-defined PCAN-TP mapping between a CAN ID and Network Address Information /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The identifier of the mapping /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_RemoveMapping_2016")] static cantp_status RemoveMapping_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, UIntPtr uid); /// /// Retrieves all the mappings defined for a PCAN-TP channel /// /// A PCANTP Channel Handle representing a PCANTP-Client /// A buffer to store an array of cantp_mapping /// [In]The number of cantp_mapping element the buffer can store. of the mapping. /// [Out]The actual number of element copied in the buffer. /// A cantp_status code. PCANTP_STATUS_OK is returned on success, /// PCANTP_STATUS_PARAM_BUFFER_TOO_SMALL if the number of mappings exceeds buffer_length. [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_GetMappings_2016")] static cantp_status GetMappings_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, [MarshalAs(UnmanagedType::LPArray, SizeParamIndex = 2)] [Out] array^ buffer, UInt32 %buffer_length); /// /// Adds an entry to the CAN-ID white-list filtering. /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The lowest CAN ID wanted to be received /// The highest CAN ID wanted to be received /// States if filter should check the CAN message type. /// If ignore_can_msgtype is false, the value states which types of CAN frame should be allowed. /// A cantp_status code : PCANTP_STATUS_OK is returned on success, and PCANTP_STATUS_ALREADY_INITIALIZED otherwise. [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_AddFiltering_2016")] static cantp_status AddFiltering_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, UInt32 can_id_from, UInt32 can_id_to, [MarshalAs(UnmanagedType::U1)] bool ignore_can_msgtype, [MarshalAs(UnmanagedType::U4)] cantp_can_msgtype can_msgtype); /// /// Removes an entry from the CAN-ID white-list filtering. /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The lowest CAN ID wanted to be removed /// The highest CAN ID wanted to be removed /// States if filter should check the CAN message type. /// If ignore_can_msgtype is false, the value states which types of CAN frame should be allowed. /// A cantp_status code : PCANTP_STATUS_OK is returned on success, and PCANTP_STATUS_ALREADY_INITIALIZED otherwise. [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_RemoveFiltering_2016")] static cantp_status RemoveFiltering_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, UInt32 can_id_from, UInt32 can_id_to, [MarshalAs(UnmanagedType::U1)] bool ignore_can_msgtype, [MarshalAs(UnmanagedType::U4)] cantp_can_msgtype can_msgtype); /// /// Adds an entry to the message's rules. /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The rule to insert. /// A cantp_status code : PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_AddMsgRule_2016")] static cantp_status AddMsgRule_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, cantp_msgrule %msgrule); /// /// Removes an entry from the message's rules. /// /// A PCANTP Channel Handle representing a PCANTP-Client /// The unique ID of the rule to remove. /// A cantp_status code : PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_RemoveMsgRule_2016")] static cantp_status RemoveMsgRule_2016( [MarshalAs(UnmanagedType::U4)] cantp_handle channel, UIntPtr uid); /// /// Returns a descriptive text of a given cantp_status error /// code, in any desired language /// /// The current languages available for translation are: /// Neutral (0x00), German (0x07), English (0x09), Spanish (0x0A), /// Italian (0x10) and French (0x0C) /// A cantp_status error code /// Indicates a 'Primary language ID' /// Buffer for a null terminated char array /// Buffer size /// A cantp_status error code [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_GetErrorText_2016")] static cantp_status GetErrorText_2016( [MarshalAs(UnmanagedType::U4)] cantp_status error, UInt16 language, StringBuilder ^StringBuffer, UInt32 BufferSize); /// /// Allocates a PCAN-TP message based on the given type /// /// A cantp_msg structure buffer (it will be freed if required) /// Type of the message to allocate /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgDataAlloc_2016")] static cantp_status MsgDataAlloc_2016( cantp_msg %msg_buffer, [MarshalAs(UnmanagedType::U4)] cantp_msgtype type); /// /// Initializes an allocated PCAN-TP message /// /// An allocated cantp_msg structure buffer /// CAN identifier (ISO-TP message may ignore this parameter and use PCANTP_MAPPING_FLOW_CTRL_NONE (-1)) /// Combination of CAN message types (like "extended CAN ID", "FD", "RTR", etc. flags) /// Length of the data /// A buffer to initialize the message's data with. If NULL, message's data is initialized with zeros. /// Network address information of the ISO-TP message (only valid with an ISO-TP message) /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgDataInit_2016")] static cantp_status MsgDataInit_2016( cantp_msg %msg_buffer, UInt32 can_id, [MarshalAs(UnmanagedType::U4)] cantp_can_msgtype can_msgtype, UInt32 data_length, [MarshalAs(UnmanagedType::LPArray, SizeParamIndex = 3)] array^ data, cantp_netaddrinfo %netaddrinfo); private: [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgDataInit_2016")] static cantp_status MsgDataInit_2016( cantp_msg %msg_buffer, UInt32 can_id, [MarshalAs(UnmanagedType::U4)] cantp_can_msgtype can_msgtype, UInt32 data_length, [MarshalAs(UnmanagedType::LPArray, SizeParamIndex = 3)] array^ data, IntPtr netaddrinfo); public: /// /// Initializes an allocated PCAN-TP message /// /// An allocated cantp_msg structure buffer /// CAN identifier (ISO-TP message may ignore this parameter and use PCANTP_MAPPING_FLOW_CTRL_NONE (-1)) /// Combination of CAN message types (like "extended CAN ID", "FD", "RTR", etc. flags) /// Length of the data /// A buffer to initialize the message's data with. If NULL, message's data is initialized with zeros. /// A cantp_status code. PCANTP_STATUS_OK is returned on success static cantp_status MsgDataInit_2016( cantp_msg %msg_buffer, UInt32 can_id, cantp_can_msgtype can_msgtype, UInt32 data_length, array^ data) { return MsgDataInit_2016(msg_buffer, can_id, can_msgtype, data_length, data, IntPtr::Zero); } /// /// Initializes a number of options for the PCAN-TP message that will override the channel's parameter(s) /// /// An allocated cantp_msg structure buffer. /// Number of options to initialize. /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgDataInitOptions_2016")] static cantp_status MsgDataInitOptions_2016( cantp_msg %msg_buffer, UInt32 nb_options); /// /// Deallocates a PCAN-TP message /// /// An allocated cantp_msg structure buffer. /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgDataFree_2016")] static cantp_status MsgDataFree_2016( cantp_msg %msg_buffer); private: [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgEqual_2016")] static Byte byteMsgEqual_2016( [In] cantp_msg %msg_buffer1, [In] cantp_msg %msg_buffer2, [MarshalAs(UnmanagedType::I1)] bool ignoreSelfReceiveFlag); public: /// /// Checks if two PCAN-TP messages are equal. /// If one message is the indication of an incoming/outgoing ISO-TP message, the actual data-content will not be compared. /// In that case the function checks if the messages' network address information matches. /// /// A cantp_msg structure buffer. /// Another cantp_msg structure buffer to compare with first parameter. /// States if comparison should ignore loopback flag /// (i.e if true the function will return true when comparing a request and its loopback confirmation). /// A boolean stating if the cantp_msgs are equal. /// Copies a PCAN-TP message to another buffer. /// /// A cantp_msg structure buffer to store the copied message. /// The cantp_msg structure buffer used as the source. /// A cantp_status code. PCANTP_STATUS_OK is returned on success [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgCopy_2016")] static cantp_status MsgCopy_2016( cantp_msg %msg_buffer_dst, [In] cantp_msg %msg_buffer_src); /// /// Converts a CAN DLC to its corresponding length. /// /// The Data Length Code (DLC) to convert. /// The corresponding length of the dlc parameter. [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgDlcToLength_2016")] static UInt32 MsgDlcToLength_2016( Byte dlc); /// /// Converts a data length to a corresponding CAN DLC. /// Note: the returned DLC can hold more data that the requested length. /// /// The length to convert. /// The smallest DLC that can hold the requested length (0x00-0x0F). [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_MsgLengthToDlc_2016")] static Byte MsgLengthToDlc_2016( UInt32 length); /// /// Lists the subtypes contained in the PCAN-TP status. /// /// The status to analyze. /// An aggregation of cantp_statustype values. [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_StatusListTypes_2016")] static cantp_statustype StatusListTypes_2016( [MarshalAs(UnmanagedType::U4)] cantp_status status); /// /// Retrieves the value of a cantp_status subtype (like cantp_errstatus, cantp_busstatus, etc.). /// /// The status to analyze. /// The type of status to filter. /// The value of the enumeration matching the requested type. [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_StatusGet_2016")] static UInt32 StatusGet_2016( [MarshalAs(UnmanagedType::U4)] cantp_status status, [MarshalAs(UnmanagedType::U4)] cantp_statustype type); private: [DllImport("PCAN-ISO-TP.dll", EntryPoint = "CANTP_StatusIsOk_2016")] static Byte byteStatusIsOk_2016( [MarshalAs(UnmanagedType::U4)] cantp_status status, [MarshalAs(UnmanagedType::U4)] cantp_status status_expected, [MarshalAs(UnmanagedType::I1)] bool strict); public: /// /// Checks if a status matches an expected result. /// /// The status to analyze. /// The expected status. /// Enable strict mode. Strict mode ensures that bus or extra information are the same. /// Returns true if the status matches expected parameter. static bool StatusIsOk_2016( cantp_status status, cantp_status status_expected, bool strict) { return (0 != byteStatusIsOk_2016(status, status_expected, strict)); }; /// /// Checks if a status matches an expected result in non-strict mode /// (Strict mode ensures that bus or extra information are the same). /// /// The status to analyze. /// The expected status (default is PCANTP_STATUS_OK). /// Returns true if the status matches expected parameter. static bool StatusIsOk_2016( cantp_status status, cantp_status status_expected ) { return StatusIsOk_2016(status, status_expected, false); } /// /// Checks if a status matches PCANTP_STATUS_OK in non-strict mode /// (Strict mode ensures that bus or extra information are the same). /// /// The status to analyze. /// Returns true if the status matches expected parameter. static bool StatusIsOk_2016( cantp_status status ) { return StatusIsOk_2016(status, cantp_status::PCANTP_STATUS_OK, false); } #pragma endregion }; #pragma endregion } } }