Documentation
Documentation
PCAN-Basic Documentation
Introduction
Welcome to the documentation to PCAN-Basic.
In this Chapter
Topics Description
Understanding This section contains an introduction to
PCAN-Basic PCAN-Basic API.
Using Events Offers support about how to read CAN
messages using notifications.
License License regulations to this software.
Regulations
Contact Contact information - PEAK-System Technik
information GmbH.
Understanding PCAN-Basic
PCAN-Basic is the new version of the PCAN-Light API. It consists of a
collection of Windows Device Drivers which allow the real-time
connection of Windows applications to all CAN busses physically
connected to a PC.
See Also
PCAN Fundamentals
PCAN-Light
PCAN-API
Using Events
Event objects can be used to automatically notify a client on reception
of a CAN message. This has following advantages:
The client program doesn't need to check periodically for
received messages any longer.
The response time on received messages is reduced.
To use events, the client application must call the CAN_SetValue
(class-method: SetValue) function to set the parameter
PCAN_RECEIVE_EVENT. This parameter sets the handle for the
event object. When receiving a message, the driver sets this event to
the "Signaled" state.
Another thread must be started in the client application, which waits
for the event to be signaled, using one of the Win32 synchronization
functions (e.g. WaitForSingleObject) without increasing the
processor load. After the event is signaled, the receive buffer of the
client can be read with the CAN_Read (class method: Read)
function, and the CAN messages can be processed.
Remarks
See Also
License Regulations
Namings for products in this manual, that are registered trademarks,
are not separately marked. Therefore the missing of the ® sign does
not implicate, that the naming is a free trade name. Furthermore the
used names do not indicate patent rights or anything similar. PEAK-
System Technik GmbH makes no representation or warranties with
respect to the use of enclosed software or the contents of this
manual, and specifically disclaims any express or implied warranties
of merchantability or fitness for any particular purpose. Further,
PEAK-System Technik GmbH reserves the right to revise this
publication and to make changes to its content, at any time, without
obligation to notify any person or entity of such revisions or changes.
See Also
Contact Information
Contact Information
This software is a product of:
Info: [email protected]
Support: support@peak-
system.com
Web: www.peak-system.com
Reference
This section contains information about the data types (classes,
structures, types, defines, enumerations) and API functions which are
contained in the PCAN-Basic API.
In this Chapter
Topic Description
Namespaces Lists the defined namespaces for Microsoft's .NET
Framework programming environment.
Modules Lists the defined modules for Python 2.6
programming environment.
Units Lists the defined units for Delphi's programming
environment.
Classes Lists the defined classes that implement the
PCAN-Basic API.
Structures Lists the defined structures.
Types Lists the defined types.
Methods Lists the defined class methods for using the
PCAN-Basic API.
Functions List the defined functions for using the PCAN-
Basic API.
Definitions Lists the defined values.
Namespaces
PEAK offers the implementation of some specific programming
interfaces as namespaces for the .NET Framework programming
environment. The following namespaces are available to be used:
Namespaces
Name Description
{} Peak Contains all namespaces that are part of
the managed programming environment
from PEAK-System.
{} Peak.Can Contains types and classes for using the
PCAN API from PEAK-System.
{} Peak.Can.Light Contains types and classes for using the
PCAN-Light API from PEAK-System.
{} Peak.Can.Basic Contains types and classes for using the
PCAN-Basic API from PEAK-System.
{} Peak.Lin Contains types and classes used to handle
with LIN devices from PEAK-System.
{} Peak.RP1210A Contains types and classes used to handle
with CAN devices from PEAK-System
through the TMC Recommended Practices
1210, version A, as known as RP1210(A).
Peak.Can.Basic
The Peak.Can.Basic namespace contain types and classes for using
the PCAN-Basic API within the .NET Framework programming
environment, in order to handle with PCAN devices from PEAK-
System.
Remarks
Aliases
Alias Description
TPCANHandle Represents a PCAN-hardware
channel handle.
TPCANBitrateFD Represents a bit rate with flexible data
rate.
TPCANTimestampFD Represents the timestamp of a CAN
message with flexible data rate.
Classes
Class Description
PCANBasic Defines a class which represents the
PCAN-Basic API.
Structures
Structure Description
TPCANMsg Defines a CAN message.
Enumerations
Enumeration Description
TPCANStatus Represents a PCAN status/error
code.
TPCANDevice Represents a PCAN device.
Modules
PEAK offers the implementation of some specific programming
interfaces as modules for programming under Python (ver. 2.6). The
following modules are available to be used:
Modules
Name Description
{} PCAN- Python module for using the PCAN-Basic API
Basic- from PEAK-System.
Module
PCANBasic Module
The Peak.Can.Basic module contain types and classes for using the
PCAN-Basic API within Python 2.6 programming environment, in
order to handle with PCAN devices from PEAK-System.
Classes
Class Description
PCANBasic Defines a class which represents the
PCAN-Basic API.
Structures
Structure Description
TPCANMsg Defines a CAN message. The
members of this structure are
sequentially byte aligned.
TPCANTimestamp Defines a time-stamp of a CAN
message.
TPCANMsgFD Defines a CAN message with flexible
data rate.
Units
PEAK offers the implementation of some specific programming
interfaces as Units for the Delphi's programming environment. The
following units are available to be used:
Units
Name Description
{} PCANBasic- Delphi unit for using the PCAN-Basic API from
Unit PEAK-System.
PCANBasic Unit
The PCANBasic-Unit contain types and classes for using the PCAN-
Basic API within the Delphi's programming environment, in order to
handle with PCAN devices from PEAK-System.
Remarks
Aliases
Alias Description
TPCANHandle Represents a PCAN-hardware
channel handle.
TPCANBitrateFD Represents a bit rate with flexible data
rate.
TPCANTimestampFD Represents the timestamp of a CAN
message with flexible data rate.
Classes
Class Description
TPCANBasic Defines a class which represents the
PCAN-Basic API.
Structures
Structure Description
TPCANMsg Defines a CAN message.
Enumerations
Enumeration Description
TPCANStatus Represents a PCAN status/error
code.
TPCANDevice Represents a PCAN device.
Classes
The following classes are offered to make use of the PCAN-Basic API
in a managed or unmanaged way.
Classes
Class Description
PCANBasic Defines a class to use the PCAN-
Basic API within the Microsoft's .NET
Framework programming
environment, and Python.
TPCANBasic Defines a class to use the PCAN-
Basic API within the Delphi
programming environment.
PCANBasic
Defines a class which represents the PCAN-Basic API for using within
the Microsoft's .NET Framework and Python (ver. 2.6).
Syntax
C#
public static class PCANBasic
C++ / CLR
public ref class PCANBasic abstract sealed
Visual Basic
Public NotInheritable Class PCANBasic
Python
class PCANBasic
Remarks
See Also
Methods
Definitions
Delphi: TPCANBasic
TPCANBasic
Defines a class which represents the PCAN-Basic API in the Delphi
programming environment.
Syntax
Pascal OO
TPCANBasic = class
Remarks
See Also
Methods
Definitions
Structures
The PCAN-Basic API defines the following structures:
Name Description
TPCANMsg Defines a CAN message.
TPCANTimestamp Defines the point of time at which a
CAN message was received.
TPCANMsgFD Defines a CAN message with flexible
data rate.
See Also
Reference
TPCANMsg
Defines a CAN message.
Syntax
C++
typedef struct
{
DWORD ID;
TPCANMessageType MSGTYPE;
BYTE LEN;
BYTE DATA[8];
} TPCANMsg;
Pascal OO
TPCANMsg = record
ID: Longword;
MSGTYPE: TPCANMessageType;
LEN: Byte;
DATA: array[0..7] of Byte;
end;
C#
public struct TPCANMsg
{
public uint ID;
[MarshalAs(UnmanagedType.U1)]
public TPCANMessageType MSGTYPE;
public byte LEN;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8
public byte[] DATA;
}
C++ / CLR
public value struct TPCANMsg
{
UInt32 ID;
[MarshalAs(UnmanagedType.U1)]
TPCANMessageType MSGTYPE;
Byte LEN;
[MarshalAs(UnmanagedType::ByValArray, SizeConst =
array<Byte>^ DATA;
}
Visual Basic
Public Structure TPCANMsg
Public ID As UInt32
<MarshalAs(UnmanagedType.U1)> _
Public MSGTYPE As TPCANMessageType
Public LEN As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst :=
Public DATA As Byte()
End Structure
Python
from ctypes import *
class TPCANMsg (Structure):
_fields_ = [ ("ID", c_uint),
("MSGTYPE", TPCANMessageType),
("LEN", c_ubyte),
("DATA", c_ubyte * 8) ]
Remarks
Fields
Name Description
ID 11/29-bit message identifier.
MSGTYPE Type of the message. Bit mask indicating the
type of the message. Several message types
can be combined.
LEN Data Length Code of the message (0..8).
DATA Data of the message (DATA[0]..DATA[7]).
See Also
TPCANTimestamp
Defines a time-stamp of a CAN message. The time-stamp contains
the number of microseconds since the start of Windows.
Syntax
C++
typedef struct
{
DWORD millis;
WORD millis_overflow;
WORD micros;
} TPCANTimestamp;
Pascal OO
TPCANTimestamp = record
millis: Longword;
millis_overflow: Word;
micros: Word;
end;
C#
public struct TPCANTimestamp
{
public uint millis;
public ushort millis_overflow;
public ushort micros;
}
C++ / CLR
public value struct TPCANTimestamp
{
UInt32 millis;
UInt16 millis_overflow;
UInt16 micros;
};
Visual Basic
Public Structure TPCANTimestamp
Public millis As UInt32
Public millis_overflow As UInt16
Public micros As UInt16
End Structure
Python
from ctypes import *
class TPCANTimestamp (Structure):
_fields_ = [ ("millis", c_uint),
("millis_overflow", c_ushort),
("micros", c_ushort) ]
Remarks
Fields
Name Description
millis Base-value: milliseconds: 0.. 2^32-1.
millis_overflow Roll-arounds of millis.
micros Microseconds: 0..999.
See Also
CAN_Write (class-method: Write)
TPCANMsg
TPCANMsgFD
Defines a CAN message with flexible data rate.
Syntax
C++
typedef struct
{
DWORD ID;
TPCANMessageType MSGTYPE;
BYTE DLC;
BYTE DATA[64];
} TPCANMsgFD;
Pascal OO
TPCANMsgFD = record
ID: Longword;
MSGTYPE: TPCANMessageType;
DLC: Byte;
DATA: array[0..63] of Byte;
end;
C#
public struct TPCANMsgFD
{
public uint ID;
[MarshalAs(UnmanagedType.U1)]
public TPCANMessageType MSGTYPE;
public byte DLC;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6
public byte[] DATA;
}
C++ / CLR
public value struct TPCANMsgFD
{
UInt32 ID;
[MarshalAs(UnmanagedType::U1)]
TPCANMessageType MSGTYPE;
Byte DLC;
[MarshalAs(UnmanagedType::ByValArray, SizeConst =
array<Byte>^ DATA;
};
Visual Basic
Public Structure TPCANMsgFD
Public ID As UInt32
<MarshalAs(UnmanagedType.U1)> _
Public MSGTYPE As TPCANMessageType
Public DLC As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=64
Public DATA As Byte()
End Structure
Python
from ctypes import *
class TPCANMsgFD (Structure):
_fields_ = [ ("ID", c_uint),
("MSGTYPE", TPCANMessageType),
("DLC", c_ubyte),
("DATA", c_ubyte * 64) ]
Remarks
Fields
Name Description
ID 11/29-bit message identifier.
MSGTYPE Type of the message. Bit mask indicating the
type of the message. Several message types
can be combined.
DLC Data Length Code of the message (0..15).
DATA Data of the message (DATA[0]..DATA[63]).
Remark
DLC Data
Bytes
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 12
10 16
11 20
12 24
13 32
14 48
15 64
See Also
Types
The PCAN-Basic API defines the following types:
Name Description
TPCANHandle Represents a PCAN hardware channel
handle.
TPCANStatus Represents a PCAN status/error code.
TPCANDevice Represents a PCAN device.
TPCANParameter Represents a PCAN parameter to be
read or set.
TPCANMessageType Represents the type of a PCAN
message.
TPCANType Represents the type of PCAN hardware
to be initialized.
TPCANMode Represents a PCAN filter mode.
TPCANBaudrate Represents a PCAN bit rate register
value.
TPCANBitrateFD Represents a bit rate string with flexible
data rate.
TPCANTimestampFD Represents the timestamp of a CAN
message with flexible data rate.
TPCANHandle
Represents a PCAN-hardware channel handle.
Syntax
C++
#define TPCANHandle WORD
Pascal OO
TPCANHandle = Word;
C#
using TPCANHandle = System.UInt16;
C++ / CLR
#define TPCANHandle System::UInt16
Visual Basic
Imports TPCANHandle = System.UInt16
Python
TPCANHandle = c_ushort
Remarks
FD capable Hardware:
Some hardware can transmit using a flexible data rate (FD capable).
Although there are no special PCAN-Handles to identify these
hardware, it is possible to ask if a hardware is able to communicate
using the FD protocol. The PCAN-Basic parameter
PCAN_CHANNEL_FEATURES allows to investigate whether a
hardware is FD capable before being initialized.
.NET Framework programming languages:
An alias is used to represent a Channel handle under Microsoft .NET
in order to originate an homogeneity between all programming
languages listed above.
Aliases are defined in the Peak.Can.Basic Namespace for C# and VB
.NET. However, including a namespace does not include the defined
aliases.
If it is wished to work with aliases, those must be copied to the
working file, right after the inclusion of the Peak.Can.Basic
Namespace. Otherwise, just use the native type, which in this case is
a UInt16.
C#:
using System;
using Peak.Can.Basic;
using TPCANHandle = System.UInt16; // Alias's declaration f
Visual Basic:
Imports System
Imports Peak.Can.Basic
Imports TPCANHandle = System.UInt16 ' Alias declaration for
See Also
TPCANStatus
Represents a PCAN status/error code. According with the
programming language, this type can be a group of defined values or
an enumeration.
Syntax
C++
#define TPCANStatus DWORD
Pascal OO
{$Z4}
TPCANStatus = (
PCAN_ERROR_OK = $00000,
PCAN_ERROR_XMTFULL = $00001,
PCAN_ERROR_OVERRUN = $00002,
PCAN_ERROR_BUSLIGHT = $00004,
PCAN_ERROR_BUSHEAVY = $00008,
PCAN_ERROR_BUSHWARNING = Byte(PCAN_ERROR_BUSHEAVY
PCAN_ERROR_BUSPASSIVE = $40000,
PCAN_ERROR_BUSOFF = $00010,
PCAN_ERROR_ANYBUSERR = Byte(PCAN_ERROR_BUSHWARNING
PCAN_ERROR_QRCVEMPTY = $00020,
PCAN_ERROR_QOVERRUN = $00040,
PCAN_ERROR_QXMTFULL = $00080,
PCAN_ERROR_REGTEST = $00100,
PCAN_ERROR_NODRIVER = $00200,
PCAN_ERROR_HWINUSE = $00400,
PCAN_ERROR_NETINUSE = $00800,
PCAN_ERROR_ILLHW = $01400,
PCAN_ERROR_ILLNET = $01800,
PCAN_ERROR_ILLCLIENT = $01C00,
PCAN_ERROR_ILLHANDLE = Byte(PCAN_ERROR_ILLHW
PCAN_ERROR_RESOURCE = $02000,
PCAN_ERROR_ILLPARAMTYPE = $04000,
PCAN_ERROR_ILLPARAMVAL = $08000,
PCAN_ERROR_UNKNOWN = $10000,
PCAN_ERROR_ILLDATA = $20000,
PCAN_ERROR_CAUTION = $2000000,
PCAN_ERROR_INITIALIZE = $4000000,
PCAN_ERROR_ILLOPERATION = $8000000
);
C#
[Flags]
public enum TPCANStatus : uint
{
PCAN_ERROR_OK = 0x00000,
PCAN_ERROR_XMTFULL = 0x00001,
PCAN_ERROR_OVERRUN = 0x00002,
PCAN_ERROR_BUSLIGHT = 0x00004,
PCAN_ERROR_BUSHEAVY = 0x00008,
PCAN_ERROR_BUSWARNING = PCAN_ERROR_BUSHEAVY,
PCAN_ERROR_BUSPASSIVE = 0x40000,
PCAN_ERROR_BUSOFF = 0x00010,
PCAN_ERROR_ANYBUSERR = (PCAN_ERROR_BUSWARNING
PCAN_ERROR_QRCVEMPTY = 0x00020,
PCAN_ERROR_QOVERRUN = 0x00040,
PCAN_ERROR_QXMTFULL = 0x00080,
PCAN_ERROR_REGTEST = 0x00100,
PCAN_ERROR_NODRIVER = 0x00200,
PCAN_ERROR_HWINUSE = 0x00400,
PCAN_ERROR_NETINUSE = 0x00800,
PCAN_ERROR_ILLHW = 0x01400,
PCAN_ERROR_ILLNET = 0x01800,
PCAN_ERROR_ILLCLIENT = 0x01C00,
PCAN_ERROR_ILLHANDLE = (PCAN_ERROR_ILLHW |
PCAN_ERROR_RESOURCE = 0x02000,
PCAN_ERROR_ILLPARAMTYPE = 0x04000,
PCAN_ERROR_ILLPARAMVAL = 0x08000,
PCAN_ERROR_UNKNOWN = 0x10000,
PCAN_ERROR_ILLDATA = 0x20000,
PCAN_ERROR_CAUTION = 0x2000000,
PCAN_ERROR_INITIALIZE = 0x4000000,
PCAN_ERROR_ILLOPERATION = 0x8000000,
}
C++ / CLR
[Flags]
public enum class TPCANStatus : UInt32
{
PCAN_ERROR_OK = 0x00000,
PCAN_ERROR_XMTFULL = 0x00001,
PCAN_ERROR_OVERRUN = 0x00002,
PCAN_ERROR_BUSLIGHT = 0x00004,
PCAN_ERROR_BUSHEAVY = 0x00008,
PCAN_ERROR_BUSWARNING = PCAN_ERROR_BUSHEAVY
PCAN_ERROR_BUSPASSIVE = 0x40000,
PCAN_ERROR_BUSOFF = 0x00010,
PCAN_ERROR_ANYBUSERR = (PCAN_ERROR_BUSWARNING | PC
PCAN_ERROR_QRCVEMPTY = 0x00020,
PCAN_ERROR_QOVERRUN = 0x00040,
PCAN_ERROR_QXMTFULL = 0x00080,
PCAN_ERROR_REGTEST = 0x00100,
PCAN_ERROR_NODRIVER = 0x00200,
PCAN_ERROR_HWINUSE = 0x00400,
PCAN_ERROR_NETINUSE = 0x00800,
PCAN_ERROR_ILLHW = 0x01400,
PCAN_ERROR_ILLNET = 0x01800,
PCAN_ERROR_ILLCLIENT = 0x01C00,
PCAN_ERROR_ILLHANDLE = (PCAN_ERROR_ILLHW |
PCAN_ERROR_RESOURCE = 0x02000,
PCAN_ERROR_ILLPARAMTYPE = 0x04000,
PCAN_ERROR_ILLPARAMVAL = 0x08000,
PCAN_ERROR_UNKNOWN = 0x10000,
PCAN_ERROR_ILLDATA = 0x20000,
PCAN_ERROR_CAUTION = 0x2000000,
PCAN_ERROR_INITIALIZE = 0x4000000,
PCAN_ERROR_ILLOPERATION = 0x8000000,
}
Visual Basic
<Flags()> _
Public Enum TPCANStatus As UInt32
PCAN_ERROR_OK = &H0
PCAN_ERROR_XMTFULL = &H1
PCAN_ERROR_OVERRUN = &H2
PCAN_ERROR_BUSLIGHT = &H4
PCAN_ERROR_BUSHEAVY = &H8
PCAN_ERROR_BUSWARNING = PCAN_ERROR_BUSHEAVY
PCAN_ERROR_BUSPASSIVE = &H40000
PCAN_ERROR_BUSOFF = &H10
PCAN_ERROR_ANYBUSERR = (PCAN_ERROR_BUSWARNING
PCAN_ERROR_QRCVEMPTY = &H20
PCAN_ERROR_QOVERRUN = &H40
PCAN_ERROR_QXMTFULL = &H80
PCAN_ERROR_REGTEST = &H100
PCAN_ERROR_NODRIVER = &H200
PCAN_ERROR_HWINUSE = &H400
PCAN_ERROR_NETINUSE = &H800
PCAN_ERROR_ILLHW = &H1400
PCAN_ERROR_ILLNET = &H1800
PCAN_ERROR_ILLCLIENT = &H1C00
PCAN_ERROR_ILLHANDLE = (PCAN_ERROR_ILLHW Or
PCAN_ERROR_RESOURCE = &H2000
PCAN_ERROR_ILLPARAMTYPE = &H4000
PCAN_ERROR_ILLPARAMVAL = &H8000
PCAN_ERROR_UNKNOWN = &H10000
PCAN_ERROR_ILLDATA = &H20000
PCAN_ERROR_CAUTION = &H2000000
PCAN_ERROR_INITIALIZE = &H4000000
PCAN_ERROR_ILLOPERATION = &H8000000
End Enum
Python
TPCANStatus = int
PCAN_ERROR_OK = TPCANStatus(0x00000)
PCAN_ERROR_XMTFULL = TPCANStatus(0x00001)
PCAN_ERROR_OVERRUN = TPCANStatus(0x00002
PCAN_ERROR_BUSLIGHT = TPCANStatus(0x00004)
PCAN_ERROR_BUSHEAVY = TPCANStatus(0x00008)
PCAN_ERROR_BUSWARNING = TPCANStatus(PCAN_ERROR_BUSHEAV
PCAN_ERROR_BUSPASSIVE = TPCANStatus(0x40000)
PCAN_ERROR_BUSOFF = TPCANStatus(0x00010)
PCAN_ERROR_ANYBUSERR = TPCANStatus(PCAN_ERROR_BUSWARNI
PCAN_ERROR_QRCVEMPTY = TPCANStatus(0x00020)
PCAN_ERROR_QOVERRUN = TPCANStatus(0x00040)
PCAN_ERROR_QXMTFULL = TPCANStatus(0x00080)
PCAN_ERROR_REGTEST = TPCANStatus(0x00100)
PCAN_ERROR_NODRIVER = TPCANStatus(0x00200)
PCAN_ERROR_HWINUSE = TPCANStatus(0x00400)
PCAN_ERROR_NETINUSE = TPCANStatus(0x00800)
PCAN_ERROR_ILLHW = TPCANStatus(0x01400)
PCAN_ERROR_ILLNET = TPCANStatus(0x01800)
PCAN_ERROR_ILLCLIENT = TPCANStatus(0x01C00)
PCAN_ERROR_ILLHANDLE = TPCANStatus(PCAN_ERROR_ILLHW
PCAN_ERROR_RESOURCE = TPCANStatus(0x02000)
PCAN_ERROR_ILLPARAMTYPE = TPCANStatus(0x04000)
PCAN_ERROR_ILLPARAMVAL = TPCANStatus(0x08000)
PCAN_ERROR_UNKNOWN = TPCANStatus(0x10000)
PCAN_ERROR_ILLDATA = TPCANStatus(0x20000)
PCAN_ERROR_CAUTION = TPCANStatus(0x2000000)
PCAN_ERROR_INITIALIZE = TPCANStatus(0x4000000)
PCAN_ERROR_ILLOPERATION = TPCANStatus(0x8000000
Remarks
Note that the values of the different PCAN-Status definitions are able
to be bitwise combined. In some cases it is possible to get more than
one error code as result of calling a function.
*Note that the values of PCAN_ERROR_INITIALIZE and
PCAN_ERROR_ILLOPERATION were changed!
PCAN_ERROR_INITIALIZE changed from 0x40000 to 0x4000000
PCAN_ERROR_ILLOPERATION changed from 0x80000 to
0x8000000
Values
TPCANDevice
Represents a PCAN device. According with the programming
language, this type can be a group of defined values or an
enumeration.
Syntax
C++
#define TPCANDevice BYTE
Pascal OO
{$Z1}
TPCANDevice = (
PCAN_NONE = 0,
PCAN_PEAKCAN = 1,
PCAN_ISA = 2,
PCAN_DNG = 3,
PCAN_PCI = 4,
PCAN_USB = 5,
PCAN_PCC = 6,
PCAN_VIRTUAL = 7,
PCAN_LAN = 8
);
C#
public enum TPCANDevice : byte
{
PCAN_NONE = 0,
PCAN_PEAKCAN = 1,
PCAN_ISA = 2,
PCAN_DNG = 3,
PCAN_PCI = 4,
PCAN_USB = 5,
PCAN_PCC = 6,
PCAN_VIRTUAL = 7,
PCAN_LAN = 8
}
C++ / CLR
public enum class TPCANDevice : Byte
{
PCAN_NONE = 0,
PCAN_PEAKCAN = 1,
PCAN_ISA = 2,
PCAN_DNG = 3,
PCAN_PCI = 4,
PCAN_USB = 5,
PCAN_PCC = 6,
PCAN_VIRTUAL = 7,
PCAN_LAN = 8
};
Visual Basic
Public Enum TPCANDevice As Byte
PCAN_NONE = 0
PCAN_PEAKCAN = 1
PCAN_ISA = 2
PCAN_DNG = 3
PCAN_PCI = 4
PCAN_USB = 5
PCAN_PCC = 6
PCAN_VIRTUAL = 7
PCAN_LAN = 8
End Enum
Python
TPCANDevice = c_ubyte
PCAN_NONE = TPCANDevice(0x00)
PCAN_PEAKCAN = TPCANDevice(0x01)
PCAN_ISA = TPCANDevice(0x02)
PCAN_DNG = TPCANDevice(0x03)
PCAN_PCI = TPCANDevice(0x04)
PCAN_USB = TPCANDevice(0x05)
PCAN_PCC = TPCANDevice(0x06)
PCAN_VIRTUAL = TPCANDevice(0x07)
PCAN_LAN = TPCANDevice(0x08)
Remarks
Values
TPCANParameter
Represents a PCAN parameter or a PCAN Value that can be read or
set. According with the programming language, this type can be a
group of defined values or an enumeration. With some exceptions, a
channel must first be initialized before their parameters can be read or
set.
Syntax
C++
#define TPCANParameter BYTE
Pascal OO
{$Z1}
TPCANParameter = (
PCAN_DEVICE_NUMBER = 1,
PCAN_5VOLTS_POWER = 2,
PCAN_RECEIVE_EVENT = 3,
PCAN_MESSAGE_FILTER = 4,
PCAN_API_VERSION = 5,
PCAN_CHANNEL_VERSION = 6,
PCAN_BUSOFF_AUTORESET = 7,
PCAN_LISTEN_ONLY = 8,
PCAN_LOG_LOCATION = 9,
PCAN_LOG_STATUS = 10,
PCAN_LOG_CONFIGURE = 11,
PCAN_LOG_TEXT = 12,
PCAN_CHANNEL_CONDITION = 13,
PCAN_HARDWARE_NAME = 14,
PCAN_RECEIVE_STATUS = 15,
PCAN_CONTROLLER_NUMBER = 16,
PCAN_TRACE_LOCATION = 17,
PCAN_TRACE_STATUS = 18,
PCAN_TRACE_SIZE = 19,
PCAN_TRACE_CONFIGURE = 20,
PCAN_CHANNEL_IDENTIFYING = 21,
PCAN_CHANNEL_FEATURES = 22,
PCAN_BITRATE_ADAPTING = 23,
PCAN_BITRATE_INFO = 24,
PCAN_BITRATE_INFO_FD = 25,
PCAN_BUSSPEED_NOMINAL = 26,
PCAN_BUSSPEED_DATA = 27,
PCAN_IP_ADDRESS = 28,
PCAN_LAN_SERVICE_STATUS = 29,
PCAN_ALLOW_STATUS_FRAMES = 30,
PCAN_ALLOW_RTR_FRAMES = 31,
PCAN_ALLOW_ERROR_FRAMES = 32,
PCAN_INTERFRAME_DELAY = 33,
PCAN_ACCEPTANCE_FILTER_11BIT = 34,
PCAN_ACCEPTANCE_FILTER_29BIT = 35
);
C#
public enum TPCANParameter : byte
{
PCAN_DEVICE_NUMBER = 1,
PCAN_5VOLTS_POWER = 2,
PCAN_RECEIVE_EVENT = 3,
PCAN_MESSAGE_FILTER = 4,
PCAN_API_VERSION = 5,
PCAN_CHANNEL_VERSION = 6,
PCAN_BUSOFF_AUTORESET = 7,
PCAN_LISTEN_ONLY = 8,
PCAN_LOG_LOCATION = 9,
PCAN_LOG_STATUS = 10,
PCAN_LOG_CONFIGURE = 11,
PCAN_LOG_TEXT = 12,
PCAN_CHANNEL_CONDITION = 13,
PCAN_HARDWARE_NAME = 14,
PCAN_RECEIVE_STATUS = 15,
PCAN_CONTROLLER_NUMBER = 16,
PCAN_TRACE_LOCATION = 17,
PCAN_TRACE_STATUS = 18,
PCAN_TRACE_SIZE = 19,
PCAN_TRACE_CONFIGURE = 20,
PCAN_CHANNEL_IDENTIFYING = 21,
PCAN_CHANNEL_FEATURES = 22,
PCAN_BITRATE_ADAPTING = 23,
PCAN_BITRATE_INFO = 24,
PCAN_BITRATE_INFO_FD = 25,
PCAN_BUSSPEED_NOMINAL = 26,
PCAN_BUSSPEED_DATA = 27,
PCAN_IP_ADDRESS = 28,
PCAN_LAN_SERVICE_STATUS = 29,
PCAN_ALLOW_STATUS_FRAMES = 30,
PCAN_ALLOW_RTR_FRAMES = 31,
PCAN_ALLOW_ERROR_FRAMES = 32,
PCAN_INTERFRAME_DELAY = 33,
PCAN_ACCEPTANCE_FILTER_11BIT = 34,
PCAN_ACCEPTANCE_FILTER_29BIT = 35,
}
C++ / CLR
public enum class TPCANParameter : Byte
{
PCAN_DEVICE_NUMBER = 1,
PCAN_5VOLTS_POWER = 2,
PCAN_RECEIVE_EVENT = 3,
PCAN_MESSAGE_FILTER = 4,
PCAN_API_VERSION = 5,
PCAN_CHANNEL_VERSION = 6,
PCAN_BUSOFF_AUTORESET = 7,
PCAN_LISTEN_ONLY = 8,
PCAN_LOG_LOCATION = 9,
PCAN_LOG_STATUS = 10,
PCAN_LOG_CONFIGURE = 11,
PCAN_LOG_TEXT = 12,
PCAN_CHANNEL_CONDITION = 13,
PCAN_HARDWARE_NAME = 14,
PCAN_RECEIVE_STATUS = 15,
PCAN_CONTROLLER_NUMBER = 16,
PCAN_TRACE_LOCATION = 17,
PCAN_TRACE_STATUS = 18,
PCAN_TRACE_SIZE = 19,
PCAN_TRACE_CONFIGURE = 20,
PCAN_CHANNEL_IDENTIFYING = 21,
PCAN_CHANNEL_FEATURES = 22,
PCAN_BITRATE_ADAPTING = 23,
PCAN_BITRATE_INFO = 24,
PCAN_BITRATE_INFO_FD = 25,
PCAN_BUSSPEED_NOMINAL = 26,
PCAN_BUSSPEED_DATA = 27,
PCAN_IP_ADDRESS = 28,
PCAN_LAN_SERVICE_STATUS = 29,
PCAN_ALLOW_STATUS_FRAMES = 30,
PCAN_ALLOW_RTR_FRAMES = 31,
PCAN_ALLOW_ERROR_FRAMES = 32,
PCAN_INTERFRAME_DELAY = 33,
PCAN_ACCEPTANCE_FILTER_11BIT = 34,
PCAN_ACCEPTANCE_FILTER_29BIT = 35,
};
Visual Basic
Public Enum TPCANParameter As Byte
PCAN_DEVICE_NUMBER = 1
PCAN_5VOLTS_POWER = 2
PCAN_RECEIVE_EVENT = 3
PCAN_MESSAGE_FILTER = 4
PCAN_API_VERSION = 5
PCAN_CHANNEL_VERSION = 6
PCAN_BUSOFF_AUTORESET = 7
PCAN_LISTEN_ONLY = 8
PCAN_LOG_LOCATION = 9
PCAN_LOG_STATUS = 10
PCAN_LOG_CONFIGURE = 11
PCAN_LOG_TEXT = 12
PCAN_CHANNEL_CONDITION = 13
PCAN_HARDWARE_NAME = 14
PCAN_RECEIVE_STATUS = 15
PCAN_CONTROLLER_NUMBER = 16
PCAN_TRACE_LOCATION = 17
PCAN_TRACE_STATUS = 18
PCAN_TRACE_SIZE = 19
PCAN_TRACE_CONFIGURE = 20
PCAN_CHANNEL_IDENTIFYING = 21
PCAN_CHANNEL_FEATURES = 22
PCAN_BITRATE_ADAPTING = 23
PCAN_BITRATE_INFO = 24
PCAN_BITRATE_INFO_FD = 25
PCAN_BUSSPEED_NOMINAL = 26
PCAN_BUSSPEED_DATA = 27
PCAN_IP_ADDRESS = 28
PCAN_LAN_SERVICE_STATUS = 29
PCAN_ALLOW_STATUS_FRAMES = 30
PCAN_ALLOW_RTR_FRAMES = 31
PCAN_ALLOW_ERROR_FRAMES = 32
PCAN_INTERFRAME_DELAY = 33
PCAN_ACCEPTANCE_FILTER_11BIT = 34
PCAN_ACCEPTANCE_FILTER_29BIT = 35
End Enum
Python
TPCANParameter = c_ubyte
PCAN_DEVICE_NUMBER = TPCANParameter(0x01)
PCAN_5VOLTS_POWER = TPCANParameter(0x02)
PCAN_RECEIVE_EVENT = TPCANParameter(0x03)
PCAN_MESSAGE_FILTER = TPCANParameter(0x04)
PCAN_API_VERSION = TPCANParameter(0x05)
PCAN_CHANNEL_VERSION = TPCANParameter(0x06)
PCAN_BUSOFF_AUTORESET = TPCANParameter(0x07)
PCAN_LISTEN_ONLY = TPCANParameter(0x08)
PCAN_LOG_LOCATION = TPCANParameter(0x09)
PCAN_LOG_STATUS = TPCANParameter(0x0A)
PCAN_LOG_CONFIGURE = TPCANParameter(0x0B)
PCAN_LOG_TEXT = TPCANParameter(0x0C)
PCAN_CHANNEL_CONDITION = TPCANParameter(0x0D)
PCAN_HARDWARE_NAME = TPCANParameter(0x0E)
PCAN_RECEIVE_STATUS = TPCANParameter(0x0F)
PCAN_CONTROLLER_NUMBER = TPCANParameter(0x10)
PCAN_TRACE_LOCATION = TPCANParameter(0x11)
PCAN_TRACE_STATUS = TPCANParameter(0x12)
PCAN_TRACE_SIZE = TPCANParameter(0x13)
PCAN_TRACE_CONFIGURE = TPCANParameter(0x14)
PCAN_CHANNEL_IDENTIFYING = TPCANParameter(0x15)
PCAN_CHANNEL_FEATURES = TPCANParameter(0x16)
PCAN_BITRATE_ADAPTING = TPCANParameter(0x17)
PCAN_BITRATE_INFO = TPCANParameter(0x18)
PCAN_BITRATE_INFO_FD = TPCANParameter(0x19)
PCAN_BUSSPEED_NOMINAL = TPCANParameter(0x1A)
PCAN_BUSSPEED_DATA = TPCANParameter(0x1B)
PCAN_IP_ADDRESS = TPCANParameter(0x1C)
PCAN_LAN_SERVICE_STATUS = TPCANParameter(0x1D)
PCAN_ALLOW_STATUS_FRAMES = TPCANParameter(0x1E)
PCAN_ALLOW_RTR_FRAMES = TPCANParameter(0x1F)
PCAN_ALLOW_ERROR_FRAMES = TPCANParameter(0x20)
PCAN_INTERFRAME_DELAY = TPCANParameter(0x21)
PCAN_ACCEPTANCE_FILTER_11BIT = TPCANParameter(0x22)
PCAN_ACCEPTANCE_FILTER_29BIT = TPCANParameter(0x23)
Values
Characteristics
PCAN_DEVICE_NUMBER
Access:
Description: This parameter is used on PCAN-USB hardware to
distinguish between 2 (or more) of them on the same computer. This
value is persistent, i.e. the identifier will not be lost after disconnecting
and connecting again the hardware.
Possible values: According with the Firmware version, this value can
be a number in the range [1..255] or [1..4294967295]. If the Firmware
has a resolution of one byte and the specified value is bigger, than the
value is truncated.
Default value: If this parameter was never set before, the value is the
maximum value possible for the used resolution. For 8-bits: 255
(FFh), for 32 bits: 429496729 (FFFFFFFFh).
PCAN-Device: PCAN-USB.
PCAN_5VOLTS_POWER
Access:
Description: This parameter is used on PCAN-PC Card hardware for
switching the external 5V on the D-Sub connector of the PC Card.
This is useful when connecting external bus converter modules to the
card (AU5790 / TJA1054)).
Possible values: This parameter can have one of these values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Disabled (PCAN_PARAMETER_OFF).
PCAN-Device: PCAN-PC Card, PCAN-HUB.
PCAN_RECEIVE_EVENT
Access:
Description: This parameter is used to let the PCAN driver notify an
application when CAN messages are placed in its receive queue. In
this form, message processing tasks of an application can react faster
and make a more efficient use of the processor time.
Possible values: This value has to be a handle for an event object
returned by the Windows API function CreateEvent or the value 0
(IntPtr.Zero in a managed environment). When setting this parameter,
the value of 0 resets the parameter in the PCAN driver. When reading
the value of 0 indicate that no event handle is set. For more
information about reading with events, please refer to the topic Using
Events.
Default value: Disabled (0).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_MESSAGE_FILTER
Access:
Description: This parameter allows the user to easy configure the
message filter of a PCAN channel. With it is possible to fully open or
complete close the filter.
Possible values: When setting only two values are possible:
PCAN_FILTER_OPEN, PCAN_FILTER_CLOSE. When reading it is
possible to receive a third value, PCAN_FILTER_CUSTOM, which
indicates that the filter is configured to receive a custom range of IDs.
Note that other values will considered invalid.
Default value: Complete opened (PCAN_FILTER_OPEN).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_API_VERSION
Access:
Description: This parameter is used to get information about the
PCAN-Basic API implementation version.
Possible values: The value is a null-terminated string indication the
version number of the API implementation. The returned text has the
following form: x,x,x,x for major, minor, release and build. It
represents the binary version of the API, within two 32-bit integers,
defined by four 16-bit integers. The length of this text value will have a
maximum length of 24 bytes, 5 bytes for represent each 16-bit value,
three separator characters ( , or . ) and the null-termination.
Default value: NA.
PCAN-Device: NA. Any PCAN device can be used, including the
PCAN_NONEBUS channel.
PCAN_CHANNEL_VERSION
Access:
Description: This parameter is used to get version information about
the Driver of a PCAN Channel.
Possible values: The value is a null-terminated string which contains
version number, driver name and copyright information about the
driver used to handle with an specified PCAN channel. The length of
the this text will have a maximum length of 256 bytes (null-termination
included) .
Default value: NA.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel). Note: It is not needed to have a PCAN channel initialized
before asking for its version.
PCAN_BUSOFF_AUTORESET
Access:
Description: This parameter instructs the PCAN driver to reset
automatically the CAN controller of a PCAN channel when a bus-off
state is detected. Since no communication is possible on a bus-off
state, it is useful to let the driver to catch this event automatically and
reset the controller, avoiding extra handling of this problem in an end
application.
Possible values: This parameter can have one of these values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Disabled (PCAN_PARAMETER_OFF).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: Reseting the hardware has a duration of ~ 500
milliseconds. After receiving the PCAN_ERROR_BUSOFF error, an
application should wait that time before trying to read or write again.
PCAN_LISTEN_ONLY
Access:
Description: This parameter allows the user to set a CAN hardware
in Listen-Only mode. When this mode is set, the CAN controller
doens't take part on active events (eg. transmit CAN messages) but
stays in a passive mode (CAN monitor), in which it can analyse the
traffic on the CAN bus used by a PCAN channel. See also the Philips
Data Sheet "SJA1000 Stand-alone CAN controller".
Possible values: This parameter can have one of these values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Disabled (PCAN_PARAMETER_OFF).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS)
containing a SJA1000 CAN controller.
REMARKS: This parameter can be used with an initialized or
uninitialized channel. Configuring this parameter without having the
channel initialized, does a so called "pre-initialization". This means
that the channel will be set in Listen-Only mode as soon as possible,
after it has been successfully connected, using CAN_Initialize (class-
method: Initialize). Once the channel is disconnected, further
initializations of this channel are done in normal mode. It is needed to
set this parameter again before each initialization process, if the
behavior described before is required. This is usefull to avoid or
minimize arbitration problems when connecting to a CAN-network.
PCAN_LOG_LOCATION
Access:
Description: This value is used to set the folder location on a
computer for the Log-File generated by the PCAN-Basic API, within a
debug session. Setting this value starts recording debug information
automatically. If a debug session is running (a log file is being written),
PCAN_LOG_LOCATION instructs the API to close the current log file
and to start the process again with the new folder information. Note
that the name of the log file cannot be specified, this name is fixed as
PCANBasic.log.
Possible values: This value must be a fully-qualified and valid path to
an existing directory on the executing computer. There is no limit for
the length of the string but it is recommended to use a length not
bigger than MAX_PATH. For more information see Naming Files,
Paths, and Namespaces.
Default value: Calling process's folder.
PCAN-Device: Default channel Only (PCAN_NONEBUS).
PCAN_LOG_STATUS
Access:
Description: This value is used to control the activity status of a
debug session within the PCAN-Basic API. If the log status is set to
ON without having set a location for the log file or without having
configured the information to be traced, then the session process will
start with the default values.
Possible values: The value must be one of the following values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Disabled (PCAN_PARAMETER_OFF).
PCAN-Device: Default channel Only (PCAN_NONEBUS).
PCAN_LOG_CONFIGURE
Access:
Description: This value is used to configure the debug information to
be included in the log file generated in a debug session within the
PCAN-Basic API.
Possible values: The value must be one of the following values or a
combination of them:
LOG_FUNCTION_DEFAULT: This value is always active. It
defines the default information to be traced, which is an
unexpected exception like a memory access violation. After
having configured the log with more options, this value can be
used to reset that configuration, setting the log with its default
value again. This kind of entry is marked with the word
"EXCEPTION"* in the log file.
LOG_FUNCTION_ENTRY: This value causes an entry in the log
file each time an API function is entered. This kind of entry is
marked with the word "ENTRY"* in the log file.
LOG_FUNCTION_PARAMETERS: This value causes an entry in
the log file each time an API function is entered, showing the
name of the parameters passed to the function as well as their
values. This kind of entry is marked with the word
"PARAMETERS"* in the log file.
LOG_FUNCTION_LEAVE: This value causes an entry in the log
file each time an API function is abandoned. This kind of entry is
marked with the word "EXIT"* in the log file.
LOG_FUNCTION_WRITE: This value causes an entry in the log
file each time a CAN message is written, using the function
CAN_Write (class-method: Write). This kind of entry is marked
with the word "CHANNEL 0xXX (Y)"* in the log file, where XX is
the channel number in hex notation, and Y the word "OUT"*
denoting the direction (outgoing). The complete CAN message is
also represented as hex text.
LOG_FUNCTION_READ: This value causes an entry in the log
file each time a CAN message is read, using the functions
CAN_Read/CAN_ReadFD (class-methods: Read, ReadFD).
This kind of entry is marked with the word "CHANNEL 0xXX (Y)"*
in the log file, where XX is the channel number in hex notation,
and Y the word "IN"* denoting the direction (incoming). The
complete CAN message is also represented as hex text.
* Note that the PCAN-Basic API supports several languages. The log
file use the language of the operating system. If this language is not
one of the supported languages, than English is used.
* These words are always written in English, independently of the
operating system's language.
Default value: Exceptions and Errors (LOG_FUNCTION_DEFAULT).
PCAN-Device: Default channel Only (PCAN_NONEBUS).
PCAN_LOG_TEXT
Access:
Description: This value is used to insert custom information in the log
file generated in a debug session within the PCAN-Basic API. Setting
this value starts recording debug information automatically.
This is very useful when it is desired to specially mark places of an
application's execution path while debugging PCAN-Basic tasks.
Furthermore, an application could use this feature as an own Log file.
To do so, just use the default log's configuration
(PCAN_LOG_CONFIGURE set to LOG_FUNCTION_DEFAULT) and
include the desired information using PCAN_LOG_TEXT. In this way
the log file will contain only user-defined debug information. Note that
the name of the log file cannot be specified, this name is fixed as
PCANBasic.log.
Possible values: This value must be a null-terminated string. There
is no limit for the length of the string but it is recommended to use a
length not bigger than MAX_PATH. For more information see
Naming Files, Paths, and Namespaces.
Default value: NA.
PCAN-Device: Default channel Only (PCAN_NONEBUS).
PCAN_CHANNEL_CONDITION
Access:
Description: This parameter is used to check and detect available
PCAN hardware on a computer, even before trying to connect any of
them. This is useful when an application wants the user to select
which hardware should be using in a communication session.
Possible values: This parameter can have one of these values:
PCAN_CHANNEL_UNAVAILABLE,
PCAN_CHANNEL_AVAILABLE, PCAN_CHANNEL_OCCUPIED,
PCAN_CHANNEL_PCANVIEW.
Default value: N/A.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_HARDWARE_NAME
Access:
Description: This parameter is used to retrieve the name of the
hardware represented by a PCAN channel. This is useful when an
application wants to differentiate between several models of the same
device, e.g. a PCAN-USB and a PCAN-USB Pro.
Possible values: The value is a null-terminated string which contains
the name of the hardware specified by the given PCAN channel. The
length of this text will have a maximum length of 32 bytes (null-
termination included).
Default value: N/A.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: This parameter can be used with an initialized or
uninitialized channel.
PCAN_RECEIVE_STATUS
Access:
Description: This parameter helps the user to allow / disallow the
reception of messages within a PCAN Channel, regardless of the
value of its reception filter. When the "Receive Status" is active (ON),
incoming messages are forwarded to the user application through the
CAN_Read/CAN_ReadFD functions (class-methods: Read, ReadFD).
If "Receive Status" is deactivated (OFF), the incoming messages are
disposed from the receive queue and each call to
CAN_Read/CAN_ReadFD returns PCAN_ERROR_QRCVEMPTY.
The acceptance filter of the channel remains unchanged (other
applications working with the same PCAN-Hardware will not be
disturbed).
Possible values: This parameter can have one of these values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Activated (PCAN_PARAMETER_ON).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS).
REMARKS: This parameter can be used with an initialized or
uninitialized channel. Configuring this parameter without having the
channel initialized, does a so called "pre-initialization". This means
that the channel will set the configured "Receive Status" after it has
been successfully connected, using CAN_Initialize (class-method:
Initialize). Once the channel is disconnected, further initializations of
this channel are done with the default value of this parameter (ON).
This is usefull to avoid receiving messages immediately after
connection, or before the receive filter is configured according with the
needs of each application.
PCAN_CONTROLLER_NUMBER
Access:
Description: This parameter is a zero-based index used to identify
the CAN controllers built in a hardware. This parameter is useful when
it is needed to communicate with a specific physical channel on a
multichannel CAN Hardware, e.g. "0" or "1" on a PCAN-USB Pro
device.
Possible values: A number in the range [0..n-1], where n is the
number of physical channels on the device being used.
Default value: NA.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: This parameter can be used with an initialized or
uninitialized channel.
PCAN_TRACE_LOCATION
Access:
Description: This value is used to set the folder location on a
computer for the PCAN-Trace file generated by the PCAN-Basic API,
within a trace session. If a trace session is active (a trace file is being
written), PCAN_TRACE_LOCATION instructs the API to close the
current trace file and to start recording data again with the new folder
information.
Possible values: This value must be a fully-qualified and valid path to
an existing directory on the executing computer. There is no limit for
the length of the string but it is recommended to use a length not
bigger than MAX_PATH. For more information see Naming Files,
Paths, and Namespaces. Passing an empty string ("", NULL value)
instructs the API to use the default value for this parameter.
Default value: Calling process's folder.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: Note that the name of the trace file cannot be specified.
The file uses the name of the current connection (PCAN-Channel's
name) plus a file counter (e.g. PCAN_PCIBUS1_1.trc), though it can
be enhanced by issuing the parameter
PCAN_TRACE_CONFIGURE.
PCAN_TRACE_STATUS
Access:
Description: This value is used to control the activity status of a trace
session within the PCAN-Basic API. If the trace status is set to ON
without having set a location for the trace file or without having
configured the storing mode, then the session process will start with
the default values. Trying to activate a trace session can fail if
overwriting is not set and a file with the same name already exists.
Possible values: The value must be one of the following values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Disabled (PCAN_PARAMETER_OFF).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_TRACE_SIZE
Access:
Description: This value is used to set the maximum size, in
megabytes, that a single trace file can have. Trying to set the size for
a trace file will fail if the trace session is active.
Possible values: A number in the range [1..100], representing the
amount of megabytes. Passing a value of 0 instructs the API to use
the default value for this parameter. Trying to set a size bigger than
100 will fail.
Default value: 10 megabytes.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_TRACE_CONFIGURE
Access:
Description: This value is used to configure the trace process and
the file generated in a trace session within the PCAN-Basic API.
Trying to configure a trace file will fail if the trace session is active.
Possible values: The value must be one of the following values or a
combination of them:
TRACE_FILE_SINGLE: This value represents the default trace
configuration. It defines the use of a single trace file as output.
When the tracing process starts, the file will be filled out with
messages until the size of the file reaches the configured
maximum size (see PCAN_TRACE_SIZE). The tracing process
is then automatically stopped.
TRACE_FILE_SEGMENTED: This value indicates the API to
keep tracing information by using several files. When the trace
file being used reaches the maximum configured file size (see
PCAN_TRACE_SIZE), then a new file is automatically created
and the tracing process continues.
TRACE_FILE_DATE: This value instruct the API to use the start
date information within the name of the trace file. The format
used is YYYYMMDD, four digits for year, the next two for the
month, and the last two for the day, e.g.
"20130228_PCAN_USBBUS_1" for the 28th February 2013. If
both, TRACE_FILE_DATE and TRACE_FILE_TIME are
configured, the file name starts always with the date:
"20130228140733_PCAN_USBBUS1_1.trc".
TRACE_FILE_TIME: This value instruct the API to use the start
time information within the name of the trace file. The format
used is HHMMSS, two digits for the hour (24 hours format), the
next two for the minutes, and the last two for the seconds, e.g.
"140733_PCAN_USBBUS_1" for 14:07:33 (02:07:33 PM). If both,
TRACE_FILE_DATE and TRACE_FILE_TIME are configured,
the file name starts always with the date:
"20130228140733_PCAN_USBBUS1_1.trc".
TRACE_FILE_OVERWRITE: This value causes the overwriting
of an existing trace file when a new trace session is started. If this
value is not configured, trying to start a tracing process will fail, if
the file name to generate is the same as one used by an existing
file.
Default value: TRACE_FILE_SINGLE (Single file, not overwriting,
with standard name).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_CHANNEL_IDENTIFYING
Access:
Description: This value is used to control the status of the "channel
identifying procedure" on USB devices within the PCAN-Basic API.
The procedure consists in blinking the LED associated to the given
channel.
Possible values: The value must be one of the following values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Disabled (PCAN_PARAMETER_OFF).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: This parameter can be used with an initialized or
uninitialized channel. This identifying procedure is only available for
USB based hardware (PCAN-USB, PCAN-USB Pro and PCAN-USB
Hub). The blinking of the LED can be different according to the kind of
hardware used (in color and blink rate). Only one channel can blink
simultaneously.
PCAN_CHANNEL_FEATURES
Access:
Description: This value is used to read the particularities of a PCAN
Channel.
Possible values: The value can be one of the following values or a
combination of them:
FEATURE_FD_CAPABLE: This value indicates that the
hardware represented by a PCAN Channel is FD capable (it
supports flexible data rate).
FEATURE_DELAY_CAPABLE: This value indicates that the
hardware represented by a PCAN Channel allows the
configuration of a delay between sending frames.
Default value: A value of 0, indicating "no special features".
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: This parameter can be used with an initialized or
uninitialized channel. FD Hardware must be initialized with
CAN_InitializeFD (class-method: InitializeFD) in order to use their FD
capabilities. In same way, the functions CAN_ReadFD (class-
method: ReadFD) and CAN_WriteFD (class-method: WriteFD) have
to be used for data transmission.
PCAN_BITRATE_ADAPTING
Access:
Description: This value is used to force an initialization process to
succeed, even if the PCAN-Channel is being used by a PCAN-View
with a different or unknown bit rate. The initialization function will
return a PCAN_ERROR_CAUTION error, when the bit rate passed as
parameter was different than that being used.
Possible values: The value must be one of the following values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Disabled (PCAN_PARAMETER_OFF).
PCAN-Device: All Plug-n-Play PCAN devices (excluding
PCAN_NONEBUS channel).
REMARKS: This parameter can be set only on uninitialized
channels. After connecting, an application can get the bit rate
currently used by calling CAN_GetValue (class-method: GetValue)
with the parameters PCAN_SPEED_QUERY, for standard CAN
channels, or PCAN_SPEED_QUERY_FD for CAN-FD channels.
PCAN_BITRATE_INFO
Access:
Description: This value is used to read the currently configured
communication speed, as BTR0-BTR1 value, of a PCAN Channel
connected as standard CAN.
Possible values: A number in the range [0..65535] (Word Value).
Default value: N/A.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: This parameter can be used only on PCAN-Channels
that have been initialized with the function CAN_Initialize (class-
method: Initialize).
PCAN_BITRATE_INFO_FD
Access:
Description: This value is used to read the currently configured
communication speed, as a parameterized string value (FD bit rate
string), of a PCAN Channel connected as CAN FD.
Possible values: a String representing a FD bit rate. See FD Bit rate
for more information.
Default value: N/A.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: This parameter can be used only on PCAN-Channels
that have been initialized with the function CAN_InitializeFD (class-
method: InitializeFD).
PCAN_BUSSPEED_NOMINAL
Access:
Description: This value is used to read the currently configured
nominal CAN Bus speed, as bits/second.
Possible values: a number representing the nominal CAN bus speed
being used, as the amount of bits that can be transmitted in a
second.
Default value: N/A.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_BUSSPEED_DATA
Access:
Description: This value is used to read the currently configured CAN
data speed (Bit Rate Switch), as bits/second.
Possible values: a number representing the CAN data speed
configured for BRS, as the amount of bits that can be transmitted in a
second.
Default value: N/A.
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: The speed used for data transmission is the same as the
nominal speed on devices that don't support flexible data rate.
PCAN_IP_ADDRESS
Access:
Description: This value is used to read the address used by a device
for IP communication.
Possible values: a string representing the IP address of a device, in
IPv4 format.
Default value: N/A.
PCAN-Device: PCAN-LAN (PCAN-Gateway Ethernet/Wireless
devices).
PCAN_LAN_SERVICE_STATUS
Access:
Description: This value is used to get the running status of the
System-Service that is part of the Virtual PCAN-Gateway solution.
Possible values: This parameter can have one of these values:
SERVICE_STATUS_RUNNING, SERVICE_STATUS_STOPPED.
Default value: N/A.
PCAN-Device: Default channel Only (PCAN_NONEBUS).
REMARKS: This parameter is only relevant in PCAN-LAN
environments (using PCAN-Gateway Ethernet/Wireless devices).
PCAN_ALLOW_STATUS_FRAMES
Access:
Description: This parameter helps the user to allow / disallow the
reception of messages of type "PCAN_MESSAGE_STATUS" within a
PCAN Channel. When "PCAN_ALLOW_STATUS_FRAMES" is active
(ON), generated Status messages are forwarded from the driver to
the user application through the CAN_Read/CAN_ReadFD functions
(class-methods: Read, ReadFD). Otherwise, the reception of Status
frames is deactivated within the driver for this specific user
application.
Possible values: The value must be one of the following values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Enabled (PCAN_PARAMETER_ON).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_ALLOW_RTR_FRAMES
Access:
Description: This parameter helps the user to allow / disallow the
reception of messages of type "PCAN_MESSAGE_RTR" within a
PCAN Channel. When "PCAN_ALLOW_RTR_FRAMES" is active
(ON), incoming RTR messages are forwarded to the user application
through the CAN_Read/CAN_ReadFD functions (class-methods:
Read, ReadFD). Otherwise, the reception of RTR frames is
deactivated within the driver for this specific user application.
Possible values: The value must be one of the following values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Enabled (PCAN_PARAMETER_ON).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_ALLOW_ERROR_FRAMES
Access:
Description: This parameter helps the user to allow / disallow the
reception of messages of type "PCAN_MESSAGE_ERRFRAME"
within a PCAN Channel. When "PCAN_ALLOW_ERROR_FRAMES"
is active (ON), generated Error messages are forwarded from the
driver to the user application through the CAN_Read/CAN_ReadFD
functions (class-methods: Read, ReadFD ). Otherwise, the reception
of Error frames is deactivated within the driver for this specific user
application.
Possible values: The value must be one of the following values:
PCAN_PARAMETER_OFF, PCAN_PARAMETER_ON. Note that
other values will considered invalid.
Default value: Disabled (PCAN_PARAMETER_OFF).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
PCAN_INTERFRAME_DELAY
Access:
Description: This parameter is used to configure a delay, in
microseconds, between sending frames. When this value is value is
greater than 0, the driver includes that value as a pause between
each written CAN frame. Otherwise, the CAN frames are sent as fast
as possible.
Possible values: The parameter has a value range between [0..n],
where n is the maximum value supported by the Firmware. If the
maximum value supported by the firmware is lower than the entered
one, the value will be truncated.
Default value: 0 (disabled).
PCAN-Device: All FPGA based PCAN devices.
PCAN_ACCEPTANCE_FILTER_11BIT
Access:
Description: This parameter is used to configure the reception filter
of a PCAN channel with a specific 11-bit acceptance code and mask,
as specified for the acceptance filter of the SJA1000 CAN controller.
The acceptance code and mask are coded together in a 64-bit value,
each of them using 4 bytes (Intel/Little-Endian format). The
acceptance code is stored at the most significant bytes.
Possible values: Both parameter parts, code and mask, have a
value range between [0..16838]. This means, the maximum value of
this parameter as 64-bit value is 70364449226751, that is,
hexadecimal 00003FFF00003FFFh. The mask uses the bit value '1'
as "don't care bit".
Default value: 00000000000007FFh (no filtering).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: This parameter is particularly adapted to the SJA1000
CAN controller. Reception filters can also be configured with the
function CAN_FilterMessages(class-method: FilterMessages). Note
that after a PCAN Channel is initialized, the status of its filter is fully
opened. According with the current filter status, setting this parameter
causes the following behavior:
Filter status is PCAN_FILTER_OPEN: The filter is automatically
closed and then configured with the given acceptance filter.
Filter status is PCAN_FILTER_CLOSE: The filter is set to the
given acceptance filter.
Filter status is PCAN_FILTER_CUSTOM: The filter is expanded
with the given acceptance filter. If a different acceptance code is
required instead of expanding the current one, the filter has to be
closed first before setting the acceptance filter. To do this use the
parameter PCAN_MESSAGE_FILTER.
PCAN_ACCEPTANCE_FILTER_29BIT
Access:
Description: This parameter is used to configure the reception filter
of a PCAN channel with a specific 29-bit acceptance code and mask,
as specified for the acceptance filter of the SJA1000 CAN controller.
The acceptance code and mask are coded together in a 64-bit value,
each of them using 4 bytes (Intel/Little-Endian format). The
acceptance code is stored at the most significant bytes.
Possible values: Both parameter parts, code and mask, have a
value range between [0..4294967295]. This means, the maximum
value of this parameter as 64-bit value is 18446744073709551615,
that is, hexadecimal FFFFFFFFFFFFFFFFh. The mask uses the bit
value '1' as "don't care bit".
Default value: 000000001FFFFFFFh (no filtering).
PCAN-Device: All PCAN devices (excluding PCAN_NONEBUS
channel).
REMARKS: This parameter is particularly adapted to the SJA1000
CAN controller. Reception filters can also be configured with the
function CAN_FilterMessages(class-method: FilterMessages). Note
that after a PCAN Channel is initialized, the status of its filter is fully
opened. According with the current filter status, setting this parameter
causes the following behavior:
Filter status is PCAN_FILTER_OPEN: The filter is automatically
closed and then configured with the given acceptance filter.
Filter status is PCAN_FILTER_CLOSE: The filter is set to the
given acceptance filter.
Filter status is PCAN_FILTER_CUSTOM: The filter is expanded
with the given acceptance filter. If a different acceptance code is
required instead of expanding the current one, the filter has to be
closed first before setting the acceptance filter. To do this use the
parameter PCAN_MESSAGE_FILTER.
See Also
TPCANMessageType
Represents the type of a CAN message. According with the
programming language, this type can be a group of defined values or
an enumeration.
Syntax
C++
#define TPCANMessageType BYTE
Pascal OO
{$Z1}
TPCANMessageType = (
PCAN_MESSAGE_STANDARD = $00,
PCAN_MESSAGE_RTR = $01,
PCAN_MESSAGE_EXTENDED = $02,
PCAN_MESSAGE_FD = $04,
PCAN_MESSAGE_BRS = $08,
PCAN_MESSAGE_ESI = $10,
PCAN_MESSAGE_ERRFRAME = $40,
PCAN_MESSAGE_STATUS = $80
);
C#
[Flags]
public enum TPCANMessageType : byte
{
PCAN_MESSAGE_STANDARD = 0x00,
PCAN_MESSAGE_RTR = 0x01,
PCAN_MESSAGE_EXTENDED = 0x02,
PCAN_MESSAGE_FD = 0x04,
PCAN_MESSAGE_BRS = 0x08,
PCAN_MESSAGE_ESI = 0x10,
PCAN_MESSAGE_ERRFRAME = 0x40,
PCAN_MESSAGE_STATUS = 0x80,
}
C++ / CLR
[Flags]
public enum class TPCANMessageType : Byte
{
PCAN_MESSAGE_STANDARD = 0x00,
PCAN_MESSAGE_RTR = 0x01,
PCAN_MESSAGE_EXTENDED = 0x02,
PCAN_MESSAGE_FD = 0x04,
PCAN_MESSAGE_BRS = 0x08,
PCAN_MESSAGE_ESI = 0x10,
PCAN_MESSAGE_ERRFRAME = 0x40,
PCAN_MESSAGE_STATUS = 0x80,
};
Visual Basic
<Flags()> _
Public Enum TPCANMessageType As Byte
PCAN_MESSAGE_STANDARD = &H0
PCAN_MESSAGE_RTR = &H1
PCAN_MESSAGE_EXTENDED = &H2
PCAN_MESSAGE_FD = &H4
PCAN_MESSAGE_BRS = &H8
PCAN_MESSAGE_ESI = &H10
PCAN_MESSAGE_ERRFRAME = &H40
PCAN_MESSAGE_STATUS = &H80
End Enum
Python
TPCANMessageType = c_ubyte
PCAN_MESSAGE_STANDARD = TPCANMessageType(0x00)
PCAN_MESSAGE_RTR = TPCANMessageType(0x01)
PCAN_MESSAGE_EXTENDED = TPCANMessageType(0x02)
PCAN_MESSAGE_FD = TPCANMessageType(0x04)
PCAN_MESSAGE_BRS = TPCANMessageType(0x08)
PCAN_MESSAGE_ESI = TPCANMessageType(0x10)
PCAN_MESSAGE_ERRFRAME = TPCANMessageType(0x40)
PCAN_MESSAGE_STATUS = TPCANMessageType(0x80)
Remarks
Values
See Also
TPCANType
Represents the type of PCAN (not plug&play) hardware to be
initialized. According with the programming language, this type can be
a group of defined values or an enumeration.
Syntax
C++
#define TPCANType BYTE
Visual Basic
Public Enum TPCANType As Byte
PCAN_TYPE_ISA = &H1
PCAN_TYPE_ISA_SJA = &H9
PCAN_TYPE_ISA_PHYTEC = &H4
PCAN_TYPE_DNG = &H2
PCAN_TYPE_DNG_EPP = &H3
PCAN_TYPE_DNG_SJA = &H5
PCAN_TYPE_DNG_SJA_EPP = &H6
End Enum
Python
TPCANType = c_ubyte
PCAN_TYPE_ISA = TPCANType(0x01)
PCAN_TYPE_ISA_SJA = TPCANType(0x09)
PCAN_TYPE_ISA_PHYTEC = TPCANType(0x04)
PCAN_TYPE_DNG = TPCANType(0x02)
PCAN_TYPE_DNG_EPP = TPCANType(0x03)
PCAN_TYPE_DNG_SJA = TPCANType(0x05)
PCAN_TYPE_DNG_SJA_EPP = TPCANType(0x06)
Values
See Also
TPCANMode
Represents a PCAN filter mode. According with the programming
language, this type can be a group of defined values or an
enumeration.
Syntax
C++
#define TPCANMode BYTE
Pascal OO
{$Z1}
TPCANMode = (
PCAN_MODE_STANDARD = Byte(PCAN_MESSAGE_STANDARD
PCAN_MODE_EXTENDED = Byte(PCAN_MESSAGE_EXTENDED
);
C#
public enum TPCANMode : byte
{
PCAN_MODE_STANDARD = TPCANMessageType.PCAN_MESSAGE
PCAN_MODE_EXTENDED = TPCANMessageType.PCAN_MESSAGE
}
C++ / CLR
public enum class TPCANMode : Byte
{
PCAN_MODE_STANDARD = TPCANMessageType::PCAN_MESSAG
PCAN_MODE_EXTENDED = TPCANMessageType::PCAN_MESSAG
};
Visual Basic
Public Enum TPCANMode As Byte
PCAN_MODE_STANDARD = TPCANMessageType.PCAN_MESSAGE
PCAN_MODE_EXTENDED = TPCANMessageType.PCAN_MESSAGE
End Enum
Python
TPCANMode = c_ubyte
PCAN_MODE_STANDARD = PCAN_MESSAGE_STANDARD
PCAN_MODE_EXTENDED = PCAN_MESSAGE_EXTENDED
Values
See Also
TPCANBaudrate
Represents a PCAN bit rate register value. According with the
programming language, this type can be a group of defined values or
an enumeration.
Syntax
C++
#define TPCANBaudrate WORD
Pascal OO
{$Z2}
TPCANBaudrate = (
PCAN_BAUD_1M = $0014,
PCAN_BAUD_800K = $0016,
PCAN_BAUD_500K = $001C,
PCAN_BAUD_250K = $011C,
PCAN_BAUD_125K = $031C,
PCAN_BAUD_100K = $432F,
PCAN_BAUD_95K = $C34E,
PCAN_BAUD_83K = $852B,
PCAN_BAUD_50K = $472F,
PCAN_BAUD_47K = $1414,
PCAN_BAUD_33K = $8B2F,
PCAN_BAUD_20K = $532F,
PCAN_BAUD_10K = $672F,
PCAN_BAUD_5K = $7F7F
);
C#
public enum TPCANBaudrate : ushort
{
PCAN_BAUD_1M = 0x0014,
PCAN_BAUD_800K = 0x0016,
PCAN_BAUD_500K = 0x001C,
PCAN_BAUD_250K = 0x011C,
PCAN_BAUD_125K = 0x031C,
PCAN_BAUD_100K = 0x432F,
PCAN_BAUD_95K = 0xC34E,
PCAN_BAUD_83K = 0x852B,
PCAN_BAUD_50K = 0x472F,
PCAN_BAUD_47K = 0x1414,
PCAN_BAUD_33K = 0x8B2F,
PCAN_BAUD_20K = 0x532F,
PCAN_BAUD_10K = 0x672F,
PCAN_BAUD_5K = 0x7F7F,
}
C++ / CLR
public enum class TPCANBaudrate : UInt16
{
PCAN_BAUD_1M = 0x0014,
PCAN_BAUD_800K = 0x0016,
PCAN_BAUD_500K = 0x001C,
PCAN_BAUD_250K = 0x011C,
PCAN_BAUD_125K = 0x031C,
PCAN_BAUD_100K = 0x432F,
PCAN_BAUD_95K = 0xC34E,
PCAN_BAUD_83K = 0x852B,
PCAN_BAUD_50K = 0x472F,
PCAN_BAUD_47K = 0x1414,
PCAN_BAUD_33K = 0x8B2F,
PCAN_BAUD_20K = 0x532F,
PCAN_BAUD_10K = 0x672F,
PCAN_BAUD_5K = 0x7F7F,
};
Visual Basic
Public Enum TPCANBaudrate As UInt16
PCAN_BAUD_1M = &H14
PCAN_BAUD_800K = &H16
PCAN_BAUD_500K = &H1C
PCAN_BAUD_250K = &H11C
PCAN_BAUD_125K = &H31C
PCAN_BAUD_100K = &H432F
PCAN_BAUD_95K = &C34E
PCAN_BAUD_83K = &852B
PCAN_BAUD_50K = &H472F
PCAN_BAUD_47K = &1414
PCAN_BAUD_33K = &8B2F
PCAN_BAUD_20K = &H532F
PCAN_BAUD_10K = &H672F
PCAN_BAUD_5K = &H7F7F
End Enum
Python
TPCANBaudrate = c_ushort
PCAN_BAUD_1M = TPCANBaudrate(0x0014)
PCAN_BAUD_800K = TPCANBaudrate(0x0016)
PCAN_BAUD_500K = TPCANBaudrate(0x001C)
PCAN_BAUD_250K = TPCANBaudrate(0x011C)
PCAN_BAUD_125K = TPCANBaudrate(0x031C)
PCAN_BAUD_100K = TPCANBaudrate(0x432F)
PCAN_BAUD_95K = TPCANBaudrate(0xC34E)
PCAN_BAUD_83K = TPCANBaudrate(0x852B)
PCAN_BAUD_50K = TPCANBaudrate(0x472F)
PCAN_BAUD_47K = TPCANBaudrate(0x1414)
PCAN_BAUD_33K = TPCANBaudrate(0x8B2F)
PCAN_BAUD_20K = TPCANBaudrate(0x532F)
PCAN_BAUD_10K = TPCANBaudrate(0x672F)
PCAN_BAUD_5K = TPCANBaudrate(0x7F7F)
Values
See Also
TPCANBitrateFD
Represents a bit rate string with flexible data rate (FD).
Syntax
C++
#define TPCANBitrateFD LPSTR
Pascal OO
TPCANBitrateFD = String;
C#
using TPCANBitrateFD = System.String;
C++ / CLR
#define TPCANBitrateFD System::String^
Visual Basic
Imports TPCANBitrateFD = System.String
Python
TPCANBitrateFD = c_char_p
Remarks
Visual Basic:
Imports System
Imports Peak.Can.Basic
Imports TPCANBitrateFD = System.String ' Alias declaration
See Also
TPCANTimestampFD
Represents the timestamp of a CAN message with flexible data rate.
The time-stamp contains the number of microseconds since the start
of Windows.
Syntax
C++
#define TPCANTimestampFD UINT64
Pascal OO
TPCANTimestampFD = UInt64;
C#
using TPCANTimestampFD = System.UInt64;
C++ / CLR
#define TPCANTimestampFD System::UInt64
Visual Basic
Imports TPCANTimestampFD = System.UInt64
Python
TPCANTimestampFD = c_ulonglong
Remarks
Visual Basic:
Imports System
Imports Peak.Can.Basic
Imports TPCANTimestampFD = System.UInt64 ' Alias declaratio
Methods
The methods defined for the classes PCANBasic and TPCANBasic
are divided in 4 groups of functionality. Note that, with exception of the
method version for Python, these methods are static and can be
called in the name of the class, without instantiation.
Connection
Function Description
Initialize Initializes a PCAN Channel.
Configuration
Function Description
SetValue Sets a configuration or information
value within a PCAN Channel.
Information
Function Description
GetValue Retrieves information from a PCAN
Channel.
GetStatus Retrieves the current BUS status of a
PCAN Channel.
Communication
Function Description
Read Reads a CAN message from the
receive queue of a PCAN Channel.
Initialize
Initializes a PCAN Channel.
Overloads
Function Description
Initialize(TPCANHandle, Initializes a Plug-And-Play PCAN
TPCANBaudrate) Channel.
Initialize(TPCANHandle, TPCANBaudrate)
Initializes a PCAN Channel which represents a Plug & Play PCAN-
Device.
Syntax
Pascal OO
class function Initialize(
Channel: TPCANHandle;
Btr0Btr1: TPCANBaudrate
): TPCANStatus; overload;
C#
public static extern TPCANStatus Initialize(
TPCANHandle Channel,
TPCANBaudrate Btr0Btr1);
C++ / CLR
static TPCANStatus Initialize(
TPCANHandle Channel,
TPCANBaudrate Btr0Btr1);
Visual Basic
Public Shared Function Initialize( _
ByVal Channel As TPCANHandle, _
ByVal Btr0Btr1 As TPCANBaudrate) As TPCANStatus
End Function
Python
def Initialize(
self,
Channel,
Btr0Btr1)
Parameters
Parameters Description
Returns
Remarks
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
begin
// The Plug & Play Channel (PCAN-PCI) is initialized
//
result := TPCANBasic.Initialize(TPCANBasic.PCAN_PCIBUS2
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
MessageBox(0,'PCAN-PCI (Ch-2) was initialized'
Python:
# The Plug & Play Channel (PCAN-PCI) is initialized
#
objPCAN = PCANBasic()
result = objPCAN.Initialize(PCAN_PCIBUS2, PCAN_BAUD_500K
if result != PCAN_ERROR_OK:
# An error occurred, get a text describing the error an
#
result = objPCAN.GetErrorText(result)
print result[1]
else:
print "PCAN-PCI (Ch-2) was initialized"
See Also
Uninitialize
GetValue
Understanding PCAN-Basic
Initialize(TPCANHandle, TPCANBaudrate,
TPCANType, UInt32, UInt16)
Initializes a PCAN Channel which represents a Not Plug & Play
PCAN-Device.
Syntax
Pascal OO
class function Initialize(
Channel: TPCANHandle;
Btr0Btr1: TPCANBaudrate;
HwType: TPCANType;
IOPort: LongWord;
Interrupt: Word
): TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Initiali
public static extern TPCANStatus Initialize(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType.U2)]
TPCANBaudrate Btr0Btr1,
[MarshalAs(UnmanagedType.U1)]
TPCANType HwType,
UInt32 IOPort,
UInt16 Interrupt);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Initiali
static TPCANStatus Initialize(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType::U2)]
TPCANBaudrate Btr0Btr1,
[MarshalAs(UnmanagedType::U1)]
TPCANType HwType,
UInt32 IOPort,
UInt16 Interrupt);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_Initializ
Public Shared Function Initialize( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
<MarshalAs(UnmanagedType.U2)> _
ByVal Btr0Btr1 As TPCANBaudrate, _
<MarshalAs(UnmanagedType.U1)> _
ByVal HwType As TPCANType, _
ByVal IOPort As UInt32, _
ByVal Interrupt As UInt16) As TPCANStatus
End Function
Python
def Initialize(
self,
Channel,
Btr0Btr1,
HwType = TPCANType(0),
IOPort = c_uint(0),
Interrupt = c_ushort(0))
Parameters
Parameters Description
Returns
Remarks
Example
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
begin
// The Not Plug & Play Channel (PCAN-DNG) is initialize
//
result := TPCANBasic.Initialize(TPCANBasic.PCAN_DNGBUS1
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
MessageBox(0,'PCAN-DNG (Ch-1) was initialized'
Python:
# The Not Plug & Play Channel (PCAN-DNG) is initialized
#
objPCAN = PCANBasic()
result = objPCAN.Initialize(PCAN_DNGBUS1, PCAN_BAUD_500K, P
if result != PCAN_ERROR_OK:
# An error occurred, get a text describing the error an
#
result = objPCAN.GetErrorText(result)
print result[1]
else:
print "PCAN-DNG (Ch-1) was initialized"
See Also
Uninitialize
GetValue
Understanding PCAN-Basic
InitializeFD
Initializes a FD capable PCAN Channel.
Syntax
Pascal OO
class function InitializeFD(
Channel: TPCANHandle;
BitrateFD: TPCANBitrateFD
): TPCANStatus;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Initiali
public static extern TPCANStatus InitializeFD(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
TPCANBitrateFD BitrateFD);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Initiali
static TPCANStatus InitializeFD(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
TPCANBitrateFD BitrateFD);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_Initializ
Public Shared Function InitializeFD( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
ByVal BitrateFD As TPCANBitrateFD) As TPCANStatus
End Function
Python
def InitializeFD(
self,
Channel,
BitrateFD)
Parameters
Parameters Description
Returns
Remarks
Example
C++/CLR:
String^ bitrate;
TPCANStatus result;
StringBuilder^ strMsg;
' Defines a FD Bit rate string with nominal and data Bit ra
'
bitrate = "f_clock_mhz=24, nom_brp=1, nom_tseg1=17, nom_tse
Pascal OO:
var
bitrate: String;
result : TPCANStatus;
strMsg: array [0..256] of Char;
begin
// Defines a FD Bit rate string with nominal and data B
//
bitrate := 'f_clock_mhz=24, nom_brp=1, nom_tseg1=17, no
// The FD capable Channel (PCAN-USB Pro FD) is initiali
//
result := TPCANBasic.InitializeFD(TPCANBasic.PCAN_USBBU
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
MessageBox(0,'PCAN-USB Pro FD (Ch-1) was initialize
Python:
# Defines a FD Bit rate string with nominal and data Bit ra
#
bitrate = "f_clock_mhz=24, nom_brp=1, nom_tseg1=17, nom_tse
See Also
Uninitialize
ReadFD
WriteFD
Uninitialize
Uninitializes a PCAN Channel.
Syntax
Pascal OO
class function Uninitialize(
Channel: TPCANHandle
): TPCANStatus;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Uninitia
public static extern TPCANStatus Uninitialize(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Uninitia
static TPCANStatus Uninitialize(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_Uninitial
Public Shared Function Uninitialize( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle) As TPCANStatus
End Function
Python
def Uninitialize(
self,
Channel)
Parameters
Parameters Description
Returns
Remarks
Example
....
if (result != TPCANStatus.PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error a
//
PCANBasic.GetErrorText(result, 0, strMsg);
MessageBox.Show(strMsg.ToString());
}
else
MessageBox.Show("PCAN-PCI (Ch-1) was released"
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
....
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
begin
// The Plug & Play Channel (PCAN-PCI) is initialized
//
result := TPCANBasic.Initialize(TPCANBasic.PCAN_PCIBUS1
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
MessageBox(0,'PCAN-PCI (Ch-1) was initialized'
....
Python:
# The Plug & Play Channel (PCAN-PCI) is initialized
#
objPCAN = PCANBasic()
result = objPCAN.Initialize(PCAN_PCIBUS1, PCAN_BAUD_500K
if result != PCAN_ERROR_OK:
# An error occurred, get a text describing the error an
#
result = objPCAN.GetErrorText(result)
print result[1]
else:
print "PCAN-PCI (Ch-1) was initialized"
....
See Also
Initialize
Plain function Version: CAN_Uninitialize
Reset
Resets the receive and transmit queues of a PCAN Channel.
Syntax
Pascal OO
class function Reset(
Channel: TPCANHandle
): TPCANStatus;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Reset
public static extern TPCANStatus Reset(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Reset
static TPCANStatus Reset(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_Reset
Public Shared Function Reset( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle) As TPCANStatus
End Function
Python
def Reset(
self,
Channel)
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of the method Reset on the
channel PCAN_PCIBUS1. In case of failure, the returned code will be
translated to a text (according with the operating system language) in
English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized.
C#:
TPCANStatus result;
StringBuilder strMsg;
......
......
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
......
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
begin
......
Python:
......
See Also
Read
Write
SetValue
GetStatus
Gets the current BUS status of a PCAN Channel.
Syntax
Pascal OO
class function GetStatus(
Channel: TPCANHandle
): TPCANStatus;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetStatu
public static extern TPCANStatus GetStatus(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetStatu
static TPCANStatus GetStatus(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_GetStatus
Public Shared Function GetStatus( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle) As TPCANStatus
End Function
Python
def GetStatus(
self,
Channel)
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of the method GetStatus on the
channel PCAN_PCIBUS1. In case of failure, the returned code will be
translated to a text (according with the operating system language) in
English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized.
C#:
TPCANStatus result;
StringBuilder strMsg;
......
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
......
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
......
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
begin
......
Python:
......
See Also
Read
Reads a CAN message from the receive queue of a PCAN Channel.
Overloads
Function Description
Read(TPCANHandle, Reads a CAN message from the
TPCANMsg) receive queue.
Read(TPCANHandle, TPCANMsg)
Reads a CAN message from the receive queue of a PCAN Channel.
Syntax
Pascal OO
class function Read(
Channel: TPCANHandle;
var MessageBuffer: TPCANMsg
): TPCANStatus; overload;
C#
public static TPCANStatus Read(
TPCANHandle Channel,
out TPCANMsg MessageBuffer);
C++ / CLR
static TPCANStatus Read(
TPCANHandle Channel,
TPCANMsg %MessageBuffer);
Visual Basic
Public Shared Function Read( _
ByVal Channel As TPCANHandle, _
ByRef MessageBuffer As TPCANMsg) As TPCANStatus
End Function
Parameters
Parameters Description
Returns
Remarks
The Read method returns received messages or status messages
from the receive queue. It is important to call Read repeatedly until
the queue is empty. In case there are no more messages in queue,
the value PCAN_ERROR_QRCVEMPTY is returned. The error code
PCAN_ERROR_QRCVEMPTY is also returned if the reception of
messages is disabled. See Receive Status Parameter for more
information.
The receive queue can contain up to 32767 messages.
If the time when the message was received is needed, use the
overloaded Read method.
There are two possibilities for reading messages from the receive
queue of a Channel:
Time-Triggered Reading: Consists in periodically calls to the Read
method. Typically, an application start a timer that every 50 or 100
milliseconds check for messages, calling the Read method in a loop
until the value of PCAN_ERROR_QRCVEMTY or another error
condition is reached.
Event-Triggered Reading: Consists in reacting to a notification sent by
the PCAN driver to a registered application, when a message is
received and inserted in its receive queue. See Using Events to
obtain more information about reading with events.
About bus errors / Status messages
If a bus-off error occur, an application cannot use the channel to
communicate anymore, until the CAN controller is reset. With PCAN-
Basic it is not possible to reset the CAN controller through a method
directly. Consider using the PCAN-Basic property
PCAN_BUSOFF_AUTORESET which instructs the API to
automatically reset the CAN controller when a bus-off state is
detected.
Another way to reset errors like BUSOFF, BUSHEAVY, and
BUSLIGTH, is to uninitialize and initialise again the channel used.
This causes a hardware reset, but only when no more clients are
connected to that channel.
The message type (see TPCANMessageType) of a CAN message
indicates if the message is a 11-bit, 29-bit, RTR, Error, or Status
message. This value should be checked every time a message has
been read successfully.
If the bit PCAN_MESSAGE_ERRFRAME is set in the
TPCANMsg.MSGTYPE field, the message is an Error frame (see
Error Frames).
If the bit PCAN_MESSAGE_STATUS is set in the
TPCANMsg.MSGTYPE field, the message is a Status message. The
ID and LEN fields do not contain valid data. The first 4 data bytes of
the message contain the Error Code. The MSB of the Error Code is in
data byte 0, the LSB is in data byte 3. If a status message was read
the return value of Read is also the error code.
Examples:
Example
The following example shows the use of method Read on the channel
PCAN_USBBUS1. In case of failure, the returned code will be
translated to a text (according with the operating system language) in
English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized and that
the following code is an OnTimer event handler method.
C#:
TPCANStatus result;
StringBuilder strMsg;
TPCANMsg msg;
do
{
// Check the receive queue for new messages
//
result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1
if (result != TPCANStatus.PCAN_ERROR_QRCVEMPTY
{
// Process the received message
//
MessageBox.Show("A message was received");
ProcessMessage(msg);
}
else
{
// An error occurred, get a text describing the err
//
PCANBasic.GetErrorText(result, 0, strMsg);
MessageBox.Show(strMsg.ToString());
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & TPCANStatus.PCAN_ERROR_QRCVEMPTY) !=
C++CLR:
TPCANStatus result;
StringBuilder^ strMsg;
TPCANMsg msg;
do
{
// Check the receive queue for new messages
//
result = PCANBasic::Read(PCANBasic::PCAN_USBBUS1
if (result != TPCANStatus::PCAN_ERROR_QRCVEMPTY
{
// Process the received message
//
MessageBox::Show("A message was received");
ProcessMessage(msg);
}
else
{
// An error occurred, get a text describing the err
//
PCANBasic::GetErrorText(result, 0, strMsg);
MessageBox::Show(strMsg->ToString());
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & TPCANStatus::PCAN_ERROR_QRCVEMPTY
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim msg As TPCANMsg
Do
' Check the receive queue for new messages
'
result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1
If result <> TPCANStatus.PCAN_ERROR_QRCVEMPTY
MessageBox.Show("A message was received")
ProcessMessage(msg)
Else
' An error occurred, get a text describing the erro
'
PCANBasic.GetErrorText(result, 0, strMsg)
MessageBox.Show(strMsg.ToString())
' Here can be decided if the loop has to be termin
' status is bus-off)
'
HandleReadError(result)
End If
' Try to read a message from the receive queue of the PCAN-
' until the queue is empty
'
Loop While ((result And TPCANStatus.PCAN_ERROR_QRCVEMPTY
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
msg: TPCANMsg;
begin
repeat
// Check the receive queue for new messages
//
result := TPCANBasic.Read(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_QRCVEMPTY) Then
begin
// Process the received message
//
MessageBox(0,'A message was received',
ProcessMessage(msg);
end
else
begin
// An error occurred, get a text describing the
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
// Here can be decided if the loop has to be t
// status is bus-off)
//
HandleReadError(result);
end;
// Try to read a message from the receive queue of the
// until the queue is empty
//
until ((TPCANStatus(Integer(result) AND Integer
See Also
Write
Using Events
Error Frames
Read(TPCANHandle, TPCANMsg,
TPCANTimestamp)
Reads a CAN message and its time stamp from the receive queue of
a PCAN Channel.
Syntax
Pascal OO
class function Read(
Channel: TPCANHandle;
var MessageBuffer: TPCANMsg;
var TimestampBuffer: TPCANTimestamp
): TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Read
public static extern TPCANStatus Read(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
out TPCANMsg MessageBuffer,
ref TPCANTimestamp TimestampBuffer);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Read
static TPCANStatus Read(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
TPCANMsg %MessageBuffer,
TPCANTimestamp %TimestampBuffer);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_Read
Public Shared Function Read( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
ByRef MessageBuffer As TPCANMsg, _
ByRef TimestampBuffer As TPCANTimestamp) As
End Function
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of method Read on the channel
PCAN_USBBUS1. In case of failure, the returned code will be
translated to a text (according with the operating system language) in
English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized and that
the following code is an OnTimer event handler method.
C#:
TPCANStatus result;
StringBuilder strMsg;
TPCANMsg msg;
TPCANTimestamp time;
do
{
// Check the receive queue for new messages
//
result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1
if (result != TPCANStatus.PCAN_ERROR_QRCVEMPTY
{
// Process the received message
//
MessageBox.Show("A message was received");
ProcessMessage(msg, time);
}
else
{
// An error occurred, get a text describing the err
//
PCANBasic.GetErrorText(result, 0, strMsg);
MessageBox.Show(strMsg.ToString());
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & TPCANStatus.PCAN_ERROR_QRCVEMPTY) !=
C++CLR:
TPCANStatus result;
StringBuilder^ strMsg;
TPCANMsg msg;
TPCANTimestamp time;
strMsg = gcnew StringBuilder(256);
do
{
// Check the receive queue for new messages
//
result = PCANBasic::Read(PCANBasic::PCAN_USBBUS1
if (result != TPCANStatus::PCAN_ERROR_QRCVEMPTY
{
// Process the received message
//
MessageBox::Show("A message was received");
ProcessMessage(msg, time);
}
else
{
// An error occurred, get a text describing the err
//
PCANBasic::GetErrorText(result, 0, strMsg);
MessageBox::Show(strMsg->ToString());
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & TPCANStatus::PCAN_ERROR_QRCVEMPTY
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim msg As TPCANMsg
Dim time As TPCANTimestamp
strMsg = New StringBuilder(256)
Do
' Check the receive queue for new messages
'
result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1
If result <> TPCANStatus.PCAN_ERROR_QRCVEMPTY
MessageBox.Show("A message was received")
ProcessMessage(msg, time)
Else
' An error occurred, get a text describing the erro
'
PCANBasic.GetErrorText(result, 0, strMsg)
MessageBox.Show(strMsg.ToString())
' Here can be decided if the loop has to be termin
' status is bus-off)
'
HandleReadError(result);
End If
' Try to read a message from the receive queue of the PCAN-
' until the queue is empty
'
Loop While ((result And TPCANStatus.PCAN_ERROR_QRCVEMPTY
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
msg: TPCANMsg;
time: TPCANTimestamp;
begin
repeat
// Check the receive queue for new messages
//
result := TPCANBasic.Read(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_QRCVEMPTY) Then
begin
// Process the received message
//
MessageBox(0,'A message was received',
ProcessMessage(msg, time);
end
else
begin
// An error occurred, get a text describing the
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
// Here can be decided if the loop has to be t
// status is bus-off)
//
HandleReadError(result);
end;
// Try to read a message from the receive queue of the
// until the queue is empty
//
until ((TPCANStatus(Integer(result) AND Integer
See Also
Write
Using Events
Error Frames
Read(TPCANHandle)
Reads a CAN message and its time stamp from the receive queue of
a PCAN Channel.
Syntax
Python
def Read(
self,
Channel)
Parameters
Parameters Description
Returns
Remarks
Python Notes
Class-Method: Unlike the .NET Framework, under Python a
variable has to be instantiated with an object of type PCANBasic
in order to use the API functionality.
Python's first argument convention: Under Python, 'self' is a
parameter that is automatically included within the call of this
method, within a PCANBasic object and hasn't to be indicated in
a method call. This parameter represents the calling object itself.
Example
The following example shows the use of method Read on the channel
PCAN_USBBUS1. In case of failure, the returned code will be
translated to a text (according with the operating system language) in
English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized and that
the following code is executed periodically.
Python:
readResult = PCAN_ERROR_OK,
while (readResult[0] & PCAN_ERROR_QRCVEMPTY) != PCAN_ERROR_
# Check the receive queue for new messages
#
readResult = objPCAN.Read(PCAN_USBBUS1)
if readResult[0] != PCAN_ERROR_QRCVEMPTY:
# Process the received message
#
print "A message was received"
ProcessMessage(result[1],result[2]) # Possible proc
else:
# An error occurred, get a text describing the erro
#
result = objPCAN.GetErrorText(readResult[0])
print result[1]
HandleReadError(readResult[0]) # Possible errors ha
See Also
Write
Using Events
Error Frames
ReadFD
Reads a CAN message from the receive queue of a FD capable
PCAN Channel.
Overloads
Function Description
ReadFD(TPCANHandle, Reads a CAN message from the
TPCANMsgFD) receive queue .
ReadFD(TPCANHandle, TPCANMsgFD)
Reads a CAN message from the receive queue of a FD capable
PCAN Channel.
Syntax
Pascal OO
class function ReadFD(
Channel: TPCANHandle;
var MessageBuffer: TPCANMsgFD
):TPCANStatus; overload;
C#
public static TPCANStatus ReadFD(
TPCANHandle Channel,
out TPCANMsgFD MessageBuffer)
C++ / CLR
static TPCANStatus ReadFD(
TPCANHandle Channel,
TPCANMsgFD %MessageBuffer);
Visual Basic
Public Shared Function ReadFD( _
ByVal Channel As TPCANHandle, _
ByRef MessageBuffer As TPCANMsgFD) As TPCANStatus
End Function
Parameters
Parameters Description
Returns
Remarks
The use of Read and ReadFD are mutually exclusive. The PCAN
Channel passed to this method must be initialized using InitializeFD
(plain function: CAN_InitializeFD). Otherwise the error
PCAN_ERROR_ILLOPERATION is returned.
If the time when the message was received is needed, use the
overloaded ReadFD method.
The ReadFD method returns received messages or status messages
from the receive queue. It is important to call ReadFD repeatedly until
the queue is empty. In case there are no more messages in queue,
the value PCAN_ERROR_QRCVEMPTY is returned. The error code
PCAN_ERROR_QRCVEMPTY is also returned if the reception of
messages is disabled. See Receive Status Parameter for more
information.
The receive queue can contain up to 32767 messages.
There are two possibilities for reading messages from the receive
queue of a Channel:
Time-Triggered Reading: Consists in periodically calls to the ReadFD
method. Typically, an application start a timer that every 50 or 100
milliseconds check for messages, calling the ReadFD method in a
loop until the value of PCAN_ERROR_QRCVEMTY or another error
condition is reached.
Event-Triggered Reading: Consists in reacting to a notification sent by
the PCAN driver to a registered application, when a message is
received and inserted in its receive queue. See Using Events to
obtain more information about reading with events.
About bus errors / Status messages
If a bus-off error occur, an application cannot use the channel to
communicate anymore, until the CAN controller is reset. With PCAN-
Basic it is not possible to reset the CAN controller through a function
directly. Consider using the PCAN-Basic property
PCAN_BUSOFF_AUTORESET which instructs the API to
automatically reset the CAN controller when a bus-off state is
detected.
Another way to reset errors like BUSOFF, BUSWARNING, and
BUSPASSIVE, is to uninitialize and initialise again the channel used.
This causes a hardware reset.
The message type (see TPCANMessageType) of a CAN message
indicates if the message is a 11-bit, 29-bit, FD, RTR, Error, or Status
message. This value should be checked every time a message has
been read successfully.
If the bit PCAN_MESSAGE_ERRFRAME is set in the
TPCANMsg.MSGTYPE field, the message is an Error frame (see
Error Frames).
If the bit PCAN_MESSAGE_STATUS is set in the
TPCANMsg.MSGTYPE field, the message is a Status message. The
ID and DLC fields do not contain valid data. The first 4 data bytes of
the message contain the Error Code. The MSB of the Error Code is in
data byte 0, the LSB is in data byte 3. If a status message was read
the return value of ReadFD is also the error code.
Examples:
Example
C++CLR:
TPCANStatus result;
StringBuilder^ strMsg;
TPCANMsgFD msg;
do
{
// Check the receive queue for new messages
//
result = PCANBasic::ReadFD(PCANBasic::PCAN_USBBUS1
if (result != TPCANStatus::PCAN_ERROR_QRCVEMPTY
{
// Process the received message
//
MessageBox::Show("A message was received");
ProcessMessage(msg);
}
else
{
// An error occurred, get a text describing the err
//
PCANBasic::GetErrorText(result, 0, strMsg);
MessageBox::Show(strMsg->ToString());
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & TPCANStatus::PCAN_ERROR_QRCVEMPTY
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim msg As TPCANMsgFD
Do
' Check the receive queue for new messages
'
result = PCANBasic.ReadFD(PCANBasic.PCAN_USBBUS1
If result <> TPCANStatus.PCAN_ERROR_QRCVEMPTY
' Process the received message
'
MessageBox.Show("A message was received")
ProcessMessage(msg)
Else
' An error occurred, get a text describing the erro
'
PCANBasic.GetErrorText(result, 0, strMsg)
MessageBox.Show(strMsg.ToString())
' Here can be decided if the loop has to be termin
' status is bus-off)
'
HandleReadError(result)
End If
' Try to read a message from the receive queue of the PCAN-
' until the queue is empty
'
Loop While ((result And TPCANStatus.PCAN_ERROR_QRCVEMPTY
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
msg: TPCANMsgFD;
begin
repeat
// Check the receive queue for new messages
//
result := TPCANBasic.ReadFD(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_QRCVEMPTY) Then
begin
// Process the received message
//
MessageBox(0,'A message was received',
ProcessMessage(msg);
end
else
begin
// An error occurred, get a text describing the
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
// Here can be decided if the loop has to be t
// status is bus-off)
//
HandleReadError(result);
end;
// Try to read a message from the receive queue of the
// until the queue is empty
//
until ((TPCANStatus(Integer(result) AND Integer
See Also
WriteFD
Using Events
Error Frames
ReadFD(TPCANHandle, TPCANMsgFD,
TPCANTimestampFD)
Reads a CAN message and its time stamp from the receive queue of
a FD capable PCAN Channel.
Syntax
Pascal OO
class function ReadFD(
Channel: TPCANHandle;
var MessageBuffer: TPCANMsgFD;
var TimestampBuffer: TPCANTimestampFD
):TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_ReadFD
public static extern TPCANStatus ReadFD(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
out TPCANMsgFD MessageBuffer,
out TPCANTimestampFD TimestampBuffer);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_ReadFD
static TPCANStatus ReadFD(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
TPCANMsgFD %MessageBuffer,
TPCANTimestampFD %TimestampBuffer);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_ReadFD
Public Shared Function ReadFD( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
ByRef MessageBuffer As TPCANMsgFD, _
ByRef TimestampBuffer As TPCANTimestampFD)
End Function
Parameters
Parameters Description
Returns
Remarks
The use of Read and ReadFD are mutually exclusive. The PCAN
Channel passed to this method must be initialized using InitializeFD
(plain function: CAN_InitializeFD). Otherwise the error
PCAN_ERROR_ILLOPERATION is returned.
If the time when the message was received is not needed, use the
overloaded ReadFD method.
The ReadFD method returns received messages or status messages
from the receive queue. It is important to call ReadFD repeatedly until
the queue is empty. In case there are no more messages in queue,
the value PCAN_ERROR_QRCVEMPTY is returned. The error code
PCAN_ERROR_QRCVEMPTY is also returned if the reception of
messages is disabled. See Receive Status Parameter for more
information.
The receive queue can contain up to 32767 messages.
There are two possibilities for reading messages from the receive
queue of a Channel:
Time-Triggered Reading: Consists in periodically calls to the ReadFD
method. Typically, an application start a timer that every 50 or 100
milliseconds check for messages, calling the ReadFD method in a
loop until the value of PCAN_ERROR_QRCVEMTY or another error
condition is reached.
Event-Triggered Reading: Consists in reacting to a notification sent by
the PCAN driver to a registered application, when a message is
received and inserted in its receive queue. See Using Events to
obtain more information about reading with events.
About bus errors / Status messages
If a bus-off error occur, an application cannot use the channel to
communicate anymore, until the CAN controller is reset. With PCAN-
Basic it is not possible to reset the CAN controller through a function
directly. Consider using the PCAN-Basic property
PCAN_BUSOFF_AUTORESET which instructs the API to
automatically reset the CAN controller when a bus-off state is
detected.
Another way to reset errors like BUSOFF, BUSWARNING, and
BUSPASSIVE, is to uninitialize and initialise again the channel used.
This causes a hardware reset.
The message type (see TPCANMessageType) of a CAN message
indicates if the message is a 11-bit, 29-bit, FD, RTR, Error, or Status
message. This value should be checked every time a message has
been read successfully.
If the bit PCAN_MESSAGE_ERRFRAME is set in the
TPCANMsg.MSGTYPE field, the message is an Error frame (see
Error Frames).
If the bit PCAN_MESSAGE_STATUS is set in the
TPCANMsg.MSGTYPE field, the message is a Status message. The
ID and DLC fields do not contain valid data. The first 4 data bytes of
the message contain the Error Code. The MSB of the Error Code is in
data byte 0, the LSB is in data byte 3. If a status message was read
the return value of ReadFD is also the error code.
Examples:
Example
The following example shows the use of method ReadFD on the
channel PCAN_USBBUS1. In case of failure, the returned code will
be translated to a text (according with the operating system language)
in English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized using the
method InitializeFD and that the following code is an OnTimer event
handler method.
C#:
TPCANStatus result;
StringBuilder strMsg;
TPCANMsgFD msg;
TPCANTimestampFD time;
do
{
// Check the receive queue for new messages
//
result = PCANBasic.ReadFD(PCANBasic.PCAN_USBBUS1
if (result != TPCANStatus.PCAN_ERROR_QRCVEMPTY
{
// Process the received message
//
MessageBox.Show("A message was received");
ProcessMessage(msg);
}
else
{
// An error occurred, get a text describing the err
//
PCANBasic.GetErrorText(result, 0, strMsg);
MessageBox.Show(strMsg.ToString());
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & TPCANStatus.PCAN_ERROR_QRCVEMPTY) !=
C++CLR:
TPCANStatus result;
StringBuilder^ strMsg;
TPCANMsgFD msg;
TPCANTimestampFD time;
do
{
// Check the receive queue for new messages
//
result = PCANBasic::ReadFD(PCANBasic::PCAN_USBBUS1
if (result != TPCANStatus::PCAN_ERROR_QRCVEMPTY
{
// Process the received message
//
MessageBox::Show("A message was received");
ProcessMessage(msg);
}
else
{
// An error occurred, get a text describing the err
//
PCANBasic::GetErrorText(result, 0, strMsg);
MessageBox::Show(strMsg->ToString());
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & TPCANStatus::PCAN_ERROR_QRCVEMPTY
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim msg As TPCANMsgFD
Dim time As TPCANTimestampFD
Do
' Check the receive queue for new messages
'
result = PCANBasic.ReadFD(PCANBasic.PCAN_USBBUS1
If result <> TPCANStatus.PCAN_ERROR_QRCVEMPTY
MessageBox.Show("A message was received")
ProcessMessage(msg)
Else
' An error occurred, get a text describing the erro
'
PCANBasic.GetErrorText(result, 0, strMsg)
MessageBox.Show(strMsg.ToString())
' Here can be decided if the loop has to be termin
' status is bus-off)
'
HandleReadError(result)
End If
' Try to read a message from the receive queue of the PCAN-
' until the queue is empty
'
Loop While ((result And TPCANStatus.PCAN_ERROR_QRCVEMPTY
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
msg: TPCANMsgFD;
time: TPCANTimestampFD;
begin
repeat
// Check the receive queue for new messages
//
result := TPCANBasic.ReadFD(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_QRCVEMPTY) Then
begin
// Process the received message
//
MessageBox(0,'A message was received',
ProcessMessage(msg);
end
else
begin
// An error occurred, get a text describing the
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
// Here can be decided if the loop has to be t
// status is bus-off)
//
HandleReadError(result);
end;
// Try to read a message from the receive queue of the
// until the queue is empty
//
until ((TPCANStatus(Integer(result) AND Integer
See Also
WriteFD
Using Events
Error Frames
ReadFD(TPCANHandle)
Reads a CAN message and its time stamp from the receive queue of
a FD capable PCAN Channel.
Syntax
Python
def ReadFD(
self,
Channel)
Parameters
Parameters Description
Returns
Remarks
The use of Read and ReadFD are mutually exclusive. The PCAN
Channel passed to this method must be initialized using InitializeFD
(plain function: CAN_InitializeFD). Otherwise the error
PCAN_ERROR_ILLOPERATION is returned.
The ReadFD method returns received messages or status messages
from the receive queue. It is important to call ReadFD repeatedly until
the queue is empty. In case there are no more messages in queue,
the value PCAN_ERROR_QRCVEMPTY is returned. The error code
PCAN_ERROR_QRCVEMPTY is also returned if the reception of
messages is disabled. See Receive Status Parameter for more
information.
The receive queue can contain up to 32767 messages.
There are two possibilities for reading messages from the receive
queue of a Channel:
Time-Triggered Reading: Consists in periodically calls to the ReadFD
method. Typically, an application start a timer that every 50 or 100
milliseconds check for messages, calling the ReadFD method in a
loop until the value of PCAN_ERROR_QRCVEMTY or another error
condition is reached.
Event-Triggered Reading: Consists in reacting to a notification sent by
the PCAN driver to a registered application, when a message is
received and inserted in its receive queue. See Using Events to
obtain more information about reading with events.
About bus errors / Status messages
If a bus-off error occur, an application cannot use the channel to
communicate anymore, until the CAN controller is reset. With PCAN-
Basic it is not possible to reset the CAN controller through a function
directly. Consider using the PCAN-Basic property
PCAN_BUSOFF_AUTORESET which instructs the API to
automatically reset the CAN controller when a bus-off state is
detected.
Another way to reset errors like BUSOFF, BUSWARNING, and
BUSPASSIVE, is to uninitialize and initialise again the channel used.
This causes a hardware reset.
The message type (see TPCANMessageType) of a CAN message
indicates if the message is a 11-bit, 29-bit, FD, RTR, Error, or Status
message. This value should be checked every time a message has
been read successfully.
If the bit PCAN_MESSAGE_ERRFRAME is set in the
TPCANMsg.MSGTYPE field, the message is an Error frame (see
Error Frames).
If the bit PCAN_MESSAGE_STATUS is set in the
TPCANMsg.MSGTYPE field, the message is a Status message. The
ID and DLC fields do not contain valid data. The first 4 data bytes of
the message contain the Error Code. The MSB of the Error Code is in
data byte 0, the LSB is in data byte 3. If a status message was read
the return value of ReadFD is also the error code.
Examples:
Example
See Also
WriteFD
Using Events
Error Frames
Write
Transmits a CAN message.
Syntax
Pascal OO
class function Write(
Channel: TPCANHandle;
var MessageBuffer: TPCANMsg
): TPCANStatus;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Write
public static extern TPCANStatus Write(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
ref TPCANMsg MessageBuffer);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_Write
static TPCANStatus Write(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
TPCANMsg %MessageBuffer);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_Write
Public Shared Function Write( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
ByVal MessageBuffer As TPCANMsg) As TPCANStatus
End Function
Python
def Write(
self,
Channel,
MessageBuffer)
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of the method Write on the
channel PCAN_USBBUS1. In case of failure, the returned code will
be translated to a text (according with the operating system language)
in English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized.
C#:
TPCANStatus result;
StringBuilder strMsg;
TPCANMsg msg;
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
TPCANMsg^ msg;
strMsg = gcnew StringBuilder(256);
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim msg As TPCANMsg
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
msg: TPCANMsg;
begin
// A CAN message is configured
//
msg.ID := $100;
msg.MSGTYPE := PCAN_MESSAGE_STANDARD;
msg.LEN := 3;
msg.DATA[0] := 1;
msg.DATA[1] := 2;
msg.DATA[2] := 3;
Python:
# A CAN message is configured
#
msg = TPCANMsg()
msg.ID = 0x100
msg.MSGTYPE = PCAN_MESSAGE_STANDARD
msg.LEN = 3
msg.DATA[0] = 1
msg.DATA[1] = 2
msg.DATA[2] = 3
See Also
Read
SetValue
WriteFD
Transmits a CAN message using a FD capable PCAN Channel.
Syntax
Pascal OO
class function WriteFD(
Channel: TPCANHandle;
var MessageBuffer: TPCANMsgFD
): TPCANStatus;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_WriteFD
public static extern TPCANStatus WriteFD(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
ref TPCANMsgFD MessageBuffer);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_WriteFD
static TPCANStatus WriteFD(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
TPCANMsgFD %MessageBuffer);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_WriteFD
Public Shared Function WriteFD( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
ByRef MessageBuffer As TPCANMsgFD) As TPCANStatus
End Function
Python
def WriteFD(
self,
Channel,
MessageBuffer)
Parameters
Parameters Description
Returns
Remarks
The use of Write and WriteFD are mutually exclusive. The PCAN
Channel passed to this method must be initialized using InitializeFD
(plain function: CAN_InitializeFD). Otherwise the error
PCAN_ERROR_ILLOPERATION is returned.
If a bus-off error occur, an application cannot use the channel to
communicate anymore, until the CAN controller is reset. With PCAN-
Basic it is not possible to reset the CAN controller through a method
directly. Consider using the PCAN-Basic property
PCAN_BUSOFF_AUTORESET which instructs the API to
automatically reset the CAN controller when a bus-off state is
detected.
Another way to reset errors like BUSOFF, BUSWARNING, and
BUSPASSIVE, is to uninitialize and initialise again the channel used.
This causes a hardware reset.
Python Notes
Class-Method: Unlike the .NET Framework, under Python a
variable has to be instantiated with an object of type PCANBasic
in order to use the API functionality.
Python's first argument convention: Under Python, 'self' is a
parameter that is automatically included within the call of this
method, within a PCANBasic object and hasn't to be indicated in
a method call. This parameter represents the calling object itself.
Example
The following example shows the use of the method WriteFD on the
channel PCAN_USBBUS1. In case of failure, the returned code will
be translated to a text (according with the operating system language)
in English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized using the
method InitializeFD.
C#:
TPCANStatus result;
StringBuilder strMsg;
TPCANMsgFD msg;
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
TPCANMsgFD^ msg;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim msg As TPCANMsgFD
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
msg: TPCANMsgFD;
I: Integer;
begin
// A CAN message is configured
//
msg.ID := $100;
msg.MSGTYPE := TPCANMessageType(Byte(PCAN_MESSAGE_STAND
Python:
# A CAN message is configured
#
msg = TPCANMsgFD()
msg.ID = 0x100
msg.MSGTYPE = PCAN_MESSAGE_STANDARD.value | PCAN_MESSAGE_FD
See Also
ReadFD
SetValue
Plain function Version: CAN_WriteFD
GetValue
Retrieves information from a PCAN Channel.
Overloads
Function Description
GetValue(TPCANHandle, TPCANParameter, Retrieves
String, UInt32) information
from a PCAN
Channel in text
form.
GetValue(TPCANHandle, TPCANParameter, Retrieves
UInt32, UInt32) information
from a PCAN
Channel in
numeric form
(32-Bit).
GetValue(TPCANHandle, TPCANParameter, Retrieves
UInt64, UInt32) information
from a PCAN
Channel in
numeric form
(64-Bit).
GetValue(TPCANHandle,TPCANParameter) Retrieves
information
from a PCAN
Channel.
GetValue(TPCANHandle, TPCANParameter,
String, UInt32)
Retrieves information from a PCAN Channel in text form.
Syntax
Pascal OO
class function GetValue(
Channel: TPCANHandle;
Parameter: TPCANParameter;
StringBuffer: PChar;
BufferLength: LongWord
): TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetValue
public static extern TPCANStatus GetValue(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType.U1)]
TPCANParameter Parameter,
StringBuilder StringBuffer,
UInt32 BufferLength);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetValue
static TPCANStatus GetValue(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType::U1)]
TPCANParameter Parameter,
StringBuilder^ StringBuffer,
UInt32 BufferLength);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_GetValue
Public Shared Function GetValue( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPCANParameter, _
ByVal StringBuffer As StringBuilder, _
ByVal BufferLength As UInt32) As TPCANStatus
End Function
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of the method GetValue on the
channel PCAN_USBBUS1 to get the PCAN-Channel version text. In
case of failure, the returned code will be translated to a text
(according with the operating system language) in English, German,
Italian, French or Spanish, and it will be shown to the user.
Note: It is assumed that the channel was already initialized
InitializeFD.
C#:
TPCANStatus result;
StringBuilder strMsg;
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Pascal OO:
var
result: TPCANStatus;
strMsg: array [0..256] of Char;
begin
See Also
SetValue
TPCANParameter
Parameter Value Definitions
GetValue(TPCANHandle, TPCANParameter,
UInt32, UInt32)
Retrieves information from a PCAN Channel in numeric form.
Syntax
Pascal OO
class function GetValue(
Channel: TPCANHandle;
Parameter: TPCANParameter;
NumericBuffer: PLongWord;
BufferLength: LongWord
): TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetValue
public static extern TPCANStatus GetValue(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType.U1)]
TPCANParameter Parameter,
out UInt32 NumericBuffer,
UInt32 BufferLength);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetValue
static TPCANStatus GetValue(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType::U1)]
TPCANParameter Parameter,
UInt32 %NumericBuffer,
UInt32 BufferLength);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_GetValue
Public Shared Function GetValue( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPCANParameter, _
ByRef NumericBuffer As UInt32, _
ByVal BufferLength As UInt32) As TPCANStatus
End Function
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of the method GetValue on the
channel PCAN_USBBUS1 to check if the Message Filter is fully
opened. In case of failure, the returned code will be translated to a
text (according with the operating system language) in English,
German, Italian, French or Spanish, and it will be shown to the user.
Note: It is assumed that the channel was already initialized.
C#:
TPCANStatus result;
StringBuilder strMsg;
UInt32 iBuffer;
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
UInt32 iBuffer;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim iBuffer As UInt32
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
iBuffer: LongWord;
begin
// The status of the message filter of the PCAN-USB Cha
//
result := TPCANBasic.GetValue(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
begin
// A text is shown giving information about the cur
//
if iBuffer = TPCANBasic.PCAN_FILTER_OPEN then
MessageBox(0, 'The message filter for the P
if iBuffer = TPCANBasic.PCAN_FILTER_CLOSE
MessageBox(0, 'The message filter for the P
if iBuffer = TPCANBasic.PCAN_FILTER_CUSTOM
MessageBox(0, 'The message filter for the P
end;
See Also
SetValue
TPCANParameter
Parameter Value Definitions
GetValue(TPCANHandle, TPCANParameter,
UInt64, UInt32)
Retrieves information from a PCAN Channel in numeric form.
Pascal OO
class function GetValue(
Channel: TPCANHandle;
Parameter: TPCANParameter;
NumericBuffer: PUInt64;
BufferLength: LongWord
): TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetValue
public static extern TPCANStatus GetValue(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType.U1)]
TPCANParameter Parameter,
out UInt64 NumericBuffer,
UInt32 BufferLength);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetValue
static TPCANStatus GetValue(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType::U1)]
TPCANParameter Parameter,
UInt64 %NumericBuffer,
UInt32 BufferLength);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_GetValue
Public Shared Function GetValue( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPCANParameter, _
ByRef NumericBuffer As UInt64, _
ByVal BufferLength As UInt32) As TPCANStatus
End Function
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of the method GetValue on the
channel PCAN_USBBUS1 to retrieve the configured message filter as
11-bit acceptance code and mask. In case of failure, the returned
code will be translated to a text (according with the operating system
language) in English, German, Italian, French or Spanish, and it will
be shown to the user.
Note: It is assumed that the channel was already initialized.
C#:
TPCANStatus result;
StringBuilder strMsg;
UInt64 i64Buffer;
UInt32 iCode, iMask;
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
UInt64 i64Buffer;
UInt32 iCode, iMask;
strMsg = gcnew StringBuilder(256);
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim i64Buffer As UInt64
Dim iCode As UInt32
Dim iMask As UInt32
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
i64Buffer: UInt64;
iCode, iMask: LongWord;
begin
// The 11-bit acceptance filter of the PCAN-USB Channel
//
result := TPCANBasic.GetValue(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
begin
// Code and mask are extracted from the 64-bit nume
//
iCode := i64Buffer shr 32;
iMask := (i64Buffer And $FFFFFFFF);
See Also
SetValue
TPCANParameter
Parameter Value Definitions
GetValue(TPCANHandle,TPCANParameter)
Retrieves information from a PCAN Channel.
Syntax
Python
def GetValue(
self,
Channel,
Parameter)
Parameters
Parameters Description
Returns
[1]: The requested parameter value (the type of the value depends on
the TPCANParameter requested).
Remarks
Example
The following example shows the use of the method GetValue on the
channel PCAN_USBBUS1 to check if the Message Filter is fully
opened. In case of failure, the returned code will be translated to a
text (according with the operating system language) in English,
German, Italian, French or Spanish, and it will be shown to the user.
Note: It is assumed that the channel was already initialized.
Python:
# The status of the message filter of the PCAN-USB Channel
#
result = objPCAN.GetValue(PCAN_USBBUS1,PCAN_MESSAGE_FILTER
if result[0] != PCAN_ERROR_OK:
# An error occurred, get a text describing the error an
#
result = objPCAN.GetErrorText(result)
print result
else:
# A text is shown giving information about the current
#
if result[1] == PCAN_FILTER_OPEN:
print "The message filter for the PCAN-USB, channel
elif result[1] == PCAN_FILTER_CLOSE:
print "The message filter for the PCAN-USB, channel
elif result[1] == PCAN_FILTER_CUSTOM:
print "The message filter for the PCAN-USB, channel
See Also
SetValue
TPCANParameter
Parameter Value Definitions
Plain function Version: CAN_GetValue
SetValue
Sets a configuration or information value within a PCAN Channel.
Overloads
Function Description
SetValue(TPCANHandle, Sets a configuration or information
TPCANParameter, string value within a PCAN
String, UInt32) Channel.
SetValue(TPCANHandle, Sets a configuration or information
TPCANParameter, numeric value within a PCAN
UInt32, UInt32) Channel (32-Bit).
SetValue(TPCANHandle, Sets a configuration or information
TPCANParameter, numeric value within a PCAN
UInt64, UInt32) Channel (64-Bit).
SetValue(TPCANHandle, Sets a configuration or information
TPCANParameter, value within a PCAN Channel.
Object)
SetValue(TPCANHandle, TPCANParameter,
String, UInt32)
Sets a configuration or information string value within a PCAN
Channel.
Syntax
Pascal OO
class function SetValue(
Channel: TPCANHandle;
Parameter: TPCANParameter;
StringBuffer: PChar;
BufferLength: LongWord
): TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_SetValue
public static extern TPCANStatus SetValue(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType.U1)]
TPCANParameter Parameter,
[MarshalAs(UnmanagedType.LPStr,SizeParamIndex=3)]
string StringBuffer,
UInt32 BufferLength);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_SetValue
static TPCANStatus SetValue(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType::U1)]
TPCANParameter Parameter,
[MarshalAs(UnmanagedType::LPStr,SizeParamIndex=3)]
String^ StringBuffer,
UInt32 BufferLength);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_SetValue
Public Shared Function SetValue( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPCANParameter, _
<MarshalAs(UnmanagedType.LPStr, SizeParamIndex:=3)
ByVal StringBuffer As String, _
ByVal BufferLength As UInt32) As TPCANStatus
End Function
Parameters
Parameters Description
Returns
Example
The following example shows the use of the method SetValue on the
channel PCAN_NONEBUS to set (and activate) the path for the log
file of a PCAN-Basic's debug session. In case of failure, the returned
code will be translated to a text (according with the operating system
language) in English, German, Italian, French or Spanish, and it will
be shown to the user.
Note: It is not needed to have an initialized PCAN channel for using
the Log functionality.
C#:
TPCANStatus result;
StringBuilder strMsg;
string strBuffer;
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
String^ strBuffer;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim strBuffer As String
strMsg = New StringBuilder(256)
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
strBuffer: string;
begin
// The path for the Log file is set.
// Note that this parameter is set using the
// default Channel (PCAN_NONEBUS)
//
strBuffer := 'C:\\Users\Keneth\Desktop';
result := TPCANBasic.SetValue(TPCANBasic.PCAN_NONEBUS
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
MessageBox(0, 'Log path was successfully set'
See Also
GetValue
TPCANParameter
Parameter Value Definitions
SetValue(TPCANHandle, TPCANParameter,
UInt32, UInt32)
Sets a configuration or information numeric value within a PCAN
Channel.
Syntax
Pascal OO
class function SetValue(
Channel: TPCANHandle;
Parameter: TPCANParameter;
NumericBuffer: PLongWord;
BufferLength: LongWord
): TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_SetValue
public static extern TPCANStatus SetValue(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType.U1)]
TPCANParameter Parameter,
ref UInt32 NumericBuffer,
UInt32 BufferLength);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_SetValue
static TPCANStatus SetValue(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType::U1)]
TPCANParameter Parameter,
UInt32 %NumericBuffer,
UInt32 BufferLength);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_SetValue
Public Shared Function SetValue( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPCANParameter, _
ByRef NumericBuffer As UInt32, _
ByVal BufferLength As UInt32) As TPCANStatus
End Function
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of the method SetValue on the
channel PCAN_USBBUS1 to close the message filter. In case of
failure, the returned code will be translated to a text (according with
the operating system language) in English, German, Italian, French or
Spanish, and it will be shown to the user.
Note: It is assumed that the channel was already initialized.
C#:
TPCANStatus result;
StringBuilder strMsg;
UInt32 iBuffer;
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
UInt32 iBuffer;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim iBuffer As UInt32
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
iBuffer: LongWord;
begin
// The message filter is closed
//
iBuffer := TPCANBasic.PCAN_FILTER_CLOSE;
result := TPCANBasic.SetValue(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
MessageBox(0, 'The filter was successfully closed'
See Also
GetValue
TPCANParameter
Parameter Value Definitions
SetValue(TPCANHandle, TPCANParameter,
UInt64, UInt32)
Sets a configuration or information numeric value within a PCAN
Channel.
Syntax
Pascal OO
class function SetValue(
Channel: TPCANHandle;
Parameter: TPCANParameter;
NumericBuffer: PUInt64;
BufferLength: LongWord
): TPCANStatus; overload;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_SetValue
public static extern TPCANStatus SetValue(
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType.U1)]
TPCANParameter Parameter,
ref UInt64 NumericBuffer,
UInt32 BufferLength);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_SetValue
static TPCANStatus SetValue(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
[MarshalAs(UnmanagedType::U1)]
TPCANParameter Parameter,
UInt64 %NumericBuffer,
UInt32 BufferLength);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_SetValue
Public Shared Function SetValue( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Parameter As TPCANParameter, _
ByRef NumericBuffer As UInt64, _
ByVal BufferLength As UInt32) As TPCANStatus
End Function
Parameters
Parameters Description
Returns
Remarks
Use the method SetValue to set configuration information or
environment values of a PCAN Channel as parameters like an
Acceptance Filter. Take in account that not all parameters are
supported for all PCAN-Channels. The access's type of the
parameters can also be different.
More information about the parameters and values that can be set
can be found in Parameter Value Definitions.
Example
The following example shows the use of the method SetValue on the
channel PCAN_USBBUS1 to set a message filter as a 11-bit
acceptance code and mask, allowing only IDs from 0x100 to 0x103. In
case of failure, the returned code will be translated to a text
(according with the operating system language) in English, German,
Italian, French or Spanish, and it will be shown to the user.
Note: It is assumed that the channel was already initialized.
C#:
TPCANStatus result;
StringBuilder strMsg;
UInt64 i64Buffer;
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
UInt64 i64Buffer;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim i64Buffer As UInt64
' The acceptance code and mask are packed as 64-bit value
'
i64Buffer = &H100 ' Acceptance code
i64Buffer <<= 32
i64Buffer = i64Buffer Or &H3 ' Acceptance mask
result = PCANBasic.SetValue(PCANBasic.PCAN_USBBUS1
If result <> TPCANStatus.PCAN_ERROR_OK Then
' An error occurred, get a text describing the error an
'
PCANBasic.GetErrorText(result, 0, strMsg)
MessageBox.Show(strMsg.ToString)
Else
MessageBox.Show("The 11-bit acceptance filter was confi
End If
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
i64Buffer: UInt64;
begin
// The acceptance code and mask are packed as 64-bit va
//
i64Buffer := $100; // Acceptance code
i64Buffer := i64Buffer shl 32;
i64Buffer := i64Buffer Or $3; // Acceptance mask
result := TPCANBasic.SetValue(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
MessageBox(0, 'The 11-bit acceptance filter was con
end;
See Also
GetValue
TPCANParameter
Parameter Value Definitions
SetValue(TPCANHandle, TPCANParameter,
Object)
Sets a configuration or information value within a PCAN Channel.
Syntax
Python
def SetValue(
self,
Channel,
Parameter,
Buffer)
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of the method SetValue on the
channel PCAN_NONEBUS to set (and activate) the path for the log
file of a PCAN-Basic's debug session. In case of failure, the returned
code will be translated to a text (according with the operating system
language) in English, German, Italian, French or Spanish, and it will
be shown to the user.
Note: It is not needed to have an initialized PCAN channel for using
the Log functionality.
Python:
# The path for the Log file is set.
# Note that this parameter is set using the
# default Channel (PCAN_NONEBUS)
#
strBuffer = "C:\Users\Admin\Desktop"
result = objPCAN.SetValue(PCAN_NONEBUS,PCAN_LOG_LOCATION
if result != PCAN_ERROR_OK:
# An error occurred, get a text describing the error an
#
result = objPCAN.GetErrorText(result)
print result[1]
else:
print "Log path was successfully set"
See Also
GetValue
TPCANParameter
Parameter Value Definitions
FilterMessages
Configures the reception filter.
Syntax
Pascal OO
class function FilterMessages(
Channel: TPCANHandle;
FromID: LongWord;
ToID: LongWord;
Mode: TPCANMode
): TPCANStatus;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_FilterMe
public static extern TPCANStatus FilterMessages
[MarshalAs(UnmanagedType.U1)]
TPCANHandle Channel,
UInt32 FromID,
UInt32 ToID,
[MarshalAs(UnmanagedType.U1)]
TPCANMode Mode);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_FilterMe
static TPCANStatus FilterMessages(
[MarshalAs(UnmanagedType::U1)]
TPCANHandle Channel,
UInt32 FromID,
UInt32 ToID,
[MarshalAs(UnmanagedType::U1)]
TPCANMode Mode);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_FilterMes
Public Shared Function FilterMessages( _
<MarshalAs(UnmanagedType.U1)> _
ByVal Channel As TPCANHandle, _
ByVal FromID As UInt32, _
ByVal ToID As UInt32, _
<MarshalAs(UnmanagedType.U1)> _
ByVal Mode As TPCANMode) As TPCANStatus
End Function
Python
def FilterMessages(
self,
Channel,
FromID,
ToID,
Mode)
Parameters
Parameters Description
Remarks
Note that after a PCAN Channel is initialized, the status of its filter is
fully opened. According with the current filter status, calling this
method causes the following behavior:
Filter status is PCAN_FILTER_OPEN: The filter is automatically
closed and then configured with the given range of IDs passed to
this function [FromID, ToID] .
Filter status is PCAN_FILTER_CLOSE: The filter is set to the
given range of IDs passed to this function [FromID, ToID] .
Filter status is PCAN_FILTER_CUSTOM: The filter is expanded
with the given range of Ids [FromID, ToID]. If a smaller or different
range is required than a range that has been configured before,
the filter has to be closed first before calling the method
FilterMessages. To do this use the method SetValue.
The parameter 'Mode' indicates which kind of ID is being used to
register the new filter range. There are two possible values, Standard
(11-bit identifier) or Extended (29-bit identifier). Standard frames are
using the bit positions 28 to 18 of the Acceptance Mask/Code
registers in the SJA1000 CAN controller. Drivers for 82C200 CAN
controllers have to shift the bits down to positions 10 to 0.
Take in account that configuring the message filter cause the CAN
controller to enter the Reset state. This will affect other applications
that communicate with the same PCAN hardware.
Notes:
1. There is only one filter for standard and extended CAN
messages. It seems that the ID from a standard message uses
the most significant 11 bits (bit 18 to 28) of the 29 bits. I.e. the
standard ID 400h is also received by indicating an extended ID
10000000h. For this reason it is not recommended to mix
standard and extended filters, since it can increase the risk of
receiving unwanted messages.
2. Multiple calls of FilterMessages expand the reception filter.
3. It is not guaranteed that an application only receives CAN
messages in the range of FromID to ToID. This is caused by the
operating principle of the SJA1000's acceptance filter. See also
Philips Data Sheet "SJA1000 Stand-alone CAN-controller".
Python Notes
Class-Method: Unlike the .NET Framework, under Python a
variable has to be instantiated with an object of type PCANBasic
in order to use the API functionality.
Python's first argument convention: Under Python, 'self' is a
parameter that is automatically included within the call of this
method, within a PCANBasic object and hasn't to be indicated in
a method call. This parameter represents the calling object itself.
Example
if (result != TPCANStatus.PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error a
//
PCANBasic.GetErrorText(result, 0, strMsg);
MessageBox.Show(strMsg.ToString());
}
else
{
// The message filter is configured to receive the IDs
//
result = PCANBasic.FilterMessages(PCANBasic.PCAN_USBBUS
if (result != TPCANStatus.PCAN_ERROR_OK)
{
// An error occurred, get a text describing the err
//
PCANBasic.GetErrorText(result, 0, strMsg);
MessageBox.Show(strMsg.ToString());
}
else
MessageBox.Show("Filter successfully configured for
}
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
UInt32 iBuffer;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Dim iBuffer As UInt32
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
iBuffer: LongWord;
begin
// The message filter is closed first to ensure the re
//
iBuffer := TPCANBasic.PCAN_FILTER_CLOSE;
result := TPCANBasic.SetValue(TPCANBasic.PCAN_USBBUS1
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the err
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
begin
// The message filter is configured to receive the
//
result := TPCANBasic.FilterMessages(TPCANBasic.PCAN
If (result <> PCAN_ERROR_OK) Then
begin
// An error occurred, get a text describing the
//
TPCANBasic.GetErrorText(result, 0, strMsg);
MessageBox(0, strMsg, 'Error',MB_OK);
end
else
MessageBox(0,'Filter successfully configured fo
end;
Python:
# The message filter is closed first to ensure the recepti
#
result = objPCAN.SetValue(PCAN_USBBUS1,PCAN_MESSAGE_FILTER
if result != PCAN_ERROR_OK:
# An error occurred, get a text describing the error an
#
result = objPCAN.GetErrorText(result)
print result[1]
else:
# The message filter is configured to receive the IDs 2
#
result = objPCAN.FilterMessages(PCAN_USBBUS1,2,5,
if result != PCAN_ERROR_OK:
# An error occurred, get a text describing the erro
#
result = objPCAN.GetErrorText(result)
print result[1]
else:
print "Filter successfully configured for IDs 2,3,4
See Also
SetValue
GetErrorText
Gets a descriptive text for an error code.
Overloads
Function Description
GetErrorText(TPCANStatus,UInt16,String) Gets a
descriptive text
for an error
code.
GetErrorText(TPCANStatus, int) Gets a
descriptive text
for an error
code.
GetErrorText(TPCANStatus,UInt16,String)
Gets a descriptive text for an error code.
Syntax
Pascal OO
class function GetErrorText(
AnError: TPCANStatus;
Language: Word;
StringBuffer: PChar
): TPCANStatus;
C#
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetError
public static extern TPCANStatus GetErrorText(
[MarshalAs(UnmanagedType.U4)]
TPCANStatus AnError,
UInt16 Language,
StringBuilder StringBuffer);
C++ / CLR
[DllImport("PCANBasic.dll", EntryPoint = "CAN_GetError
static TPCANStatus GetErrorText(
[MarshalAs(UnmanagedType::U4)]
TPCANStatus AnError,
UInt16 Language,
StringBuilder^ StringBuffer);
Visual Basic
<DllImport("PCANBasic.dll", EntryPoint:="CAN_GetErrorT
Public Shared Function GetErrorText( _
<MarshalAs(UnmanagedType.U4)> _
ByVal AnError As TPCANStatus, _
ByVal Language As UInt16, _
ByVal StringBuffer As StringBuilder) As TPCANStatu
End Function
Parameters
Parameters Description
Returns
Remarks
Note: If the buffer is to small for the resulting text, the error
PCAN_ERROR_ILLPARAMVAL is returned. Even when only short
texts are being currently returned, a text within this function can have
a maximum of 255 characters. For this reason it is recommended to
use a buffer with a length of at least 256 bytes.
Example
C++/CLR:
TPCANStatus result;
StringBuilder^ strMsg;
Visual Basic:
Dim result As TPCANStatus
Dim strMsg As StringBuilder
Pascal OO:
var
result : TPCANStatus;
strMsg: array [0..256] of Char;
begin
See Also
Primary Language ID
GetErrorText(TPCANStatus, int)
Gets a descriptive text for an error code.
Syntax
Python
def GetErrorText(
self,
Error,
Language = 0)
Parameters
Parameters Description
Returns
Remarks
Python Notes
Class-Method: Unlike the .NET Framework, under Python a
variable has to be instantiated with an object of type PCANBasic
in order to use the API functionality.
Python's first argument convention: Under Python, 'self' is a
parameter that is automatically included within the call of this
method, within a PCANBasic object and hasn't to be indicated in
a method call. This parameter represents the calling object itself.
Example
See Also
Primary Language ID
Functions
The functions of the PCAN-Basic API are divided in 4 groups of
functionality:
Connection
Function Description
CAN_Initialize Initializes a PCAN Channel.
Configuration
Function Description
CAN_SetValue Sets a configuration or information
value within a PCAN Channel.
CAN_FilterMessages Configures the message's reception
filter of a PCAN Channel.
Information
Function Description
CAN_GetValue Retrieves information from a PCAN
Channel.
CAN_GetStatus Retrieves the current BUS status of a
PCAN Channel.
CAN_GetErrorText Returns a descriptive text for an error
code.
Communication
Function Description
CAN_Read Reads a CAN message from the
receive queue of a PCAN Channel.
CAN_ReadFD Reads a CAN message from the
receive queue of a FD capable PCAN
Channel.
CAN_Write Transmits a CAN message using a
connected PCAN Channel.
CAN_WriteFD Transmits a CAN message using a
connected FD capable PCAN
Channel.
CAN_Reset Resets the receive and transmit
queues of a PCAN Channel.
CAN_Initialize
Initializes a PCAN Channel.
Syntax
C++
#ifdef __cplusplus
#define _DEF_ARG =0 // Using of default arguments
#else
#define _DEF_ARG
#endif
Parameters
Parameters Description
Returns
Remarks
Example
....
See Also
CAN_Uninitialize
CAN_GetValue
Understanding PCAN-Basic
CAN_InitializeFD
Initializes a FD capable PCAN Channel.
Syntax
C++
TPCANStatus __stdcall CAN_InitializeFD(
TPCANHandle Channel,
TPCANBitrateFD BitrateFD);
Parameters
Parameters Description
Returns
Remarks
Example
See Also
CAN_Uninitialize
CAN_ReadFD
CAN_WriteFD
CAN_Uninitialize
Uninitializes a PCAN Channel.
Syntax
C++
TPCANStatus __stdcall CAN_Uninitialize(
TPCANHandle Channel
);
Parameters
Parameters Description
Returns
Remarks
Example
....
See Also
CAN_Initialize
CAN_Reset
Resets the receive and transmit queues of a PCAN Channel.
Syntax
C++
TPCANStatus __stdcall CAN_Reset(
TPCANHandle Channel
);
Parameters
Parameters Description
Returns
Remarks
Example
See Also
CAN_Read
CAN_Write
CAN_SetValue
CAN_GetStatus
Gets the current BUS status of a PCAN Channel.
Syntax
C++
TPCANStatus __stdcall CAN_GetStatus(
TPCANHandle Channel
);
Parameters
Parameters Description
Returns
Remarks
Example
See Also
CAN_Read
Reads a CAN message from the receive queue of a PCAN Channel.
Syntax
C++
TPCANStatus __stdcall CAN_Read(
TPCANHandle Channel,
TPCANMsg* MessageBuffer,
TPCANTimestamp* TimestampBuffer
);
Parameters
Parameters Description
Returns
Remarks
do
{
// Check the receive queue for new messages
//
result = CAN_Read(PCAN_USBBUS1,&msg,×tamp
if(result != PCAN_ERROR_QRCVEMPTY)
{
// Process the received message
//
MessageBox("A message was received");
ProcessMessage(msg)
}
else
{
// An error occurred, get a text describing the err
// and handle the error
//
CAN_GetErrorText(result, 0, strMsg);
MessageBox(strMsg);
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & PCAN_ERROR_QRCVEMPTY) != PCAN_ERROR_QRCVEM
See Also
CAN_Write
Using Events
Error Frames
CAN_ReadFD
Reads a CAN message from the receive queue of a FD capable
PCAN Channel.
Syntax
C++
TPCANStatus __stdcall CAN_ReadFD(
TPCANHandle Channel,
TPCANMsgFD* MessageBuffer,
TPCANTimestampFD *TimestampBuffer);
Parameters
Parameters Description
Returns
Remarks
Example
do
{
// Check the receive queue for new messages
//
result = CAN_ReadFD(PCAN_USBBUS1,&msg,×tamp
if(result != PCAN_ERROR_QRCVEMPTY)
{
// Process the received message
//
MessageBox("A message was received");
ProcessMessage(msg)
}
else
{
// An error occurred, get a text describing the err
// and handle the error
//
CAN_GetErrorText(result, 0, strMsg);
MessageBox(strMsg);
// Here can be decided if the loop has to be termi
// status is bus-off)
//
HandleReadError(result);
}
// Try to read a message from the receive queue of the PCAN
// until the queue is empty
//
}while((result & PCAN_ERROR_QRCVEMPTY) != PCAN_ERROR_QRCVEM
See Also
CAN_InitializeFD
CAN_WriteFD
Using Events
Error Frames
CAN_Write
Transmits a CAN message.
Syntax
C++
TPCANStatus __stdcall CAN_Write(
TPCANHandle Channel,
TPCANMsg* MessageBuffer
);
Parameters
Parameters Description
Returns
Remarks
Example
See Also
CAN_Read
CAN_SetValue
CAN_WriteFD
Transmits a CAN message using a connected FD capable PCAN
Channel.
Syntax
C++
TPCANStatus __stdcall CAN_WriteFD(
TPCANHandle Channel,
TPCANMsgFD* MessageBuffer);
Parameters
Parameters Description
Returns
Remarks
Example
The following example shows the use of CAN_WriteFD on the
channel PCAN_USBBUS1. In case of failure, the returned code will
be translated to a text (according with the operating system language)
in English, German, Italian, French or Spanish, and it will be shown to
the user.
Note: It is assumed that the channel was already initialized using
CAN_InitializeFD.
C++:
TPCANMsgFD msg;
TPCANStatus result;
char strMsg[256];
CAN_InitializeFD
CAN_ReadFD
CAN_GetValue
Retrieves information from a PCAN Channel.
Syntax
C++
TPCANStatus __stdcall CAN_GetValue(
TPCANHandle Channel,
TPCANParameter Parameter,
void* Buffer,
WORD BufferLength
);
Parameters
Parameters Description
Returns
Remarks
Example
CAN_SetValue
TPCANParameter
Parameter Value Definitions
CAN_SetValue
Sets a configuration or information value within a PCAN Channel.
Syntax
C++
TPCANStatus __stdcall CAN_SetValue(
TPCANHandle Channel,
TPCANParameter Parameter,
void* Buffer,
WORD BufferLength
);
Parameters
Parameters Description
Returns
Remarks
Use the function CAN_SetValue to set configuration information or
environment values of a PCAN Channel as parameters like the
Message Filter and values like a custom entry in the log file of PCAN-
Basic. Take in account that not all parameters are supported for all
PCAN-Channels. The access's type of the parameters can also be
different.
More information about the parameters and values that can be set
can be found in Parameter Value Definitions.
Example
// Inserts the given text into the Log file of the PCAN-Bas
// Note: If the Log functionality is disabled, this call wi
//activate the log process.
//
result = CAN_SetValue(PCAN_NONEBUS, PCAN_LOG_TEXT,
if(result != PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error a
//
CAN_GetErrorText(result, 0, strMsg);
MessageBox(strMsg);
}
else
MessageBox("The text was successfully logged in the PCA
See Also
CAN_GetValue
TPCANParameter
Parameter Value Definitions
CAN_FilterMessages
Configures the reception filter.
Syntax
C++
TPCANStatus __stdcall CAN_FilterMessages(
TPCANHandle Channel,
DWORD FromID,
DWORD ToID,
TPCANMode Mode
);
Parameters
Parameters Description
Returns
Remarks
Note that after a PCAN Channel is initialized, the status of its filter is
fully opened. According with the current filter status, calling this
function causes the following behavior:
Filter status is PCAN_FILTER_OPEN: The filter is automatically
closed and then configured with the given range of IDs passed to
this function [FromID, ToID] .
Filter status is PCAN_FILTER_CLOSE: The filter is set to the
given range of IDs passed to this function [FromID, ToID] .
Filter status is PCAN_FILTER_CUSTOM: The filter is expanded
with the given range of Ids [FromID, ToID]. If a smaller or different
range is required than a range that has been configured before,
the filter has to be closed first before calling the
CAN_FilterMessages function. To do this use the function
CAN_SetValue.
The parameter 'Mode' indicates which kind of ID is being used to
register the new filter range. There are two possible values, Standard
(11-bit identifier) or Extended (29-bit identifier). Standard frames are
using the bit positions 28 to 18 of the Acceptance Mask/Code
registers in the SJA1000 CAN controller. Drivers for 82C200 CAN
controllers have to shift the bits down to positions 10 to 0.
Take in account that configuring the message filter cause the CAN
controller to enter the Reset state. This will affect other applications
that communicate with the same PCAN hardware.
Notes:
1. There is only one filter for standard and extended CAN
messages. It seems that the ID from a standard message uses
the most significant 11 bits (bit 18 to 28) of the 29 bits. I.e. the
standard ID 400h is also received by indicating an extended ID
10000000h. For this reason it is not recommended to mix
standard and extended filters, since it can increase the risk of
receiving unwanted messages.
2. Multiple calls of CAN_FilterMessages expand the reception
filter.
3. It is not guaranteed that an application only receives CAN
messages in the range of FromID to ToID. This is caused by the
operating principle of the SJA1000's acceptance filter. See also
Philips Data Sheet "SJA1000 Stand-alone CAN-controller".
Example
if(result != PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error a
//
CAN_GetErrorText(result, 0, strMsg);
MessageBox(strMsg);
}
else
{
// The message filter is configured to receive the IDs
//
result = CAN_FilterMessages(PCAN_USBBUS1, 2, 5, PCAN_ME
if(result != PCAN_ERROR_OK)
{
// An error occurred, get a text describing the err
//
CAN_GetErrorText(result, 0, strMsg);
MessageBox(strMsg);
}
else
MessageBox("Filter successfully configured for IDs
}
See Also
CAN_SetValue
CAN_GetErrorText
Returns a descriptive text for an error code.
Syntax
C++
TPCANStatus __stdcall CAN_GetErrorText(
TPCANStatus Error,
WORD Language,
LPSTR Buffer
);
Parameters
Parameters Description
Returns
Remarks
Note: If the buffer is to small for the resulting text, the error
PCAN_ERROR_ILLPARAMVAL is returned. Even when only short
texts are being currently returned, a text within this function can have
a maximum of 255 characters. For this reason it is recommended to
use a buffer with a length of at least 256 bytes.
Example
See Also
Primary Language ID
Definitions
The PCAN-Basic API defines the following values:
Name Description
PCAN Handle Defines the handles for the different
Definitions PCAN Channels.
Parameter Value Defines the possible values for setting
Definitions and getting PCAN's environment
information with the functions
CAN_SetValue and CAN_GetValue.
FD Bit rate Parameter Defines the different configuration
Definitions parameters used to create a Flexible
Data rate string for FD capable PCAN-
Channels initialization.
See Also
Activation values:
Filter values:
Int32 PCAN_CHANNEL_AVAILABLE 1
Int32 PCAN_CHANNEL_OCCUPIED 2
Trace-Configuration values*:
Feature values*:
Service-Status values:
Remarks
See Also
PCAN Handle Definitions
Remarks
Parameter Value
Range
f_clock [80000000,
60000000,
40000000,
30000000,
24000000,
20000000]
f_clock_mhz [80, 60, 40,
30, 24, 20]
nom_brp 1 .. 1024
nom_tseg1 1 .. 256
nom_tseg2 1 .. 128
nom_sjw 1 .. 128
data_brp 1 .. 1024
data_tseg1 1 .. 32
data_tseg2 1 .. 16
data_sjw 1 .. 16
Python:
The definitions of these values have the following form:
TPCANBitrateFD(string) where string is the value contained in the
"value" column. e.g. PCAN_BR_CLOCK is defined as
TPCANBitrateFD("f_clock").
See Also
Additional Information
PCAN is the platform for PCAN-Basic. In the following topics there is
an overview of PCAN and the fundamental practice with the interface
DLL CanApi4 (PCAN-API)
In this Chapter
Topics Description
PCAN This section contains an introduction to
Fundamentals PCAN.
PCAN-Light This section contains information about the
previous version of the PCAN-Basic.
PCAN-API This section compares the PCAN-Basic and
CanApi4 interfaces, with a function
description of CanApi4.
Error Frames This section contains information about CAN
Error frames.
Log File This section contains information about
Generation logging debug data within PCAN-Basic.
PCAN Fundamentals
PCAN is a synonym for PEAK CAN APPLICATIONS and is a flexible
system for planning, developing and using Controller Area Networks
(CAN). It is a powerful product for both the developer and the end-
user.
The PCAN system consists of a collection of Windows Device Drivers.
These allow the Real-time connection of Windows applications to all
CAN busses that are physically connected to the PC via a PCAN
hardware. The interface to the user and the manager of a CAN-
equipped installation are the so-called PCAN clients. With their help
process factors are controlled and visualized. The drivers permit the
connection of several clients, which are then able to communicate via
the CAN busses. Furthermore, several hardware components are
supported, which are based on the CAN controller Philips SJA1000.
So-called Nets are available. These specify virtual CAN busses that
are extended into the PC. Several clients can connect to a virtual
CAN bus. The connection to the outside world (a physical CAN bus) is
possible with a hardware interface, e.g. the PCAN-Dongle or the
PCAN-ISA card. The following figures give an overview of possible
configurations.
Following rules apply to PCAN clients, nets and hardware:
A PCAN client can be connected to more than one net.
A net supplies several PCAN clients.
A hardware component belongs to not more than one Net.
A Net can have no hardware.
If a Client sends a message, it will be transferred to every other
Client and to the external CAN bus via the hardware.
If a message is received over the hardware, it is received by
every client. Every client receives only those messages, which
pass its acceptance filter.
Definition of the installed hardware and of the nets. Per hardware
several nets may be defined. But only one net can be active.
Clients connect to a net using the net name.
Every PCAN client has a transmission queue, where CAN
messages to be transmitted are waiting until the individual
transmission time. At occurrence of the transmission time they
are written into the transmission queue of the PCAN hardware.
Every hardware contains a receive queue for buffering received
CAN messages.
See Also
Understanding PCAN-Basic
PCAN-Light
PCAN-Light is the previous version of the PCAN-Basic, the small API
variant to PCAN-API. It makes a fast and comprehensive working
possible with the CAN bus system. The connection between the
application program and the PCAN hardware is made by the
appropriate device driver. The following illustration gives a short
overview.
Following rules apply to PCAN-Light client (application software)
and PCAN hardware:
A client is in each case assigned to a hardware at each time. A
connection with one client to different hardware types is not
possible at the same time.
If a multi-channel hardware is present, each channel is treated
like a separate hardware.
If a Client sends a message, it will be transferred to every other
Client and to the external CAN bus via the hardware.
If a PCAN hardware is connected to a client, then no further client
can access the same hardware.
If a message is received over the hardware, it is received by
every client. Every client receives only those messages, which
pass its message (acceptance) filter.
Every PCAN-Light client has a transmission queue, where CAN
messages to be transmitted are waiting until the individual
transmission time. At occurrence of the transmission time they
are written into the transmission queue of the PCAN hardware.
Every hardware contains a transmission queue for buffering CAN
messages to be transmitted.
See Also
PCAN Fundamentals
PCAN-API
Also called CanApi4 interface, is a synonym for CAN Application
Programming Interface (version 2) and is a comprehensively
programming interface to the PCAN system of the company PEAK-
System Technik GmbH. This interface is more comprehensive than
PCAN-Basic.
Important difference to PCAN-Basic:
Transmit a CAN message at a fixed point of time.
Several application programs could be connected to one PCAN-
PC hardware.
Detailed information to PCAN-PC hardware and the PCAN
system (PCAN net and PCAN client).
The PCAN client is connected via the net to the PCAN-PC
hardware.
The following text is a short overview to the CanApi2 functions. The
functions itself can be categorized as follows:
Control
Function Description
CloseAll Disconnects all hardware, nets, and
clients.
RegisterHardware Registers a Not-Plug-and-Play CAN
hardware.
RegisterHardwarePCI Registers a PCI CAN hardware.
RegisterNet Defines of a PCAN net.
RemoveHardware Removes and deactivates CAN
hardware.
RemoveNet Removes a PCAN net.
Configuration
Function Description
SetDeviceName Sets the PCAN device to be used for
subsequent CanApi2 function calls.
SetDriverParam Configures a driver parameter, eg. the size of
the receive or transmit buffer.
SetHwParam Configures a hardware parameter, eg.
- the PEAK serial number,
- and additional parameters for the PCAN-
USB hardware.
SetNetParam Configures net parameter.
Client
Function Description
ConnectToNet Connects a client to a PCAN net.
DisconnectFromNet Disconnects a client from a PCAN net.
RegisterClient Registers an application as PCAN client.
RegisterMsg Expands the reception filter of a client.
RemoveAllMsgs Resets the filter of a Client for a connected
Net.
RemoveClient Removes a client from the driver.
ResetClient Resets the receive and transmit queue of a
client.
ResetHardware Resets a CAN hardware.
SetClientFilter Configures the reception filter of a client.
SetClientFilterEx Configures the reception filter of a client
SetClientParam Configures a client parameter, eg.
- self-receive mode of transmitted
messages.
- improve the accuracy of the reception
filter.
Communication
Function Description
Read Reads a number of CAN_*-records from the
client's receive queue. Records are CAN
messages, error events, and other
information.
Write Writes a number of CAN messages or other
commands into the transmit queue of a
client.
Information
Function Description
GetClientParam Retrieves client parameter, eg.
- total number of transmitted or received
CAN messages,
- the PCAN driver name, PCAN net, or
PCAN client name
- the number of received bits.
GetDeviceName Retrieves the currently used PCAN device.
GetDiagnosticText Reads the diagnostic text buffer.
GetDriverName Retrieves the name of a PCAN device
type.
GetDriverParam Retrieves a driver parameter.
GetErrText Translates an error code into a text.
GetHwParam Retrieves a hardware parameter.
GetNetParam Retrieves a net parameter.
GetSystemTime Gets the system time.
Msg2Text Creates a text form of a CAN message.
GetHardwareStatus Detects the current status of a CAN
hardware.
GetVersionInfo Reads version and copyright information
from the driver.
Error Frames
Error Frames can be received if:
the hardware represented by the connected PCAN-Channel
supports error frames generation,
the connected PCAN-Channel configured the parameter
PCAN_ALLOW_ERROR_FRAMES using the function
CAN_SetValue (class-method: SetValue) to activate the error
frames.
The error frame data will be placed into a TPCANMsg or
TPCANMsgFD structure, according to the kind of initialization used,
and its MSGTYPE field will have the PCAN_MESSAGE_ERRFRAME
bit set.
The following list shows the elements of an error frame:
Remarks
For further information about this, see Philips Data Sheet "SJA1000
Stand-alone CAN controller".
In order to enable the log file generation, the following registry key
must be created:
HKEY_CURRENT_USER\SOFTWARE\PEAK-System\PCAN-Basic\Log
Remarks:
The registry key should be deleted (or renamed) after a debug
session is done. If the key is leaved, all PCAN-Basic applications
running under the same user account will remain writing data to their
log files, generating in this way huge text files that consume hard-disk
space unnecessarily.
PCAN-Basic Documentation