PCANBasic开发(二)
阅读原文时间:2023年07月10日阅读:1

使用Peak的PCan转换器开发,使用其中的PCanBasic.dll

// PCANBasic.cs
//
// ~~ // // PCAN-Basic API // // ~~
//
// ------------------------------------------------------------------
// Author : Keneth Wagner
// Last change: 13.11.2017 Wagner
//
// Language: C# 1.0
// ------------------------------------------------------------------
//
// Copyright (C) 1999-2017 PEAK-System Technik GmbH, Darmstadt
// more Info at http://www.peak-system.com
//
using System;
using System.Text;
using System.Runtime.InteropServices;

namespace Peak.Can.Basic
{
using TPCANHandle = System.UInt16;
using TPCANBitrateFD = System.String;
using TPCANTimestampFD = System.UInt64;

#region Enumerations  
/// <summary>  
/// Represents a PCAN status/error code  
/// </summary>  
\[Flags\]  
public enum TPCANStatus : uint  
{  
    /// <summary>  
    /// No error  
    /// </summary>  
    PCAN\_ERROR\_OK           = 0x00000,  
    /// <summary>  
    /// Transmit buffer in CAN controller is full  
    /// </summary>  
    PCAN\_ERROR\_XMTFULL      = 0x00001,  
    /// <summary>  
    /// CAN controller was read too late  
    /// </summary>  
    PCAN\_ERROR\_OVERRUN      = 0x00002,  
    /// <summary>  
    /// Bus error: an error counter reached the 'light' limit  
    /// </summary>  
    PCAN\_ERROR\_BUSLIGHT     = 0x00004,  
    /// <summary>  
    /// Bus error: an error counter reached the 'heavy' limit  
    /// </summary>  
    PCAN\_ERROR\_BUSHEAVY     = 0x00008,  
    /// <summary>  
    /// Bus error: an error counter reached the 'warning' limit  
    /// </summary>  
    PCAN\_ERROR\_BUSWARNING   = PCAN\_ERROR\_BUSHEAVY,  
    /// <summary>  
    /// Bus error: the CAN controller is error passive  
    /// </summary>  
    PCAN\_ERROR\_BUSPASSIVE   = 0x40000,  
    /// <summary>  
    /// Bus error: the CAN controller is in bus-off state  
    /// </summary>  
    PCAN\_ERROR\_BUSOFF       = 0x00010,  
    /// <summary>  
    /// Mask for all bus errors  
    /// </summary>  
    PCAN\_ERROR\_ANYBUSERR = (PCAN\_ERROR\_BUSWARNING | PCAN\_ERROR\_BUSLIGHT | PCAN\_ERROR\_BUSHEAVY | PCAN\_ERROR\_BUSOFF | PCAN\_ERROR\_BUSPASSIVE),  
    /// <summary>  
    /// Receive queue is empty  
    /// </summary>  
    PCAN\_ERROR\_QRCVEMPTY    = 0x00020,  
    /// <summary>  
    /// Receive queue was read too late  
    /// </summary>  
    PCAN\_ERROR\_QOVERRUN     = 0x00040,  
    /// <summary>  
    /// Transmit queue is full  
    /// </summary>  
    PCAN\_ERROR\_QXMTFULL     = 0x00080,  
    /// <summary>  
    /// Test of the CAN controller hardware registers failed (no hardware found)  
    /// </summary>  
    PCAN\_ERROR\_REGTEST      = 0x00100,  
    /// <summary>  
    /// Driver not loaded  
    /// </summary>  
    PCAN\_ERROR\_NODRIVER     = 0x00200,  
    /// <summary>  
    /// Hardware already in use by a Net  
    /// </summary>  
    PCAN\_ERROR\_HWINUSE      = 0x00400,  
    /// <summary>  
    /// A Client is already connected to the Net  
    /// </summary>  
    PCAN\_ERROR\_NETINUSE     = 0x00800,  
    /// <summary>  
    /// Hardware handle is invalid  
    /// </summary>  
    PCAN\_ERROR\_ILLHW        = 0x01400,  
    /// <summary>  
    /// Net handle is invalid  
    /// </summary>  
    PCAN\_ERROR\_ILLNET       = 0x01800,  
    /// <summary>  
    /// Client handle is invalid  
    /// </summary>  
    PCAN\_ERROR\_ILLCLIENT    = 0x01C00,  
    /// <summary>  
    /// Mask for all handle errors  
    /// </summary>  
    PCAN\_ERROR\_ILLHANDLE    = (PCAN\_ERROR\_ILLHW | PCAN\_ERROR\_ILLNET | PCAN\_ERROR\_ILLCLIENT),  
    /// <summary>  
    /// Resource (FIFO, Client, timeout) cannot be created  
    /// </summary>  
    PCAN\_ERROR\_RESOURCE     = 0x02000,  
    /// <summary>  
    /// Invalid parameter  
    /// </summary>  
    PCAN\_ERROR\_ILLPARAMTYPE = 0x04000,  
    /// <summary>  
    /// Invalid parameter value  
    /// </summary>  
    PCAN\_ERROR\_ILLPARAMVAL  = 0x08000,  
    /// <summary>  
    /// Unknown error  
    /// </summary>  
    PCAN\_ERROR\_UNKNOWN      = 0x10000,  
    /// <summary>  
    /// Invalid data, function, or action.  
    /// </summary>  
    PCAN\_ERROR\_ILLDATA      = 0x20000,  
    /// <summary>  
    /// An operation was successfully carried out, however, irregularities were registered  
    /// </summary>  
    PCAN\_ERROR\_CAUTION = 0x2000000,  
    /// <summary>  
    /// Channel is not initialized  
    /// <remarks>Value was changed from 0x40000 to 0x4000000</remarks>  
    /// </summary>  
    PCAN\_ERROR\_INITIALIZE = 0x4000000,  
    /// <summary>  
    /// Invalid operation  
    /// <remarks>Value was changed from 0x80000 to 0x8000000</remarks>  
    /// </summary>  
    PCAN\_ERROR\_ILLOPERATION = 0x8000000,  
}

/// <summary>  
/// Represents a PCAN device  
/// </summary>  
public enum TPCANDevice : byte  
{  
    /// <summary>  
    /// Undefined, unknown or not selected PCAN device value  
    /// </summary>  
    PCAN\_NONE = 0,  
    /// <summary>  
    /// PCAN Non-Plug and Play devices. NOT USED WITHIN PCAN-Basic API  
    /// </summary>  
    PCAN\_PEAKCAN = 1,  
    /// <summary>  
    /// PCAN-ISA, PCAN-PC/104, and PCAN-PC/104-Plus  
    /// </summary>  
    PCAN\_ISA = 2,  
    /// <summary>  
    /// PCAN-Dongle  
    /// </summary>  
    PCAN\_DNG = 3,  
    /// <summary>  
    /// PCAN-PCI, PCAN-cPCI, PCAN-miniPCI, and PCAN-PCI Express  
    /// </summary>  
    PCAN\_PCI = 4,  
    /// <summary>  
    /// PCAN-USB and PCAN-USB Pro  
    /// </summary>  
    PCAN\_USB = 5,  
    /// <summary>  
    /// PCAN-PC Card  
    /// </summary>  
    PCAN\_PCC = 6,  
    /// <summary>  
    /// PCAN Virtual hardware. NOT USED WITHIN PCAN-Basic API  
    /// </summary>  
    PCAN\_VIRTUAL = 7,  
    /// <summary>  
    /// PCAN Gateway devices  
    /// </summary>  
    PCAN\_LAN = 8  
}

/// <summary>  
/// Represents a PCAN parameter to be read or set  
/// </summary>  
public enum TPCANParameter : byte  
{  
    /// <summary>  
    /// PCAN-USB device number parameter  
    /// </summary>  
    PCAN\_DEVICE\_NUMBER       = 1,  
    /// <summary>  
    /// PCAN-PC Card 5-Volt power parameter  
    /// </summary>  
    PCAN\_5VOLTS\_POWER        = 2,  
    /// <summary>  
    /// PCAN receive event handler parameter  
    /// </summary>  
    PCAN\_RECEIVE\_EVENT       = 3,  
    /// <summary>  
    /// PCAN message filter parameter  
    /// </summary>  
    PCAN\_MESSAGE\_FILTER      = 4,  
    /// <summary>  
    /// PCAN-Basic API version parameter  
    /// </summary>  
    PCAN\_API\_VERSION         = 5,  
    /// <summary>  
    /// PCAN device channel version parameter  
    /// </summary>  
    PCAN\_CHANNEL\_VERSION     = 6,  
    /// <summary>  
    /// PCAN Reset-On-Busoff parameter  
    /// </summary>  
    PCAN\_BUSOFF\_AUTORESET    = 7,  
    /// <summary>  
    /// PCAN Listen-Only parameter  
    /// </summary>  
    PCAN\_LISTEN\_ONLY         = 8,  
    /// <summary>  
    /// Directory path for log files  
    /// </summary>  
    PCAN\_LOG\_LOCATION        = 9,  
    /// <summary>  
    /// Debug-Log activation status  
    /// </summary>  
    PCAN\_LOG\_STATUS          = 10,  
    /// <summary>  
    /// Configuration of the debugged information (LOG\_FUNCTION\_\*\*\*)  
    /// </summary>  
    PCAN\_LOG\_CONFIGURE       = 11,  
    /// <summary>  
    /// Custom insertion of text into the log file  
    /// </summary>  
    PCAN\_LOG\_TEXT            = 12,  
    /// <summary>  
    /// Availability status of a PCAN-Channel  
    /// </summary>  
    PCAN\_CHANNEL\_CONDITION   = 13,  
    /// <summary>  
    /// PCAN hardware name parameter  
    /// </summary>  
    PCAN\_HARDWARE\_NAME       = 14,  
    /// <summary>  
    /// Message reception status of a PCAN-Channel  
    /// </summary>  
    PCAN\_RECEIVE\_STATUS      = 15,  
    /// <summary>  
    /// CAN-Controller number of a PCAN-Channel  
    /// </summary>  
    PCAN\_CONTROLLER\_NUMBER   = 16,  
    /// <summary>  
    /// Directory path for PCAN trace files  
    /// </summary>  
    PCAN\_TRACE\_LOCATION      = 17,  
    /// <summary>  
    /// CAN tracing activation status  
    /// </summary>  
    PCAN\_TRACE\_STATUS        = 18,  
    /// <summary>  
    /// Configuration of the maximum file size of a CAN trace  
    /// </summary>  
    PCAN\_TRACE\_SIZE          = 19,  
    /// <summary>  
    /// Configuration of the trace file storing mode (TRACE\_FILE\_\*\*\*)  
    /// </summary>  
    PCAN\_TRACE\_CONFIGURE     = 20,  
    /// <summary>  
    /// Physical identification of a USB based PCAN-Channel by blinking its associated LED  
    /// </summary>  
    PCAN\_CHANNEL\_IDENTIFYING = 21,  
    /// <summary>  
    /// Capabilities of a PCAN device (FEATURE\_\*\*\*)  
    /// </summary>  
    PCAN\_CHANNEL\_FEATURES    = 22,  
    /// <summary>  
    /// Using of an existing bit rate (PCAN-View connected to a channel)  
    /// </summary>  
    PCAN\_BITRATE\_ADAPTING    = 23,  
    /// <summary>  
    /// Configured bit rate as Btr0Btr1 value  
    /// </summary>  
    PCAN\_BITRATE\_INFO        = 24,  
    /// <summary>  
    /// Configured bit rate as TPCANBitrateFD string  
    /// </summary>  
    PCAN\_BITRATE\_INFO\_FD     = 25,  
    /// <summary>  
    /// Configured nominal CAN Bus speed as Bits per seconds  
    /// </summary>  
    PCAN\_BUSSPEED\_NOMINAL    = 26,  
    /// <summary>  
    /// Configured CAN data speed as Bits per seconds  
    /// </summary>  
    PCAN\_BUSSPEED\_DATA       = 27,  
    /// <summary>  
    /// Remote address of a LAN channel as string in IPv4 format  
    /// </summary>  
    PCAN\_IP\_ADDRESS          = 28,  
    /// <summary>  
    /// Status of the Virtual PCAN-Gateway Service  
    /// </summary>  
    PCAN\_LAN\_SERVICE\_STATUS  = 29,  
    /// <summary>  
    /// Status messages reception status within a PCAN-Channel  
    /// </summary>  
    PCAN\_ALLOW\_STATUS\_FRAMES = 30,  
    /// <summary>  
    /// RTR messages reception status within a PCAN-Channel  
    /// </summary>  
    PCAN\_ALLOW\_RTR\_FRAMES = 31,  
    /// <summary>  
    /// Error messages reception status within a PCAN-Channel  
    /// </summary>  
    PCAN\_ALLOW\_ERROR\_FRAMES = 32,  
    /// <summary>  
    /// Delay, in microseconds, between sending frames  
    /// </summary>  
    PCAN\_INTERFRAME\_DELAY = 33,  
    /// <summary>  
    /// Filter over code and mask patterns for 11-Bit messages  
    /// </summary>  
    PCAN\_ACCEPTANCE\_FILTER\_11BIT = 34,  
    /// <summary>  
    /// Filter over code and mask patterns for 29-Bit messages  
    /// </summary>  
    PCAN\_ACCEPTANCE\_FILTER\_29BIT = 35,  
    /// <summary>  
    /// Output mode of 32 digital I/O pin of a PCAN-USB Chip. 1: Output-Active 0 : Output Inactive  
    /// </summary>  
    PCAN\_IO\_DIGITAL\_CONFIGURATION = 36,  
    /// <summary>  
    /// Value assigned to a 32 digital I/O pins of a PCAN-USB Chip  
    /// </summary>  
    PCAN\_IO\_DIGITAL\_VALUE = 37,  
    /// <summary>  
    /// Value assigned to a 32 digital I/O pins of a PCAN-USB Chip - Multiple digital I/O pins to 1 = High  
    /// </summary>  
    PCAN\_IO\_DIGITAL\_SET = 38,  
    /// <summary>  
    /// Clear multiple digital I/O pins to 0  
    /// </summary>  
    PCAN\_IO\_DIGITAL\_CLEAR = 39,  
    /// <summary>  
    /// Get value of a single analog input pin  
    /// </summary>  
    PCAN\_IO\_ANALOG\_VALUE = 40,  
}

/// <summary>  
/// Represents the type of a PCAN message  
/// </summary>  
\[Flags\]  
public enum TPCANMessageType : byte  
{  
    /// <summary>  
    /// The PCAN message is a CAN Standard Frame (11-bit identifier)  
    /// </summary>  
    PCAN\_MESSAGE\_STANDARD  = 0x00,  
    /// <summary>  
    /// The PCAN message is a CAN Remote-Transfer-Request Frame  
    /// </summary>  
    PCAN\_MESSAGE\_RTR       = 0x01,  
    /// <summary>  
    /// The PCAN message is a CAN Extended Frame (29-bit identifier)  
    /// </summary>  
    PCAN\_MESSAGE\_EXTENDED  = 0x02,  
    /// <summary>  
    /// The PCAN message represents a FD frame in terms of CiA Specs  
    /// </summary>  
    PCAN\_MESSAGE\_FD = 0x04,  
    /// <summary>  
    /// The PCAN message represents a FD bit rate switch (CAN data at a higher bit rate)  
    /// </summary>  
    PCAN\_MESSAGE\_BRS = 0x08,  
    /// <summary>  
    /// The PCAN message represents a FD error state indicator(CAN FD transmitter was error active)  
    /// </summary>  
    PCAN\_MESSAGE\_ESI = 0x10,  
    /// <summary>  
    /// The PCAN message represents an error frame  
    /// </summary>  
    PCAN\_MESSAGE\_ERRFRAME = 0x40,  
    /// <summary>  
    /// The PCAN message represents a PCAN status message  
    /// </summary>  
    PCAN\_MESSAGE\_STATUS    = 0x80,  
}

/// <summary>  
/// Represents a PCAN filter mode  
/// </summary>  
public enum TPCANMode : byte  
{  
    /// <summary>  
    /// Mode is Standard (11-bit identifier)  
    /// </summary>  
    PCAN\_MODE\_STANDARD = TPCANMessageType.PCAN\_MESSAGE\_STANDARD,  
    /// <summary>  
    /// Mode is Extended (29-bit identifier)  
    /// </summary>  
    PCAN\_MODE\_EXTENDED = TPCANMessageType.PCAN\_MESSAGE\_EXTENDED,  
}

/// <summary>  
/// Represents a PCAN Baud rate register value  
/// </summary>  
public enum TPCANBaudrate : ushort  
{  
    /// <summary>  
    /// 1 MBit/s  
    /// </summary>  
    PCAN\_BAUD\_1M      = 0x0014,  
    /// <summary>  
    /// 800 KBit/s  
    /// </summary>  
    PCAN\_BAUD\_800K    = 0x0016,  
    /// <summary>  
    /// 500 kBit/s  
    /// </summary>  
    PCAN\_BAUD\_500K    = 0x001C,  
    /// <summary>  
    /// 250 kBit/s  
    /// </summary>  
    PCAN\_BAUD\_250K    = 0x011C,  
    /// <summary>  
    /// 125 kBit/s  
    /// </summary>  
    PCAN\_BAUD\_125K    = 0x031C,  
    /// <summary>  
    /// 100 kBit/s  
    /// </summary>  
    PCAN\_BAUD\_100K    = 0x432F,  
    /// <summary>  
    /// 95,238 KBit/s  
    /// </summary>  
    PCAN\_BAUD\_95K     = 0xC34E,  
    /// <summary>  
    /// 83,333 KBit/s  
    /// </summary>  
    PCAN\_BAUD\_83K     = 0x852B,  
    /// <summary>  
    /// 50 kBit/s  
    /// </summary>  
    PCAN\_BAUD\_50K     = 0x472F,  
    /// <summary>  
    /// 47,619 KBit/s  
    /// </summary>  
    PCAN\_BAUD\_47K     = 0x1414,  
    /// <summary>  
    /// 33,333 KBit/s  
    /// </summary>  
    PCAN\_BAUD\_33K     = 0x8B2F,  
    /// <summary>  
    /// 20 kBit/s  
    /// </summary>  
    PCAN\_BAUD\_20K     = 0x532F,  
    /// <summary>  
    /// 10 kBit/s  
    /// </summary>  
    PCAN\_BAUD\_10K     = 0x672F,  
    /// <summary>  
    /// 5 kBit/s  
    /// </summary>  
    PCAN\_BAUD\_5K      = 0x7F7F,  
}

/// <summary>  
/// Represents the type of PCAN (non plug and play) hardware to be initialized  
/// </summary>  
public enum TPCANType : byte  
{  
    /// <summary>  
    /// PCAN-ISA 82C200  
    /// </summary>  
    PCAN\_TYPE\_ISA           = 0x01,  
    /// <summary>  
    /// PCAN-ISA SJA1000  
    /// </summary>  
    PCAN\_TYPE\_ISA\_SJA       = 0x09,  
    /// <summary>  
    /// PHYTEC ISA  
    /// </summary>  
    PCAN\_TYPE\_ISA\_PHYTEC    = 0x04,  
    /// <summary>  
    /// PCAN-Dongle 82C200  
    /// </summary>  
    PCAN\_TYPE\_DNG           = 0x02,  
    /// <summary>  
    /// PCAN-Dongle EPP 82C200  
    /// </summary>  
    PCAN\_TYPE\_DNG\_EPP       = 0x03,  
    /// <summary>  
    /// PCAN-Dongle SJA1000  
    /// </summary>  
    PCAN\_TYPE\_DNG\_SJA       = 0x05,  
    /// <summary>  
    /// PCAN-Dongle EPP SJA1000  
    /// </summary>  
    PCAN\_TYPE\_DNG\_SJA\_EPP   = 0x06,  
}  
#endregion

#region Structures  
/// <summary>  
/// Represents a PCAN message  
/// </summary>  
public struct TPCANMsg  
{  
    /// <summary>  
    /// 11/29-bit message identifier  
    /// </summary>  
    public uint ID;  
    /// <summary>  
    /// Type of the message  
    /// </summary>  
    \[MarshalAs(UnmanagedType.U1)\]  
    public TPCANMessageType MSGTYPE;  
    /// <summary>  
    /// Data Length Code of the message (0..8)  
    /// </summary>  
    public byte LEN;  
    /// <summary>  
    /// Data of the message (DATA\[0\]..DATA\[7\])  
    /// </summary>  
    \[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)\]  
    public byte\[\] DATA;  
}

/// <summary>  
/// Represents a timestamp of a received PCAN message.  
/// Total Microseconds = micros + 1000 \* millis + 0x100000000 \* 1000 \* millis\_overflow  
/// </summary>  
public struct TPCANTimestamp  
{  
    /// <summary>  
    /// Base-value: milliseconds: 0.. 2^32-1  
    /// </summary>  
    public uint millis;  
    /// <summary>  
    /// Roll-arounds of millis  
    /// </summary>  
    public ushort millis\_overflow;  
    /// <summary>  
    /// Microseconds: 0..999  
    /// </summary>  
    public ushort micros;  
}

/// <summary>  
/// Represents a PCAN message from a FD capable hardware  
/// </summary>  
public struct TPCANMsgFD  
{  
    /// <summary>  
    /// 11/29-bit message identifier  
    /// </summary>  
    public uint ID;  
    /// <summary>  
    /// Type of the message  
    /// </summary>  
    \[MarshalAs(UnmanagedType.U1)\]  
    public TPCANMessageType MSGTYPE;  
    /// <summary>  
    /// Data Length Code of the message (0..15)  
    /// </summary>  
    public byte DLC;  
    /// <summary>  
    /// Data of the message (DATA\[0\]..DATA\[63\])  
    /// </summary>  
    \[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)\]  
    public byte\[\] DATA;  
}  
#endregion

#region PCANBasic class  
/// <summary>  
/// PCAN-Basic API class implementation  
/// </summary>  
public static class PCANBasic  
{  
    #region PCAN-BUS Handles Definition  
    /// <summary>  
    /// Undefined/default value for a PCAN bus  
    /// </summary>  
    public const TPCANHandle PCAN\_NONEBUS = 0x00;

    /// <summary>  
    /// PCAN-ISA interface, channel 1  
    /// </summary>  
    public const TPCANHandle PCAN\_ISABUS1 = 0x21;  
    /// <summary>  
    /// PCAN-ISA interface, channel 2  
    /// </summary>  
    public const TPCANHandle PCAN\_ISABUS2 = 0x22;  
    /// <summary>  
    /// PCAN-ISA interface, channel 3  
    /// </summary>  
    public const TPCANHandle PCAN\_ISABUS3 = 0x23;  
    /// <summary>  
    /// PCAN-ISA interface, channel 4  
    /// </summary>  
    public const TPCANHandle PCAN\_ISABUS4 = 0x24;  
    /// <summary>  
    /// PCAN-ISA interface, channel 5  
    /// </summary>  
    public const TPCANHandle PCAN\_ISABUS5 = 0x25;  
    /// <summary>  
    /// PCAN-ISA interface, channel 6  
    /// </summary>  
    public const TPCANHandle PCAN\_ISABUS6 = 0x26;  
    /// <summary>  
    /// PCAN-ISA interface, channel 7  
    /// </summary>  
    public const TPCANHandle PCAN\_ISABUS7 = 0x27;  
    /// <summary>  
    /// PCAN-ISA interface, channel 8  
    /// </summary>  
    public const TPCANHandle PCAN\_ISABUS8 = 0x28;

    /// <summary>  
    /// PPCAN-Dongle/LPT interface, channel 1  
    /// </summary>  
    public const TPCANHandle PCAN\_DNGBUS1 = 0x31;

    /// <summary>  
    /// PCAN-PCI interface, channel 1  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS1 = 0x41;  
    /// <summary>  
    /// PCAN-PCI interface, channel 2  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS2 = 0x42;  
    /// <summary>  
    /// PCAN-PCI interface, channel 3  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS3 = 0x43;  
    /// <summary>  
    /// PCAN-PCI interface, channel 4  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS4 = 0x44;  
    /// <summary>  
    /// PCAN-PCI interface, channel 5  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS5 = 0x45;  
    /// <summary>  
    /// PCAN-PCI interface, channel 6  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS6 = 0x46;  
    /// <summary>  
    /// PCAN-PCI interface, channel 7  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS7 = 0x47;  
    /// <summary>  
    /// PCAN-PCI interface, channel 8  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS8 = 0x48;  
    /// <summary>  
    /// PCAN-PCI interface, channel 9  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS9 = 0x409;  
    /// <summary>  
    /// PCAN-PCI interface, channel 10  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS10 = 0x40A;  
    /// <summary>  
    /// PCAN-PCI interface, channel 11  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS11 = 0x40B;  
    /// <summary>  
    /// PCAN-PCI interface, channel 12  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS12 = 0x40C;  
    /// <summary>  
    /// PCAN-PCI interface, channel 13  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS13 = 0x40D;  
    /// <summary>  
    /// PCAN-PCI interface, channel 14  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS14 = 0x40E;  
    /// <summary>  
    /// PCAN-PCI interface, channel 15  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS15 = 0x40F;  
    /// <summary>  
    /// PCAN-PCI interface, channel 16  
    /// </summary>  
    public const TPCANHandle PCAN\_PCIBUS16 = 0x410;

    /// <summary>  
    /// PCAN-USB interface, channel 1  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS1 = 0x51;  
    /// <summary>  
    /// PCAN-USB interface, channel 2  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS2 = 0x52;  
    /// <summary>  
    /// PCAN-USB interface, channel 3  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS3 = 0x53;  
    /// <summary>  
    /// PCAN-USB interface, channel 4  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS4 = 0x54;  
    /// <summary>  
    /// PCAN-USB interface, channel 5  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS5 = 0x55;  
    /// <summary>  
    /// PCAN-USB interface, channel 6  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS6 = 0x56;  
    /// <summary>  
    /// PCAN-USB interface, channel 7  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS7 = 0x57;  
    /// <summary>  
    /// PCAN-USB interface, channel 8  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS8 = 0x58;  
    /// <summary>  
    /// PCAN-USB interface, channel 9  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS9 = 0x509;  
    /// <summary>  
    /// PCAN-USB interface, channel 10  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS10 = 0x50A;  
    /// <summary>  
    /// PCAN-USB interface, channel 11  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS11 = 0x50B;  
    /// <summary>  
    /// PCAN-USB interface, channel 12  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS12 = 0x50C;  
    /// <summary>  
    /// PCAN-USB interface, channel 13  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS13 = 0x50D;  
    /// <summary>  
    /// PCAN-USB interface, channel 14  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS14 = 0x50E;  
    /// <summary>  
    /// PCAN-USB interface, channel 15  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS15 = 0x50F;  
    /// <summary>  
    /// PCAN-USB interface, channel 16  
    /// </summary>  
    public const TPCANHandle PCAN\_USBBUS16 = 0x510;

    /// <summary>  
    /// PCAN-PC Card interface, channel 1  
    /// </summary>  
    public const TPCANHandle PCAN\_PCCBUS1 = 0x61;  
    /// <summary>  
    /// PCAN-PC Card interface, channel 2  
    /// </summary>  
    public const TPCANHandle PCAN\_PCCBUS2 = 0x62;

    /// <summary>  
    /// PCAN-LAN interface, channel 1  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS1 = 0x801;  
    /// <summary>  
    /// PCAN-LAN interface, channel 2  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS2 = 0x802;  
    /// <summary>  
    /// PCAN-LAN interface, channel 3  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS3 = 0x803;  
    /// <summary>  
    /// PCAN-LAN interface, channel 4  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS4 = 0x804;  
    /// <summary>  
    /// PCAN-LAN interface, channel 5  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS5 = 0x805;  
    /// <summary>  
    /// PCAN-LAN interface, channel 6  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS6 = 0x806;  
    /// <summary>  
    /// PCAN-LAN interface, channel 7  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS7 = 0x807;  
    /// <summary>  
    /// PCAN-LAN interface, channel 8  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS8 = 0x808;  
    /// <summary>  
    /// PCAN-LAN interface, channel 9  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS9 = 0x809;  
    /// <summary>  
    /// PCAN-LAN interface, channel 10  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS10 = 0x80A;  
    /// <summary>  
    /// PCAN-LAN interface, channel 11  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS11 = 0x80B;  
    /// <summary>  
    /// PCAN-LAN interface, channel 12  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS12 = 0x80C;  
    /// <summary>  
    /// PCAN-LAN interface, channel 13  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS13 = 0x80D;  
    /// <summary>  
    /// PCAN-LAN interface, channel 14  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS14 = 0x80E;  
    /// <summary>  
    /// PCAN-LAN interface, channel 15  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS15 = 0x80F;  
    /// <summary>  
    /// PCAN-LAN interface, channel 16  
    /// </summary>  
    public const TPCANHandle PCAN\_LANBUS16 = 0x810;  
    #endregion

    #region FD Bit rate parameters  
    /// <summary>  
    /// Clock frequency in Herz (80000000, 60000000, 40000000, 30000000, 24000000, 20000000)  
    /// </summary>  
    public const string PCAN\_BR\_CLOCK = "f\_clock";  
    /// <summary>  
    /// Clock frequency in Megaherz (80, 60, 40, 30, 24, 20)  
    /// </summary>  
    public const string PCAN\_BR\_CLOCK\_MHZ = "f\_clock\_mhz";  
    /// <summary>  
    /// Clock prescaler for nominal time quantum  
    /// </summary>  
    public const string PCAN\_BR\_NOM\_BRP = "nom\_brp";  
    /// <summary>  
    /// TSEG1 segment for nominal bit rate in time quanta  
    /// </summary>  
    public const string PCAN\_BR\_NOM\_TSEG1 = "nom\_tseg1";  
    /// <summary>  
    /// TSEG2 segment for nominal bit rate in time quanta  
    /// </summary>  
    public const string PCAN\_BR\_NOM\_TSEG2 = "nom\_tseg2";  
    /// <summary>  
    /// Synchronization Jump Width for nominal bit rate in time quanta  
    /// </summary>  
    public const string PCAN\_BR\_NOM\_SJW = "nom\_sjw";  
    /// <summary>  
    /// Sample point for nominal bit rate  
    /// </summary>  
    public const string PCAN\_BR\_NOM\_SAMPLE = "nom\_sam";  
    /// <summary>  
    /// Clock prescaler for highspeed data time quantum  
    /// </summary>  
    public const string PCAN\_BR\_DATA\_BRP = "data\_brp";  
    /// <summary>  
    /// TSEG1 segment for fast data bit rate in time quanta  
    /// </summary>  
    public const string PCAN\_BR\_DATA\_TSEG1 = "data\_tseg1";  
    /// <summary>  
    /// TSEG2 segment for fast data bit rate in time quanta  
    /// </summary>  
    public const string PCAN\_BR\_DATA\_TSEG2 = "data\_tseg2";  
    /// <summary>  
    /// Synchronization Jump Width for highspeed data bit rate in time quanta  
    /// </summary>  
    public const string PCAN\_BR\_DATA\_SJW = "data\_sjw";  
    /// <summary>  
    /// Secondary sample point delay for highspeed data bit rate in cyles  
    /// </summary>  
    public const string PCAN\_BR\_DATA\_SAMPLE = "data\_ssp\_offset";  
    #endregion

    #region Parameter values definition  
    /// <summary>  
    /// The PCAN parameter is not set (inactive)  
    /// </summary>  
    public const int PCAN\_PARAMETER\_OFF = 0;  
    /// <summary>  
    /// The PCAN parameter is set (active)  
    /// </summary>  
    public const int PCAN\_PARAMETER\_ON = 1;  
    /// <summary>  
    /// The PCAN filter is closed. No messages will be received  
    /// </summary>  
    public const int PCAN\_FILTER\_CLOSE = 0;  
    /// <summary>  
    /// The PCAN filter is fully opened. All messages will be received  
    /// </summary>  
    public const int PCAN\_FILTER\_OPEN = 1;  
    /// <summary>  
    /// The PCAN filter is custom configured. Only registered  
    /// messages will be received  
    /// </summary>  
    public const int PCAN\_FILTER\_CUSTOM = 2;  
    /// <summary>  
    /// The PCAN-Channel handle is illegal, or its associated hardware is not available  
    /// </summary>  
    public const int PCAN\_CHANNEL\_UNAVAILABLE = 0;  
    /// <summary>  
    /// The PCAN-Channel handle is available to be connected (Plug and Play Hardware: it means furthermore that the hardware is plugged-in)  
    /// </summary>  
    public const int PCAN\_CHANNEL\_AVAILABLE = 1;  
    /// <summary>  
    /// The PCAN-Channel handle is valid, and is already being used  
    /// </summary>  
    public const int PCAN\_CHANNEL\_OCCUPIED = 2;  
    /// <summary>  
    /// The PCAN-Channel handle is already being used by a PCAN-View application, but is available to connect  
    /// </summary>  
    public const int PCAN\_CHANNEL\_PCANVIEW = (PCAN\_CHANNEL\_AVAILABLE | PCAN\_CHANNEL\_OCCUPIED);

    /// <summary>  
    /// Logs system exceptions / errors  
    /// </summary>  
    public const int LOG\_FUNCTION\_DEFAULT = 0x00;  
    /// <summary>  
    /// Logs the entries to the PCAN-Basic API functions  
    /// </summary>  
    public const int LOG\_FUNCTION\_ENTRY = 0x01;  
    /// <summary>  
    /// Logs the parameters passed to the PCAN-Basic API functions  
    /// </summary>  
    public const int LOG\_FUNCTION\_PARAMETERS = 0x02;  
    /// <summary>  
    /// Logs the exits from the PCAN-Basic API functions  
    /// </summary>  
    public const int LOG\_FUNCTION\_LEAVE = 0x04;  
    /// <summary>  
    /// Logs the CAN messages passed to the CAN\_Write function  
    /// </summary>  
    public const int LOG\_FUNCTION\_WRITE = 0x08;  
    /// <summary>  
    /// Logs the CAN messages received within the CAN\_Read function  
    /// </summary>  
    public const int LOG\_FUNCTION\_READ = 0x10;  
    /// <summary>  
    /// Logs all possible information within the PCAN-Basic API functions  
    /// </summary>  
    public const int LOG\_FUNCTION\_ALL = 0xFFFF;

    /// <summary>  
    /// A single file is written until it size reaches PAN\_TRACE\_SIZE  
    /// </summary>  
    public const int TRACE\_FILE\_SINGLE = 0x00;  
    /// <summary>  
    /// Traced data is distributed in several files with size PAN\_TRACE\_SIZE  
    /// </summary>  
    public const int TRACE\_FILE\_SEGMENTED = 0x01;  
    /// <summary>  
    /// Includes the date into the name of the trace file  
    /// </summary>  
    public const int TRACE\_FILE\_DATE = 0x02;  
    /// <summary>  
    /// Includes the start time into the name of the trace file  
    /// </summary>  
    public const int TRACE\_FILE\_TIME = 0x04;  
    /// <summary>  
    /// Causes the overwriting of available traces (same name)  
    /// </summary>  
    public const int TRACE\_FILE\_OVERWRITE = 0x80;

    /// <summary>  
    /// Device supports flexible data-rate (CAN-FD)  
    /// </summary>  
    public const int FEATURE\_FD\_CAPABLE = 0x01;  
    /// <summary>  
    /// Device supports a delay between sending frames (FPGA based USB devices)  
    /// </summary>  
    public const int FEATURE\_DELAY\_CAPABLE = 0x02;  
    /// <summary>  
    /// Device supports I/O functionality for electronic circuits (USB-Chip devices)  
    /// </summary>  
    public const int FEATURE\_IO\_CAPABLE = 0x04;

    /// <summary>  
    /// The service is not running  
    /// </summary>  
    public const int SERVICE\_STATUS\_STOPPED = 0x01;  
    /// <summary>  
    /// The service is running  
    /// </summary>  
    public const int SERVICE\_STATUS\_RUNNING = 0x04;  
    #endregion

    #region PCANBasic API Implementation  
    /// <summary>  
    /// Initializes a PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="Btr0Btr1">The speed for the communication (BTR0BTR1 code)</param>  
    /// <param name="HwType">NON PLUG and PLAY: The type of hardware and operation mode</param>  
    /// <param name="IOPort">NON PLUG and PLAY: The I/O address for the parallel port</param>  
    /// <param name="Interrupt">NON PLUG and PLAY: Interrupt number of the parallel por</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_Initialize")\]  
    public static extern TPCANStatus Initialize(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANBaudrate Btr0Btr1,  
        \[MarshalAs(UnmanagedType.U1)\]  
        TPCANType HwType,  
        UInt32 IOPort,  
        UInt16 Interrupt);

    /// <summary>  
    /// Initializes a PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="Btr0Btr1">The speed for the communication (BTR0BTR1 code)</param>  
    /// <returns>A TPCANStatus error code</returns>  
    public static TPCANStatus Initialize(  
        TPCANHandle Channel,  
        TPCANBaudrate Btr0Btr1)  
    {  
        return Initialize(Channel, Btr0Btr1, (TPCANType)0, 0, 0);  
    }

    /// <summary>  
    /// Initializes a FD capable PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a FD capable PCAN Channel</param>  
    /// <param name="BitrateFD">The speed for the communication (FD bit rate string)</param>  
    /// <remarks> See PCAN\_BR\_\* values  
    /// Bit rate string must follow the following construction rules:  
    /// \* parameters 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\_sam</remarks>  
    /// <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</example>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_InitializeFD")\]  
    public static extern TPCANStatus InitializeFD(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        TPCANBitrateFD BitrateFD);

    /// <summary>  
    /// Uninitializes one or all PCAN Channels initialized by CAN\_Initialize  
    /// </summary>  
    /// <remarks>Giving the TPCANHandle value "PCAN\_NONEBUS",  
    /// uninitialize all initialized channels</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_Uninitialize")\]  
    public static extern TPCANStatus Uninitialize(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel);

    /// <summary>  
    /// Resets the receive and transmit queues of the PCAN Channel  
    /// </summary>  
    /// <remarks>A reset of the CAN controller is not performed</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_Reset")\]  
    public static extern TPCANStatus Reset(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel);

    /// <summary>  
    /// Gets the current status of a PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_GetStatus")\]  
    public static extern TPCANStatus GetStatus(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel);

    /// <summary>  
    /// Reads a CAN message from the receive queue of a PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="MessageBuffer">A TPCANMsg structure buffer to store the CAN message</param>  
    /// <param name="TimestampBuffer">A TPCANTimestamp structure buffer to get  
    /// the reception time of the message</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_Read")\]  
    public static extern TPCANStatus Read(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        out TPCANMsg MessageBuffer,  
        out TPCANTimestamp TimestampBuffer);

    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_Read")\]  
    private static extern TPCANStatus Read(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        out TPCANMsg MessageBuffer,  
        IntPtr bufferPointer);

    /// <summary>  
    /// Reads a CAN message from the receive queue of a PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="MessageBuffer">A TPCANMsg structure buffer to store the CAN message</param>  
    /// <returns>A TPCANStatus error code</returns>  
    public static TPCANStatus Read(  
        TPCANHandle Channel,  
        out TPCANMsg MessageBuffer)  
    {  
        return Read(Channel, out MessageBuffer, IntPtr.Zero);  
    }

    /// <summary>  
    /// Reads a CAN message from the receive queue of a FD capable PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a FD capable PCAN Channel</param>  
    /// <param name="MessageBuffer">A TPCANMsgFD structure buffer to store the CAN message</param>  
    /// <param name="TimestampBuffer">A TPCANTimestampFD buffer to get the  
    /// reception time of the message</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_ReadFD")\]  
    public static extern TPCANStatus ReadFD(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        out TPCANMsgFD MessageBuffer,  
        out TPCANTimestampFD TimestampBuffer);

    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_ReadFD")\]  
    private static extern TPCANStatus ReadFD(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        out TPCANMsgFD MessageBuffer,  
        IntPtr TimestampBuffer);

    /// <summary>  
    /// Reads a CAN message from the receive queue of a FD capable PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a FD capable PCAN Channel</param>  
    /// <param name="MessageBuffer">A TPCANMsgFD structure buffer to store the CAN message</param>  
    /// <returns>A TPCANStatus error code</returns>  
    public static TPCANStatus ReadFD(  
        TPCANHandle Channel,  
        out TPCANMsgFD MessageBuffer)  
    {  
        return ReadFD(Channel, out MessageBuffer, IntPtr.Zero);  
    }

    /// <summary>  
    ///  Transmits a CAN message  
    /// </summary>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="MessageBuffer">A TPCANMsg buffer with the message to be sent</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_Write")\]  
    public static extern TPCANStatus Write(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        ref TPCANMsg MessageBuffer);

    /// <summary>  
    /// Transmits a CAN message over a FD capable PCAN Channel  
    /// </summary>  
    /// <param name="Channel">The handle of a FD capable PCAN Channel</param>  
    /// <param name="MessageBuffer">A TPCANMsgFD buffer with the message to be sent</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_WriteFD")\]  
    public static extern TPCANStatus WriteFD(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        ref TPCANMsgFD MessageBuffer);

    /// <summary>  
    /// Configures the reception filter  
    /// </summary>  
    /// <remarks>The message filter will be expanded with every call to  
    /// this function. If it is desired to reset the filter, please use  
    /// the 'SetValue' function</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="FromID">The lowest CAN ID to be received</param>  
    /// <param name="ToID">The highest CAN ID to be received</param>  
    /// <param name="Mode">Message type, Standard (11-bit identifier) or  
    /// Extended (29-bit identifier)</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_FilterMessages")\]  
    public static extern TPCANStatus FilterMessages(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        UInt32 FromID,  
        UInt32 ToID,  
        \[MarshalAs(UnmanagedType.U1)\]  
        TPCANMode Mode);

    /// <summary>  
    /// Retrieves a PCAN Channel value  
    /// </summary>  
    /// <remarks>Parameters can be present or not according with the kind  
    /// of Hardware (PCAN Channel) being used. If a parameter is not available,  
    /// a PCAN\_ERROR\_ILLPARAMTYPE error will be returned</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="Parameter">The TPCANParameter parameter to get</param>  
    /// <param name="StringBuffer">Buffer for the parameter value</param>  
    /// <param name="BufferLength">Size in bytes of the buffer</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_GetValue")\]  
    public static extern TPCANStatus GetValue(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        \[MarshalAs(UnmanagedType.U1)\]  
        TPCANParameter Parameter,  
        StringBuilder StringBuffer,  
        UInt32 BufferLength);

    /// <summary>  
    /// Retrieves a PCAN Channel value  
    /// </summary>  
    /// <remarks>Parameters can be present or not according with the kind  
    /// of Hardware (PCAN Channel) being used. If a parameter is not available,  
    /// a PCAN\_ERROR\_ILLPARAMTYPE error will be returned</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="Parameter">The TPCANParameter parameter to get</param>  
    /// <param name="NumericBuffer">Buffer for the parameter value</param>  
    /// <param name="BufferLength">Size in bytes of the buffer</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_GetValue")\]  
    public static extern TPCANStatus GetValue(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        \[MarshalAs(UnmanagedType.U1)\]  
        TPCANParameter Parameter,  
        out UInt32 NumericBuffer,  
        UInt32 BufferLength);

    /// <summary>  
    /// Retrieves a PCAN Channel value  
    /// </summary>  
    /// <remarks>Parameters can be present or not according with the kind  
    /// of Hardware (PCAN Channel) being used. If a parameter is not available,  
    /// a PCAN\_ERROR\_ILLPARAMTYPE error will be returned</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="Parameter">The TPCANParameter parameter to get</param>  
    /// <param name="NumericBuffer">Buffer for the parameter value</param>  
    /// <param name="BufferLength">Size in bytes of the buffer</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_GetValue")\]  
    public static extern TPCANStatus GetValue(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        \[MarshalAs(UnmanagedType.U1)\]  
        TPCANParameter Parameter,  
        out UInt64 NumericBuffer,  
        UInt32 BufferLength);

    /// <summary>  
    /// Configures or sets a PCAN Channel value  
    /// </summary>  
    /// <remarks>Parameters can be present or not according with the kind  
    /// of Hardware (PCAN Channel) being used. If a parameter is not available,  
    /// a PCAN\_ERROR\_ILLPARAMTYPE error will be returned</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="Parameter">The TPCANParameter parameter to set</param>  
    /// <param name="NumericBuffer">Buffer with the value to be set</param>  
    /// <param name="BufferLength">Size in bytes of the buffer</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_SetValue")\]  
    public static extern TPCANStatus SetValue(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        \[MarshalAs(UnmanagedType.U1)\]  
        TPCANParameter Parameter,  
        ref UInt32 NumericBuffer,  
        UInt32 BufferLength);

    /// <summary>  
    /// Configures or sets a PCAN Channel value  
    /// </summary>  
    /// <remarks>Parameters can be present or not according with the kind  
    /// of Hardware (PCAN Channel) being used. If a parameter is not available,  
    /// a PCAN\_ERROR\_ILLPARAMTYPE error will be returned</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="Parameter">The TPCANParameter parameter to set</param>  
    /// <param name="NumericBuffer">Buffer with the value to be set</param>  
    /// <param name="BufferLength">Size in bytes of the buffer</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_SetValue")\]  
    public static extern TPCANStatus SetValue(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        \[MarshalAs(UnmanagedType.U1)\]  
        TPCANParameter Parameter,  
        ref UInt64 NumericBuffer,  
        UInt32 BufferLength);

    /// <summary>  
    /// Configures or sets a PCAN Channel value  
    /// </summary>  
    /// <remarks>Parameters can be present or not according with the kind  
    /// of Hardware (PCAN Channel) being used. If a parameter is not available,  
    /// a PCAN\_ERROR\_ILLPARAMTYPE error will be returned</remarks>  
    /// <param name="Channel">The handle of a PCAN Channel</param>  
    /// <param name="Parameter"></param>  
    /// <param name="StringBuffer">Buffer with the value to be set</param>  
    /// <param name="BufferLength">Size in bytes of the buffer</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_SetValue")\]  
    public static extern TPCANStatus SetValue(  
        \[MarshalAs(UnmanagedType.U2)\]  
        TPCANHandle Channel,  
        \[MarshalAs(UnmanagedType.U1)\]  
        TPCANParameter Parameter,  
        \[MarshalAs(UnmanagedType.LPStr,SizeParamIndex=3)\]  
        string StringBuffer,  
        UInt32 BufferLength);

    /// <summary>  
    /// Returns a descriptive text of a given TPCANStatus error  
    /// code, in any desired language  
    /// </summary>  
    /// <remarks>The current languages available for translation are:  
    /// Neutral (0x00), German (0x07), English (0x09), Spanish (0x0A),  
    /// Italian (0x10) and French (0x0C)</remarks>  
    /// <param name="Error">A TPCANStatus error code</param>  
    /// <param name="Language">Indicates a 'Primary language ID'</param>  
    /// <param name="StringBuffer">Buffer for the text (must be at least 256 in length)</param>  
    /// <returns>A TPCANStatus error code</returns>  
    \[DllImport("PCANBasic.dll", EntryPoint = "CAN\_GetErrorText")\]  
    public static extern TPCANStatus GetErrorText(  
        \[MarshalAs(UnmanagedType.U4)\]  
        TPCANStatus Error,  
        UInt16 Language,  
        StringBuilder StringBuffer);  
    #endregion  
}  
#endregion  

}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章