Welcome to the PCAN-Basic.NET Package Documentation

This documentation refers to the use of the PCAN-Basic.NET package for connecting to and communicating with CAN and CAN FD Buses using the .NET environment.

The underlaying PCAN-Basic API (application programming interface) allows easy development of powerful software with CAN and CAN FD support. It includes all of the functions that an application needs in order to communicate with PCAN PC hardware. The cross-operating-system design makes it possible to easily port software projects between platforms.

PCAN-Basic consists of the actual device driver and an interface DLL, which provides the API functions.

As the successor to PCAN-Light, PCAN-Basic offers increased functionality and extended language support. It provides various functions for developers under C++, C#, C++/CLR, Delphi, VB.NET, Java, and Python 3.x.

See Also

Other Resources

Introduction

Copyright © 2024, PEAK-System Technik GmbH, All rights reserved

Send comments on this topic to PEAK-System Technik GmbH


Introduction

The PCAN system of the company PEAK-System Technik GmbH comprises of a collection of Windows device drivers, which allow the real-time connection of Windows applications to all CAN buses physically connected to a PC.

PCAN-Basic, successor of PCAN-Light, is a simple programming interface to the PCAN system. Via the PCAN-Basic library (dll), it is possible to connect own applications to the device drivers and the PCAN hardware, to communicate with the CAN buses.

In this chapter
Topic | description
Understanding PCAN-Basic | This section contains an introduction to the PCAN-Basic API.
Using Events | This section offers information about using notifications for CAN messages reading.
How-To's and Q&A's | This section contents explanation to some typical operations carried out with and for the PCAN-Basic.NET assembly.
License Regulations | This section shows information about the license regulations to this software.
Contact Information | This section offers information about how to contact PEAK-System.
Syntax section title

Syntax content

See Also

Other Resources

Welcome to the PCAN-Basic.NET Package Documentation


Understanding PCAN-Basic

PCAN-Basic is a programming application interface (API) for CAN communication using the PCAN system of the company PEAK-System Technik GmbH. It consists of a collection of Windows Device Drivers which allow the real-time connection of Windows applications to all CAN buses physically connected to a PC. PCAN-Basic supports connecting several CAN channels simultaneously, from the same or different types of devices. The following list shows the PCAN Channels that can be connected per PCAN Device:

 | PCAN-ISA | PCAN-Dongle | PCAN-PCI | PCAN-USB | PCAN-PC Card | PCAN-LAN
Number of Channels | 8 | 1 | 16 | 16 | 2 | 16

Using the API:

The PCAN-Basic offers the possibility to use several PCAN-Channels within the same application easily. The communication process is divided in 3 phases: initialization/start, interaction/operation and finalization of a PCAN-Channel.

  • Initialization: To start doing CAN communication using a Channel, it is necessary to first initialize it. This is done making a call to the Initialize method, or to Initialize method in case FD communication is desired.

  • Interaction: After a successful initialization, a PCAN Channel is ready to communicate with the connected CAN bus. Further configuration is not needed. The Read and Write methods can be then used to read and write CAN messages. If desired, extra configuration can be made to improve a communication session, like changing the message filter to target specific messages.

  • Finalization: When the communication is finished, the Uninitialize should be called to release the PCAN Channel and the resources allocated for it. In this way the channel is marked as "free" and can be used from other applications.

Hardware and Drivers:

Overview of the current PCAN hardware and device drivers
Hardware | Is Plug-and-Play | Device Driver
PCAN-Dongle | NO | Pcan_dng.sys
PCAN-ISA | NO | Pcan_isa.sys
PCAN-PC/104 | NO | Pcan_isa.sys
PCAN-PCI | YES | Pcan_pci.sys
PCAN-PCI Express | YES | Pcan_pci.sys
PCAN-PCI Express FD | YES | Pcan_pci.sys
PCAN-cPCI | YES | Pcan_pci.sys
PCAN-miniPCI | YES | Pcan_pci.sys
PCAN-miniPCIe | YES | Pcan_pci.sys
PCAN-miniPCIe FD | YES | Pcan_pci.sys
PCAN-M.2 | YES | Pcan_pci.sys
PCAN-Chip PCIe FD | YES | Pcan_pci.sys
PCAN-PC/104-Plus | YES | Pcan_pci.sys
PCAN-PC/104-Plus Quad | YES | Pcan_pci.sys
PCAN-PC/104-Express | YES | Pcan_pci.sys
PCAN-PC/104-Express FD | YES | Pcan_pci.sys
PCAN-ExpressCard | YES | Pcan_pci.sys
PCAN-ExpressCard 34 | YES | Pcan_pci.sys
PCAN-Chip PCIe FD | YES | Pcan_pci.sys
PCAN-USB | YES | Pcan_usb.sys
PCAN-USB FD | YES | Pcan_usb.sys
PCAN-USB Pro | YES | Pcan_usb.sys
PCAN-USB Pro FD | YES | Pcan_usb.sys
PCAN-USB Hub | YES | Pcan_usb.sys
PCAN-USB X6 | YES | Pcan_usb.sys
PCAN-Chip USB | YES | Pcan_usb.sys
PCAN-PC Card | YES | Pcan_pcc.sys
PCAN-Ethernet Gateway DR | YES | Pcan_lan.sys
PCAN-Ethernet Gateway FD DR | YES | Pcan_lan.sys
PCAN-Wireless Gateway DR | YES | Pcan_lan.sys
PCAN-Wireless Gateway | YES | Pcan_lan.sys
PCAN-Wireless Automotive Gateway | YES | Pcan_lan.sys
Remarks

The Peak.Can.BasicApi class only supports plug-and-play devices. If it is desired to work with non plug-and-play devices, the class Peak.Can.Basic.BackwardCompatibilityPCANBasic is to be used.

See Also

Other Resources

Introduction


Using Events

Event objects can be used to notify an application on reception of a CAN message automatically. This has following advantages:

  • The application doesn't need to check periodically for received messages any longer.

  • The response time on received messages is reduced.

To use events, the application must call the SetValue method to set the PcanParameterReceiveEvent parameter. 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 application, to wait for the event to be signaled, using one of the Win32 synchronization functions (WaitForSingleObject) without increasing the processor load. After the event is signaled, the receive buffer of the Channel can be read with the Read method, and the CAN messages can be processed.

Remarks

Tips for the creation of the event object:

  • Creation of the event as "auto-reset":

    • Trigger mode "set" (default): After the first waiting thread has been released, the event object's state changes to non-signaled. Other waiting threads are not released. If no threads are waiting, the event object's state remains signaled.

    • Trigger mode "pulse": After the first waiting thread has been released, the event object's state changes to non-signaled. Other waiting threads are not released. If no threads are waiting, or if no thread can be released immediately, the event object's state is simply set to non-signaled.

  • Creation of the event as "manual-reset":

    • Trigger mode "set" (default): The state of the event object remains signaled until it is set explicitly to the non-signaled state by the Win32

      ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait operations, can be released while the object's state remains signaled.

    • Trigger mode "pulse": All waiting threads that can be released immediately are released. The event object's state is then reset to the non-signaled state. If no threads are waiting, or if no thread can be released immediately, the event object's state is simply set to non-signaled.

See Also

Reference

SetValue
Read

Other Resources

Introduction


How-To's and Q&A's

There are some new possibilities to write code for CAN communication when using PCAN-Basic.NET. The most asked questions are answered next.

  1. What is PCAN-Basic.NET?

  2. I have already a project using a PCAN-Basic header file. Do I have to re-write everything?

  3. Do I need to learn how to use a new API?

  4. Which benefits offers PCAN-Basic.NET in comparison to the header files?

  5. How do I get the PCAN-Basic.NET assembly?

  6. Are the native libraries delivered within the NuGet package?

  7. How do I install the assembly using Visual Studio?

  8. How do I install the assembly using dotnet-CLI (Visual Studio Code)?

  9. How can I use the assembly without changing old .NET code?

  10. How can I get notified on new received CAN messages?

  11. How can I send CAN messages periodically?

  12. Can I mix old and new PCAN-Basic code in a project?

  13. What can I use more than one queue for?

  14. How many reception queues are used in PCAN-Basic.NET?

  15. Does the filtering system of the "Worker" class have the same SJA1000 filter limitations?

  16. Does the class “Worker” restring the filter in the CAN controller when setting different filters?

What is PCAN-Basic.NET?

PCAN-Basic.NET is a .NET library compiled targeting the .NET Standard 2.0. It is the new way to access the native library PCAN-Basic from the managed Microsoft programming environment. Using PCAN-Basic header files (PCANBasic.cs/PCANBasic.vb/PCANBasicCLR.h) has been deprecated.

I have already a project using a PCAN-Basic header file. Do I have to re-write everything?

No. PCAN-Basic.NET has a Peak.Can.Basic.BackwardCompatibility namespace. Using this, the code remains unchanged. API Calls are internally redirected.

Do I need to learn how to use a new API?

Not really. PCAN-Basic.NET offers a similar API usage as with the old header files (PCANBasic.cs/PCANBasic.vb/PCANBasicCLR.h). This was though enhanced, i.e., calls were simplified, and new data types were created, making it use easier and more intuitive. The way to use and access the API is the same, i.e., using a static class, Api, for accessing the available API functionality.

Added to this traditional way to access and work with the PCAN-Basic library in the .NET environment, the PCAN-Basic.NET assembly offers also a new way to do CAN communication. Using the new Worker class, you can more easily read/write CAN messages from/to the CAN bus.

Which benefits offers PCAN-Basic.NET in comparison to the header files?

  • The Api class, the re-worked API-access class (replaces the PCANBasic class), is more comfortable to use.

    1. Using StringBuilder object for getting string parameters is not needed anymore.

    2. Passing buffer size on calls to GetValue/SetValue is not needed anymore.

    3. The new type DataBytes manages the data field for any CAN or CAN FD message. It is no more needed to initialize the Data field of a message after creating it.

    4. The Api class makes use of function overloading. Instead of having two sets of functions for CAN and CAN-FD, for instance Initialize and InitializeFD, you have only one function, Initialize that can be used for both purposes.

    5. New data types were created for API values that were defined as standard data types. This makes the code more readable and understandable. For example, there is a new ParameterValue class, that encapsulates valid values for PCAN-Basic parameters used with the GetValue/SetValue methods.

  • The assembly introduces a more comfortable way to do CAN communication using the new Worker class. Following features are supported:

    1. Automatic reading of CAN messages using event notification. An application can register to the MessageAvailable event to get notified on the reception of new CAN messages.

    2. Automatic writing of CAN message using a broadcast table, having an accuracy of up to one millisecond. Operations like having a "keep-alive" message can be easily done.

    3. A more exhaustive filtering system. Message filtering allows mixing different filter criteria like:

      • Single standard CAN ID.

      • Single extended CAN ID.

      • Standard CAN ID range.

      • Extended CAN ID range.

      • Standard mask and code.

      • Extended mask and code.

      • Filtering of CAN message type (RTR, Error Frame, Data, Status, etc.).

      • Each filter criterion can be configured to operate as "include" or "exclude" filter.

    4. Handling of several reception queues. An application can use a queue and its messages for dedicated/separated tasks.

    5. Filtering is implemented for a queue, not for the object, so that messages can be automatically sorted in different queues on reception time.

  • The assembly contains additional useful classes like the PerformanceTimer, useful for operations that require a fast reaction time (up to one millisecond accuracy).

  • The code becomes portable: since .NET Standard 2.0 is used, the same code can be used for .Net-Core, .NET Framework, and others.

  • The code becomes multi-platform: Since PCAN-Basic and .NET (C#) are available for Linux and Windows, applications written using the PCAN-Basic.NET assembly can compile and run on both systems.

How do I get the PCAN-Basic.NET assembly?

The assembly is delivered as a NuGet package (.nupkg). This file can be installed directly from NuGet.org (online installation). Additionally, it is also contained in the download package of the PCAN-Basic API (local installation).

Are the native libraries delivered within the NuGet package?

No. The underlying native library (“PCANBasic.dll” on Windows and “libpcanbasic.so” on Linux) must be present and reachable on the system in which the assembly is intended to be used.

How do I install the assembly using Visual Studio?

Please check the following page: Install and use a package in Visual Studio.

To look for packages locally, it is needed to configure a source for the NuGet Manager. For this, see the following page: Install and manage packages in Visual Studio using the NuGet Package Manager.

How do I install the assembly using dotnet-CLI (Visual Studio Code)?

Please check the following page: Install and use a package using the dotnet CLI.

To look for packages locally, it is needed to configure a source for the NuGet Manager. For this, see the following page: dotnet nuget add source

How can I use the assembly without changing old .NET code?

The PCAN-Basic.NET assembly contains a Peak.Can.Basic.BackwardCompatibility namespace for this case. just follow these steps to include and use the assembly in a .NET project that was written using a PCAN-Basic header file (PCANBasic.cs/PCANBasic.vb/PCANBasicCLR.h):

  1. Remove the PCAN-Basic header file from your project.

  2. Install the PCANBasic.NET NuGet package.

  3. Look for the using statement in your code “Peak.Can.Basic” and change it to be Peak.Can.Basic.BackwardCompatibility

How can I get notified on new received messages?

With the class Worker you can be notified on message reception. After creating an object of this type, you can register to its MessageAvailable event to get informed that a message was received. After connecting an object of type Worker, reading is started automatically, if this standard configuration was not changed. The event is fired within its own thread, so synchronization is needed when interacting with UI elements.

C#
VB
C++
Copy
// Create a "Worker" object
//
Worker myWorker = new Worker();

// Register for the event “MesasgeAvailable”. Configure this event
// handler to dequeue messages
//
myWorker.MessageAvailable += OnMessageAvailable;

// Activate the connection of the “Worker” object
myWorker.Start();

// Event handler
//
...
private static void OnMessageAvailable(object sender, MessageAvailableEventArgs e)
{
    PcanMessage msg;
    ulong timestamp;
    while (myWorker.Dequeue(out msg, out timestamp))
    ProcessYourMessage(msg, timestamp);
}
...
' Create a "Worker" object using the "WithEvents" modifier
'
Dim WithEvents myWorker As Worker = New Worker()

' Register for the event “MesasgeAvailable”. Configure this event
' handler to dequeue messages
'
...
Private Sub HandlerMessages() Handles myWorker.MessageAvailable
Dim msg As PcanMessage
Dim timestamp As ULong

While (myWorker.Dequeue(msg, timestamp))
ProcessYourMessage(msg, timestamp)
End While
End Sub
...

' Activate the connection of the “Worker” object
'
myWorker.Start()
// Create a "Worker" object
//
Worker^ myWorker = gcnew Worker();

// Register for the event “MesasgeAvailable”.Configure this event
// handler to dequeue messages
//
myWorker->MessageAvailable += gcnew System::EventHandler<MessageAvailableEventArgs^>(&OnMessageAvailable);

// Activate the connection of the “Worker” object
//
myWorker->Start(false, false, false);

// Event handler
...
void OnMessageAvailable(System::Object^ sender, Peak::Can::Basic::MessageAvailableEventArgs^ e)
{
    PcanMessage^ msg;
    UInt64 timestamp;

    while (myWorker->Dequeue(msg, timestamp))
        ProcessYourMessage(msg, timestamp);
}
...
How can I send messages periodically?

With the class Worker it is possible to configure up to MaximumBroadcastCount broadcast messages. After creating a Worker object, you can use its method “AddBroadcast” to configure the automatic sending of messages. After connecting the object, broadcasting is started automatically, if this standard configuration was not changed.

C#
VB
C++
Copy
// Create a "Worker" object
//
Worker myWorker = new Worker();

// Create a message to broadcast
//
PcanMessage msg = new PcanMessage()
{
    ID = 1,
    DLC = 8,
    MsgType = MessageType.Standard,
    Data = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 }
};

// Configure a broadcast (message and send-interval) within the “Worker” object
//
myWorker.AddBroadcast(msg, 250);

// Activate the connection of the “Worker” object
//
myWorker.Start();
' Create a "Worker" object
'
Dim myWorker As Worker = New Worker()

' Create a message to broadcast
'
Dim msg As PcanMessage = New PcanMessage() With
{
    .ID = 1,
    .DLC = 8,
    .MsgType = MessageType.Standard,
    .Data = New Byte() {8, 7, 6, 5, 4, 3, 2, 1}
}

' Configure a broadcast (message and send-interval) within the “Worker” object
'
myWorker.AddBroadcast(msg, 250)

' Activate the connection of the “Worker” object
'
myWorker.Start()
// Create a "Worker" object
//
Worker^ myWorker = gcnew Worker();

// Create a message to broadcast
//
PcanMessage^ msg = gcnew PcanMessage(
    1,
    MessageType::Standard,
    8,
    gcnew array<Byte>{ 8, 7, 6, 5, 4, 3, 2, 1}
);

// Configure a broadcast (message and send-interval) within the “Worker” object
//
myWorker->AddBroadcast(msg, 250);

// Activate the connection of the “Worker” object
//
myWorker->Start(false, false, false);
Can I mix old and new PCAN-Basic in a project?

Yes, it is possible. Note that old code needs the Peak.Can.Basic.BackwardCompatibility namespace to work. To use the new PCAN-Basic features you need the Peak.Can.Basic namespace. To use other utility classes, please use the Peak.Classes.* namespace.

What can I use more than one queue for?

The Worker class reads the underlying, native, reception queue actively. Each message received is passed then to each of the queues managed by this class. Since each queue has its own filter, messages can be sorted out at reception time, for example, you can have one queue for standard messages only, and another for extended messages.

How many reception queues are used in PCAN-Basic.NET?

Using the standard interface, the Api class, there is only one reception queue, the one created by the native library, which is also filtered using the old mechanism (SJA1000 filter). When using an object of type Worker on the other hand, there are so many message queues available as stated by the ReceiveQueuesCount field of the Worker class.

Per default only the first queue has a filter configured to pass all messages. The others are configured to discard all messages. Methods for accessing the receive queues are overloaded to assume index 0, when only one queue is used, or to accept the index associated to it as parameter.

Does the filtering system of the "Worker" class have the same SJA1000 filter limitations?

No. The queues of the Worker class implement a software filter on top, this is, messages being received by the underlying PCAN-Basic API are passed and checked for the filters of each receive queue. This allows for instance configuring standard and extended filters together, which is not possible using the native API. Received messages that do not match any filter of the active queues are just discarded.

Does the class “Worker” restring the filter in the CAN controller when setting different filters?

No. The native filter is configured to pass all messages. The actual filtering is done within the reception queues of the Worker class.


License Regulations

The use of this software is subject to the terms of the End User License Agreement of PEAK-System Technik GmbH.

Product names 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.

Copyright © 2000-2022 PEAK-System Technik GmbH

All rights reserved.

No part of this publication may be reproduced, photocopied, stored on a retrieval system, or transmitted without the express written consent of PEAK-System Technik GmbH.

See Also

Other Resources

Contact Information


Contact Information

This software is a product of:

PEAK-System Technik GmbH
Darmstadt, Germany

Info: | info@peak-system.com
Support: | support@peak-system.com
Web: | www.peak-system.com
See Also

Other Resources

Introduction


Reference

Namespaces
Namespace | Description
Peak.Can | The namespace group Peak.Can contains different classes and other data types for loading and using the native PCANBasic.dll library in .NET based projects.
Peak.Classes.Time | The namespace Peak.Classes.Time contains different classes and data types intended for handling time related operations.


Peak.Can Namespaces

The namespace group Peak.Can contains different classes and other data types for loading and using the native PCANBasic.dll library in .NET based projects.
Namespaces
Namespace | Description
Peak.Can.Basic | The namespace Peak.Can.Basic contains different data types that grant access to the PCAN-Basic library to do CAN communication using plug and play devices from PEAK-System.
Peak.Can.Basic.BackwardCompatibility | The namespace Peak.Can.Basic.BackwardCompatibility grants access to the PCAN-Basic library over an interface as defined within the header files PCANBasic.cs / PCANBasic.vb / PCANBasicCLR.h (C++ / CLI). This namespace is intended to be used only with already existing projects, that have been written using those header files, as a way to keep old code working without the need of rewriting it. For new development projects the namespace Peak.Can.Basic should be used instead.


Peak.Can.Basic Namespace

The namespace Peak.Can.Basic contains different data types that grant access to the PCAN-Basic library to do CAN communication using plug and play devices from PEAK-System.
Classes
 | Class | Description
Public class | Api | PCAN-Basic API class implementation.
Public class | BitrateFD | Defines the different configuration parameters used to create a Flexible Data rate string for FD capable PCAN Channels initialization.
Public class | Broadcast | Represents a CAN message that is written periodically.
Public class | DataBytes | Represents an object that manages the Data field for any CAN or CAN FD message.
Public class | MessageAvailableEventArgs | Represents the arguments for a MessageAvailable event.
Public class | ParameterValue | Represents the allowed values for PCAN-Basic parameters configuration.
Public class | ParameterValueActivation | Represents values applicable to parameters, that can be activated or deactivated.
Public class | ParameterValueFilter | Represents values applicable to filter parameters.
Public class | ParameterValueLog | Represents values applicable to parameters related to data logging.
Public class | ParameterValueLookUp | Represents values applicable to parameters related to the LookUpChannel method.
Public class | ParameterValueTrace | Represents values applicable to parameters related to CAN data tracing.
Public class | PcanBasicException | Represents an exception thrown when a call to a Api functions fails in an unexpected manner.
Public class | PcanChannelInformation | Represents information about a PCAN Channel.
Public class | PcanMessage | Represents a PCAN message from a CAN or CAN FD capable hardware.
Public class | Worker | PCAN Worker class implementation. Worker makes use of the Api class to allows reading and writing from and to a PCAN Channel in an automatic way, using timers and events. It allows a more accurate filtering system that the native one, and the use of multiple receive queues with separate filter configuration. If direct access to the PCAN-Basic interface is desired, use the Api class instead.
Structures
 | Structure | Description
Public structure | BitrateFDBitrateSegment | Represents single bit rate parameters.
Public structure | FilteringCriterion | Represents a criterion for filtering CAN messages.
Enumerations
 | Enumeration | Description
Public enumeration | Bitrate | Represents a PCAN bit rate register value.
Public enumeration | BitrateFDBitrateType | The bit rate representation.
Public enumeration | BitrateFDClockFrequency | Represents the supported bit rate clock frequencies.
Public enumeration | ChannelCondition | Represents the connectivity condition of a PCAN Channel.
Public enumeration | FilterBehavior | The operation that take place when a filtering criterion has a match.
Public enumeration | FilterData | The kind of information used for filtering messages.
Public enumeration | FilteringState | State of verification of a message filter.
Public enumeration | FilterMode | Represents a PCAN filter mode.
Public enumeration | LanDirection | Represents the direction of the communication being currently carried out by a PCAN-LAN device.
Public enumeration | MessageType | Represents the type of a CAN message.
Public enumeration | OutputLanguage | Represents the available translation languages for error codes.
Public enumeration | PcanChannel | Represents the different PCAN buses (PCAN Channels) available to use within the API when a PCAN Handle is required.
Public enumeration | PcanDevice | Represents the type of interface and driver a device uses.
Public enumeration | PcanDeviceFeatures | Represents the features implemented by a PCAN device.
Public enumeration | PcanParameter | Represents a PCAN parameter or a PCAN Value that can be read or set.
Public enumeration | PcanStatus | Represents a PCAN status/error code.
Public enumeration | Protocol | Represents the transport protocol used for Data transmission.
Public enumeration | ServiceStatus | Represents the status of the Virtual PCAN-Gateway service.


Api Class

PCAN-Basic API class implementation.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicApi

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static class Api
Public NotInheritable Class Api
public ref class Api abstract sealed

The Api type exposes the following members.

Methods
Name | Description
FilterMessages | Configures the acceptance filter for CAN messages within a PCAN Channel.
GetAttachedChannels | Retrieves information about the PCAN Channels attached to the system.
GetErrorText(PcanStatus, String) | Returns a descriptive text of a given error code, using the operating system language, or English, if it is not supported.
GetErrorText(PcanStatus, String, OutputLanguage) | Returns a descriptive text of a given error code, using a custom output language.
GetHandleInformation | Retrieves information about device type and channel number from a PCAN Handle
GetStatus | Retrieves the current status of the CAN controller of the hardware represented by a PCAN Channel.
GetValue(PcanChannel, PcanParameter, PcanChannelInformation) | Retrieves an array of PcanChannelInformation with information about the hardware currently attached to the system.
GetValue(PcanChannel, PcanParameter, String) | Retrieves a string parameter value from a PCAN Channel.
GetValue(PcanChannel, PcanParameter, UInt32) | Retrieves a 32-bit numeric parameter value from a PCAN Channel.
GetValue(PcanChannel, PcanParameter, UInt64) | Retrieves a 64-bit numeric parameter value from a PCAN Channel.
Initialize(PcanChannel, Bitrate) | Initializes a PCAN Channel for classic CAN communication.
Initialize(PcanChannel, BitrateFD) | Initializes a PCAN Channel for CAN communication supporting flexible data rate.
LookUpChannel | Finds the handle of a PCAN Channel that matches the given parameters.
Read(PcanChannel, PcanMessage) | Reads a CAN message from the receive queue of a PCAN Channel.
Read(PcanChannel, PcanMessage, UInt64) | Reads a CAN message and its timestamp from the receive queue of a PCAN Channel.
Reset | Discards all messages contained in the receive and transmit queues of a PCAN Channel.
SetValue(PcanChannel, PcanParameter, String) | Configures a string parameter value of a PCAN Channel.
SetValue(PcanChannel, PcanParameter, UInt32) | Configures a 32-bit numeric parameter value of a PCAN Channel.
SetValue(PcanChannel, PcanParameter, UInt64) | Configures a 64-bit numeric parameter value of a PCAN Channel.
Uninitialize | Uninitializes one or all PCAN Channels initialized by the methods Initialize and Initialize.
Write | Places a CAN message in the transmit queue of a PCAN Channel.
Top
Remarks
This class allows access to the underlying PCAN-Basic API.
See Also

Reference

Peak.Can.Basic Namespace


Api Methods

The Api type exposes the following members.

Methods
Name | Description
FilterMessages | Configures the acceptance filter for CAN messages within a PCAN Channel.
GetAttachedChannels | Retrieves information about the PCAN Channels attached to the system.
GetErrorText(PcanStatus, String) | Returns a descriptive text of a given error code, using the operating system language, or English, if it is not supported.
GetErrorText(PcanStatus, String, OutputLanguage) | Returns a descriptive text of a given error code, using a custom output language.
GetHandleInformation | Retrieves information about device type and channel number from a PCAN Handle
GetStatus | Retrieves the current status of the CAN controller of the hardware represented by a PCAN Channel.
GetValue(PcanChannel, PcanParameter, PcanChannelInformation) | Retrieves an array of PcanChannelInformation with information about the hardware currently attached to the system.
GetValue(PcanChannel, PcanParameter, String) | Retrieves a string parameter value from a PCAN Channel.
GetValue(PcanChannel, PcanParameter, UInt32) | Retrieves a 32-bit numeric parameter value from a PCAN Channel.
GetValue(PcanChannel, PcanParameter, UInt64) | Retrieves a 64-bit numeric parameter value from a PCAN Channel.
Initialize(PcanChannel, Bitrate) | Initializes a PCAN Channel for classic CAN communication.
Initialize(PcanChannel, BitrateFD) | Initializes a PCAN Channel for CAN communication supporting flexible data rate.
LookUpChannel | Finds the handle of a PCAN Channel that matches the given parameters.
Read(PcanChannel, PcanMessage) | Reads a CAN message from the receive queue of a PCAN Channel.
Read(PcanChannel, PcanMessage, UInt64) | Reads a CAN message and its timestamp from the receive queue of a PCAN Channel.
Reset | Discards all messages contained in the receive and transmit queues of a PCAN Channel.
SetValue(PcanChannel, PcanParameter, String) | Configures a string parameter value of a PCAN Channel.
SetValue(PcanChannel, PcanParameter, UInt32) | Configures a 32-bit numeric parameter value of a PCAN Channel.
SetValue(PcanChannel, PcanParameter, UInt64) | Configures a 64-bit numeric parameter value of a PCAN Channel.
Uninitialize | Uninitializes one or all PCAN Channels initialized by the methods Initialize and Initialize.
Write | Places a CAN message in the transmit queue of a PCAN Channel.
Top
See Also

Reference

Api Class
Peak.Can.Basic Namespace


Api.FilterMessages Method

PCAN-Basic.NET Library Documentation

ApiFilterMessages Method

Configures the acceptance filter for CAN messages within a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus FilterMessages(
    PcanChannel channel,
    uint fromID,
    uint toID,
    FilterMode mode
)
Public Shared Function FilterMessages (
    channel As PcanChannel,
    fromID As UInteger,
    toID As UInteger,
    mode As FilterMode
) As PcanStatus
public:
static PcanStatus FilterMessages(
    PcanChannel channel,
    unsigned int fromID,
    unsigned int toID,
    FilterMode mode
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
fromID UInt32
The lower range value to accept and place messages in the receive queue.

The lowest value allowed is 0.The highest value allowed is 0x7FF if mode equals to Standard, and 0x1FFFFFFF if mode equals to Extended.

toID UInt32
The upper range value to accept and place messages in the receive queue.

The lowest value allowed is 0. The highest value allowed is 0x7FF if mode equals to Standard, and 0x1FFFFFFF if mode equals to Extended.

mode FilterMode
The kind of filter to be set. This parameter restricts the range of values valid for fromID and toID.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks
Important note Important
After a PCAN Channel is initialized, its filter is fully opened, causing any message received by the hardware to be placed in the receive queue of the Channel.

Based on the current state of the filter, calling this method results in the following behavior:

  • Status was Open: The filter is automatically closed and then configured with the given range of IDs passed to FilterMessages [fromID, toID].
  • Status was Close: The filter is set to the given range of IDs passed to FilterMessages [fromID, toID].
  • Status was 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 FilterMessages again. To do this, use the method SetValue.

The 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 into account that configuring the message filter causes the CAN controller to enter the reset state. This will affect other applications that communicate with the same PCAN hardware.

Important note Important
  1. There is only one filter for standard and extended CAN messages. The ID from a standard message uses the most significant 11 bits (bit 18 to 28) of the 29 bits filter. 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.
Example

The following example shows the use of the FilterMessages method using the USB interface (first PCAN-USB hardware). A Channel is initialized and its filter is configured to get only messages with ID 2,3,4 or 5.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

    // The message filter is fully open after initialization.
    // Configuring a custom acceptance range automatically closes the filter first.
    //  The messages with ID in the range [2,5] is configured.
    //
    result = Api.FilterMessages(channel, 2, 5, FilterMode.Standard);
    if (result != PcanStatus.OK)
    {
        // An error occurred, get a text describing the error and show it
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine("The message filter was successfully configured for IDs 2,3,4 and 5.");

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
Dim channel As PcanChannel = PcanChannel.Usb01
' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
'
Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)

' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then

    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message on connection is shown.
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

    ' The message filter Is fully open after initialization.
    ' Configuring a custom acceptance range automatically closes the filter first.
    '  The messages with ID in the range [2,5] Is configured.
    '
    result = Api.FilterMessages(channel, 2, 5, FilterMode.Standard)
    If result <> PcanStatus.OK Then
        ' An error occurred, get a text describing the error And show it
        '
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine("The message filter was successfully configured for IDs 2,3,4 and 5.")
    End If

    ' The connection to the hardware is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
PcanChannel channel = PcanChannel::Usb01;
String^ errorText;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

    // The message filter is fully open after initialization.
    // Configuring a custom acceptance range automatically closes the filter first.
    //  The messages with ID in the range [2,5] is configured.
    //
    result = Api::FilterMessages(channel, 2, 5, FilterMode::Standard);
    if (result != PcanStatus::OK)
    {
        // An error occurred, get a text describing the error and show it
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The message filter was successfully configured for IDs 2,3,4 and 5.");

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api::Uninitialize(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
}
See Also

Reference

Api Class
Peak.Can.Basic Namespace
Initialize
Initialize
GetValue(PcanChannel, PcanParameter, UInt32)

Other Resources

Philips Data Sheet "SJA1000 Stand-alone CAN-controller


Api.GetAttachedChannels Method

ApiGetAttachedChannels Method

Retrieves information about the PCAN Channels attached to the system.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetAttachedChannels(
    out PcanChannelInformation[] buffer
)
Public Shared Function GetAttachedChannels (
    <OutAttribute> ByRef buffer As PcanChannelInformation()
) As PcanStatus
public:
static PcanStatus GetAttachedChannels(
    [OutAttribute] array<PcanChannelInformation^>^% buffer
)

Parameters

buffer PcanChannelInformation
An array of PcanChannelInformation to return information about the PCAN Channels found.

Return Value

PcanStatus

The return value is a PcanStatus value. OK is returned on success.

Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
Remarks

The method GetAttachedChannels is an aid that internally calls the method GetValue to get the amount of attached PCAN Channels and their description as an array of PcanChannelInformation objects.

The involved PCAN parameters are AttachedChannelsCount and AttachedChannelsInformation.

Example

The following example shows the use of the GetAttachedChannels method to retrieve and show the name, PCAN Channel handle, and features of all current attached PCAN devices.

C#
VB
C++
Copy
// A list with all registered channels is retrieved
//
PcanStatus result = Api.GetAttachedChannels(out var channels);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // The information about the registered hardware is shown
    //
    if (channels.Length == 0)
        Console.WriteLine("There are currently no PCAN devices attached to the system...");
    else
        foreach (PcanChannelInformation channelInfo in channels)
            Console.WriteLine($"{channelInfo.DeviceName} (0x{channelInfo.ChannelHandle:X}): {channelInfo.DeviceFeatures}");
}
Dim result As PcanStatus
Dim channels As PcanChannelInformation() = Nothing

' A list with all registered channels Is retrieved
'
result = Api.GetAttachedChannels(channels)
If (result <> PcanStatus.OK) Then
    ' An error occurred
    '
    Dim errorText As String = String.Empty
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' The information about the registered hardware is shown
    '
    If (channels.Length = 0) Then
        Console.WriteLine("There are currently no PCAN devices attached to the system...")
    Else
        For Each channelInfo As PcanChannelInformation In channels
            Console.WriteLine($"{channelInfo.DeviceName} (0x{channelInfo.ChannelHandle:X}): {channelInfo.DeviceFeatures}")
        Next
    End If
End If
String^ errorText;
PcanStatus result;
array<PcanChannelInformation^>^ channels;

// A list with all registered channels is retrieved
//
result = Api::GetAttachedChannels(channels);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // The information about the registered hardware is shown
    //
    if (channels->Length == 0)
        Console::WriteLine("There are currently no PCAN devices attached to the system...");
    else
        for each (PcanChannelInformation^ channelInfo in channels)
        {
            Console::WriteLine("{0} (0x{1:X}): {2}", channelInfo->DeviceName, channelInfo->ChannelHandle, channelInfo->DeviceFeatures);
        }
}
See Also

Reference

Api Class
Peak.Can.Basic Namespace


Api.GetErrorText Method

ApiGetErrorText Method

Overload List
Name | Description
GetErrorText(PcanStatus, String) | Returns a descriptive text of a given error code, using the operating system language, or English, if it is not supported.
GetErrorText(PcanStatus, String, OutputLanguage) | Returns a descriptive text of a given error code, using a custom output language.
Top
See Also

Reference

Api Class
Peak.Can.Basic Namespace


Api.GetErrorText(PcanStatus, String) Method

ApiGetErrorText(PcanStatus, String) Method

Returns a descriptive text of a given error code, using the operating system language, or English, if it is not supported.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetErrorText(
    PcanStatus errorCode,
    out string errorText
)
Public Shared Function GetErrorText (
    errorCode As PcanStatus,
    <OutAttribute> ByRef errorText As String
) As PcanStatus
public:
static PcanStatus GetErrorText(
    PcanStatus errorCode,
    [OutAttribute] String^% errorText
)

Parameters

errorCode PcanStatus
The error code which description text is to be retrieved.
errorText String

Contains the description text of the given errorCode.

The content of errorText is only valid if the returned value of this method is OK.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • InvalidValue: Indicates that one or more of the values passed to the method are invalid. Possible causes are:
    • The given errorCode is not defined.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

The "Primary language IDs" are codes used by Windows OS from Microsoft, to identify a human language. Currently, following languages are supported:

Language | Primary Language ID
Neutral (System dependent) | 00h (0)
English | 09h (9)
German | 07h (7)
French | 0Ch (12)
Italian | 10h (16)
Spanish | 0Ah (10)
Example

The following example shows the use of the GetErrorText(PcanStatus, String) method. The description of all available error codes are requested.

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.

C#
VB
C++
Copy
PcanStatus result;
string errorText = String.Empty;

foreach (PcanStatus errorCode in Enum.GetValues(typeof(PcanStatus)))
{
    result = Api.GetErrorText(errorCode, out errorText);
    if(result != PcanStatus.OK)
    {
        // An error occurred
        //
        Console.WriteLine($"  [{((uint)errorCode):X8}] {errorCode}: Error while retrieving --> {result}");
    }
    else
    {
        Console.WriteLine($"  [{((uint)errorCode):X8}] {errorCode}: {errorText}");
    }
}
Dim result As PcanStatus
Dim errorText As String = String.Empty

For Each errorCode As PcanStatus In [Enum].GetValues(GetType(PcanStatus))
    result = Api.GetErrorText(errorCode, errorText)
    If result <> PcanStatus.OK Then
        ' An error occurred
        '
        Console.WriteLine($"  [{CUInt(errorCode):X8}] {errorCode}: Error while retrieving --> {result}")
    Else
        Console.WriteLine($"  [{CUInt(errorCode):X8}] {errorCode}: {errorText}")
    End If
Next
PcanStatus result;
String^ errorText = String::Empty;

for each (PcanStatus errorCode in Enum::GetValues(PcanStatus::typeid))
{
    result = Api::GetErrorText(errorCode, errorText);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Console::WriteLine("  [{0:X8}] {1}: Error while retrieving --> {2}", (UInt32)errorCode, errorCode, result);
    }
    else
    {
        Console::WriteLine("  [{0:X8}] {1}: {2}", (UInt32)errorCode, errorCode, errorText);
    }
}
See Also

Reference

Api Class
GetErrorText Overload
Peak.Can.Basic Namespace
Error codes


Api.GetErrorText(PcanStatus, String, OutputLanguage) Method

ApiGetErrorText(PcanStatus, String, OutputLanguage) Method

Returns a descriptive text of a given error code, using a custom output language.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetErrorText(
    PcanStatus errorCode,
    out string errorText,
    OutputLanguage language
)
Public Shared Function GetErrorText (
    errorCode As PcanStatus,
    <OutAttribute> ByRef errorText As String,
    language As OutputLanguage
) As PcanStatus
public:
static PcanStatus GetErrorText(
    PcanStatus errorCode,
    [OutAttribute] String^% errorText,
    OutputLanguage language
)

Parameters

errorCode PcanStatus
The error code which description text is to be retrieved.
errorText String

Contains the description text of the given errorCode.

The content of errorText is only valid if the returned value of this method is OK.

language OutputLanguage
The language used for the description text.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • InvalidValue: Indicates that one or more of the values passed to the method are invalid. Possible causes are:
    • The given errorCode is not defined.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

The "Primary language IDs" are codes used by Windows OS from Microsoft, to identify a human language. Currently, following languages are supported:

Language | Primary Language ID
Neutral (System dependent) | 00h (0)
English | 09h (9)
German | 07h (7)
French | 0Ch (12)
Italian | 10h (16)
Spanish | 0Ah (10)
Example

The following example shows the use of the GetErrorText(PcanStatus, String) method. The description of all available error codes are requested using Spanish as output language.

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.

C#
VB
C++
Copy
PcanStatus result;
string errorText = String.Empty;

foreach (PcanStatus errorCode in Enum.GetValues(typeof(PcanStatus)))
{
    result = Api.GetErrorText(errorCode, out errorText, OutputLanguage.Spanish);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Console.WriteLine($"  [{((uint)errorCode):X8}] {errorCode}: Error while retrieving --> {result}");
    }
    else
    {
        Console.WriteLine($"  [{((uint)errorCode):X8}] {errorCode}: {errorText}");
    }
}
Dim result As PcanStatus
Dim errorText As String = String.Empty

For Each errorCode As PcanStatus In [Enum].GetValues(GetType(PcanStatus))
    result = Api.GetErrorText(errorCode, errorText, OutputLanguage.Spanish)
    If result <> PcanStatus.OK Then
        ' An error occurred
        '
        Console.WriteLine($"  [{CUInt(errorCode):X8}] {errorCode}: Error while retrieving --> {result}")
    Else
        Console.WriteLine($"  [{CUInt(errorCode):X8}] {errorCode}: {errorText}")
    End If
Next
PcanStatus result;
String^ errorText = String::Empty;

for each(PcanStatus errorCode in Enum::GetValues(PcanStatus::typeid))
{
    result = Api::GetErrorText(errorCode, errorText, OutputLanguage::Spanish);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Console::WriteLine("  [{0:X8}] {1}: Error while retrieving --> {2}", (UInt32)errorCode, errorCode, result);
    }
    else
    {
        Console::WriteLine("  [{0:X8}] {1}: {2}", (UInt32)errorCode, errorCode, errorText);
    }
}
See Also

Reference

Api Class
GetErrorText Overload
Peak.Can.Basic Namespace
Error codes


Api.GetHandleInformation Method

ApiGetHandleInformation Method

Retrieves information about device type and channel number from a PCAN Handle

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetHandleInformation(
    PcanChannel handle,
    out PcanDevice device,
    out int channel
)
Public Shared Function GetHandleInformation (
    handle As PcanChannel,
    <OutAttribute> ByRef device As PcanDevice,
    <OutAttribute> ByRef channel As Integer
) As PcanStatus
public:
static PcanStatus GetHandleInformation(
    PcanChannel handle,
    [OutAttribute] PcanDevice% device,
    [OutAttribute] int% channel
)

Parameters

handle PcanChannel
The handle of a PCAN Channel
device PcanDevice
Output variable to store the device type
channel Int32
Output variable to store the channel number

Return Value

PcanStatus

The return value is a PcanStatus value. OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the given handle is invalid.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
Example

The following example shows the use of the GetHandleInformation method to retrieve the PCAN device name and channel number associated to the given channel.

C#
VB
C++
Copy
// The information about the handle is retrieved
//
PcanStatus result = Api.GetHandleInformation(PcanChannel.Lan07, out var device, out var channelNumber);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // The information about the handle is shown
    //
    Console.WriteLine($"The given {nameof(PcanChannel)} represents the {device} hardware number {channelNumber}.");
}
Dim result As PcanStatus
Dim device As PcanDevice
Dim channelNumber As Integer

' The information about the handle is retrieved
'
result = Api.GetHandleInformation(PcanChannel.Lan07, device, channelNumber)
If (result <> PcanStatus.OK) Then
    ' An error occurred
    '
    Dim errorText As String = String.Empty
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' The information about the handle is shown
    '
    Console.WriteLine($"The given {NameOf(PcanChannel)} represents the {device} hardware number {channelNumber}.")
End If
String^ errorText;
PcanDevice device;
int channelNumber;

// The information about the handle is retrieved
//
PcanStatus result = Api::GetHandleInformation(PcanChannel::Lan07, device, channelNumber);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // The information about the handle is shown
    //
    Console::WriteLine("The given PcanChannel represents the {0} hardware number {1}", device, channelNumber);
}
See Also

Reference

Api Class
Peak.Can.Basic Namespace


Api.GetStatus Method

ApiGetStatus Method

Retrieves the current status of the CAN controller of the hardware represented by a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetStatus(
    PcanChannel channel
)
Public Shared Function GetStatus (
    channel As PcanChannel
) As PcanStatus
public:
static PcanStatus GetStatus(
    PcanChannel channel
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.

Return Value

PcanStatus

OK is returned if the CAN controller of the hardware represented by the given PCAN Channel is in a normal state. The typical errors in case of failure are:

  • Initialize: Indicates that the channel cannot be terminated because it was not found in the list of reserved Channels of the calling application.
  • IllegalHardwareHandle: Indicates that the hardware represented by channel was removed or deactivated.
  • IllegalHandle: Indicates that the channel contains an invalid value.
  • BusHeavyIndicates a bus error within the CAN controller of the hardware represented by the given PCAN Channel. An error counter reached the 'heavy' limit.
  • BusLightIndicates a bus error within the CAN controller of the hardware represented by the given PCAN Channel. An error counter reached the 'light' limit.
  • BusPassiveIndicates a bus error within the CAN controller of the hardware represented by the given PCAN Channel. The CAN controller is in error passive state.
  • BusWarningIndicates a bus error within the CAN controller of the hardware represented by the given PCAN Channel. An error counter reached the 'warning' limit.
  • BusOffIndicates a bus error within the CAN controller of the hardware represented by the given PCAN Channel. The CAN controller is in bus-off state.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

When the hardware status is bus-off, an application cannot communicate anymore. Consider using the BusOffAutoReset parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset bus errors like BusOff, BusPassive, and others:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter HardResetStatus: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

Example

The following example shows the use of the GetStatus method using the USB interface (first PCAN-USB hardware). A Channel is initialized and used to send 255 messages in about 4 seconds. After each sending the status of the CAN controller is checked.

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.

  1. C#
    VB
    C++
    Copy
    private static void GetStatusExample()
{
    PcanChannel channel = PcanChannel.Usb01;

    // The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    //
    PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        // A success message on connection is shown.
        //
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

        // Start a thread for a writing messages and wait until it is finished
        //
        var worker = new System.Threading.Thread(DoWriteProcess);
        worker.Start(channel);
        worker.Join();

        // The connection to the hardware is finalized when it is no longer needed
        //
        result = Api.Uninitialize(channel);
        if (result != PcanStatus.OK)
        {
            // An error occurred
            //
            Api.GetErrorText(result, out var errorText);
            Console.WriteLine(errorText);
        }
        else
            Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
    }

}

private static void DoWriteProcess(object channelToUse)
{
    // Channel to use for message reading
    //
    PcanChannel channel = (PcanChannel)channelToUse;
    PcanStatus result;

    // Message to be send
    PcanMessage toSend = new PcanMessage(0x100, MessageType.Standard, 1, new byte[1]);

    // 255 messages are send, using the first data byte as a message counter
    //
    for (byte i=0; i < byte.MaxValue; i++)
    {
        // Send the message
        //
        toSend.Data[0] = (byte)(i + 1);
        result = Api.Write(channel, toSend);

        // Check for any unexpected error
        //
        if ((result == PcanStatus.Initialize) || (result == PcanStatus.IllegalHandle)
            || (result == PcanStatus.InvalidOperation) || (result == PcanStatus.InvalidValue))
        {
            // An unexpected error occurred
            //
            Api.GetErrorText(result, out var errorText);
            Console.WriteLine(errorText);
            break;
        }

        // The status of the Channel is checked and outputted
        //
        result = Api.GetStatus(channel);
        switch (result)
        {
            case PcanStatus.BusLight:
                Console.WriteLine($"An error counter of the Channel {channel} has reached the bus-light limit by sending the message number {i + 1}.");
                break;
            case PcanStatus.BusHeavy:
                Console.WriteLine($"An error counter of the Channel {channel} has reached the bus-heavy limit by sending the message number {i + 1}.");
                break;
            case PcanStatus.BusOff:
                Console.WriteLine($"An error counter of the Channel {channel} has reached the bus-off state by sending the message number {i + 1}.");
                break;
            case PcanStatus.OK:
                Console.WriteLine($"Status of Channel {channel} after sending message {i + 1} is 'OK'.");
                break;
            default:
                // An unexpected error occurred
                //
                Api.GetErrorText(result, out var errorText);
                Console.WriteLine(errorText);
                break;
        }

        // Wait some milliseconds to slow down things
        //
        System.Threading.Thread.Sleep(15);
    }
}
    Public Sub GetStatusExample()
    Dim channel As PcanChannel = PcanChannel.Usb01

    ' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    '
    Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)

    If result <> PcanStatus.OK Then
        ' An error occurred
        '
        Dim errorText = Nothing
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        ' A success message on connection is shown.
        '
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

        ' Start a thread for a writing messages and wait until it is finished
        '
        Dim worker = New System.Threading.Thread(New System.Threading.ParameterizedThreadStart(AddressOf DoWriteProcess))
        worker.Start(channel)
        worker.Join()

        ' The connection to the hardware is finalized when it is no longer needed
        '
        result = Api.Uninitialize(channel)

        If result <> PcanStatus.OK Then
            ' An error occurred
            '
            Dim errorText = Nothing
            Api.GetErrorText(result, errorText)
            Console.WriteLine(errorText)
        Else
            Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
        End If
    End If
End Sub

Private Sub DoWriteProcess(channelToUse As Object)
    Dim channel As PcanChannel = CType(channelToUse, PcanChannel)
    Dim result As PcanStatus
    Dim errorText = Nothing

    ' Channel to use for message reading
    '
    Dim toSend As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 1, New Byte(0) {})

    ' 255 messages are send, using the first data byte as a message counter
    '
    For i As Byte = 0 To Byte.MaxValue - 1
        ' Send the message
        '
        toSend.Data(0) = CByte((i + 1))
        result = Api.Write(channel, toSend)

        ' Check for any unexpected error
        '
        If (result = PcanStatus.Initialize) OrElse (result = PcanStatus.IllegalHandle) OrElse
            (result = PcanStatus.InvalidOperation) OrElse (result = PcanStatus.InvalidValue) Then
            ' An unexpected error occurred
            '
            Api.GetErrorText(result, errorText)
            Console.WriteLine(errorText)
            Exit For
        End If

        ' The status of the Channel is checked and outputted
        '
        result = Api.GetStatus(channel)

        Select Case result
            Case PcanStatus.BusLight
                Console.WriteLine($"An error counter of the Channel {channel} has reached the bus-light limit by sending the message number {i + 1}.")
            Case PcanStatus.BusHeavy
                Console.WriteLine($"An error counter of the Channel {channel} has reached the bus-heavy limit by sending the message number {i + 1}.")
            Case PcanStatus.BusOff
                Console.WriteLine($"An error counter of the Channel {channel} has reached the bus-off state by sending the message number {i + 1}.")
            Case PcanStatus.OK
                Console.WriteLine($"Status of Channel {channel} after sending message {i + 1} is 'OK'.")
            Case Else
                ' An unexpected error occurred
                '
                Api.GetErrorText(result, errorText)
                Console.WriteLine(errorText)
        End Select

        ' Wait some milliseconds to slow down things
        '
        System.Threading.Thread.Sleep(15)
    Next
End Sub
    void GetStatusExample()
{
    String^ errorText;
    PcanChannel channel = PcanChannel::Usb01;

    // The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    //
    PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        // A success message on connection is shown.
        //
        Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

        // Start a thread for a writing messages and wait until it is finished
        //
        System::Threading::Thread^ worker = gcnew System::Threading::Thread(gcnew System::Threading::ParameterizedThreadStart(DoWriteProcess));
        worker->Start(channel);
        worker->Join();

        // The connection to the hardware is finalized when it is no longer needed
        //
        result = Api::Uninitialize(channel);
        if (result != PcanStatus::OK)
        {
            // An error occurred
            //
            Api::GetErrorText(result, errorText);
            Console::WriteLine(errorText);
        }
        else
            Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
    }

}

void DoWriteProcess(Object^ channelToUse)
{
    // Channel to use for message reading
    //
    PcanChannel channel = (PcanChannel)channelToUse;
    PcanStatus result;
    String^ errorText;

    // Message to be send
    PcanMessage^ toSend = gcnew PcanMessage(0x100, MessageType::Standard, 1, gcnew array<Byte>(1), false);

    // 255 messages are send, using the first data byte as a message counter
    //
    for (Byte i = 0; i < Byte::MaxValue; i++)
    {
        // Send the message
        //
        toSend->Data[0] = (Byte)(i + 1);
        result = Api::Write(channel, toSend);

        // Check for any unexpected error
        //
        if ((result == PcanStatus::Initialize) || (result == PcanStatus::IllegalHandle)
            || (result == PcanStatus::InvalidOperation) || (result == PcanStatus::InvalidValue))
        {
            // An unexpected error occurred
            //
            Api::GetErrorText(result, errorText);
            Console::WriteLine(errorText);
            break;
        }

        // The status of the Channel is checked and outputted
        //
        result = Api::GetStatus(channel);
        switch (result)
        {
        case PcanStatus::BusLight:
            Console::WriteLine("An error counter of the Channel {0} has reached the bus-light limit by sending the message number {1}.", channel, i + 1);
            break;
        case PcanStatus::BusHeavy:
            Console::WriteLine("An error counter of the Channel {0} has reached the bus-heavy limit by sending the message number {1}.", channel, i + 1);
            break;
        case PcanStatus::BusOff:
            Console::WriteLine("An error counter of the Channel {0} has reached the bus-off state by sending the message number {1}.", channel, i + 1);
            break;
        case PcanStatus::OK:
            Console::WriteLine("Status of Channel {0} after sending message {1} is 'OK'.", channel, i + 1);
            break;
        default:
            // An unexpected error occurred
            //
            Api::GetErrorText(result, errorText);
            Console::WriteLine(errorText);
            break;
        }

        // Wait some milliseconds to slow down things
        //
        System::Threading::Thread::Sleep(15);
    }
}
See Also

Reference

Api Class
Peak.Can.Basic Namespace
Initialize
Initialize


Api.GetValue Method

ApiGetValue Method

Overload List
Name | Description
GetValue(PcanChannel, PcanParameter, PcanChannelInformation) | Retrieves an array of PcanChannelInformation with information about the hardware currently attached to the system.
GetValue(PcanChannel, PcanParameter, String) | Retrieves a string parameter value from a PCAN Channel.
GetValue(PcanChannel, PcanParameter, UInt32) | Retrieves a 32-bit numeric parameter value from a PCAN Channel.
GetValue(PcanChannel, PcanParameter, UInt64) | Retrieves a 64-bit numeric parameter value from a PCAN Channel.
Top
See Also

Reference

Api Class
Peak.Can.Basic Namespace


Api.GetValue(PcanChannel, PcanParameter, PcanChannelInformation[]) Method

ApiGetValue(PcanChannel, PcanParameter, PcanChannelInformation) Method

Retrieves an array of PcanChannelInformation with information about the hardware currently attached to the system.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetValue(
    PcanChannel channel,
    PcanParameter parameter,
    PcanChannelInformation[] buffer
)
Public Shared Function GetValue (
    channel As PcanChannel,
    parameter As PcanParameter,
    buffer As PcanChannelInformation()
) As PcanStatus
public:
static PcanStatus GetValue(
    PcanChannel channel,
    PcanParameter parameter,
    array<PcanChannelInformation^>^ buffer
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
parameter PcanParameter
The parameter whose value is to be retrieved.
buffer PcanChannelInformation

Contains the requested information.

buffer is only valid, if the returned value of this method is OK.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • InvalidParameter: Indicates that the requested parameter value is not implemented or is not supported by the given PCAN Channel.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Use GetValue(PcanChannel, PcanParameter, PcanChannelInformation) to get the values associated to the parameters AttachedChannelsInformation.

This method can only be called using the Channel None. Using any other Channel ends with an error.

See PcanChannelInformation for additional information on the retrieved data.

Example

The following example shows the use of the GetValue(PcanChannel, PcanParameter, PcanChannelInformation) method. The information about the attached Channels is requested and shown.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.None;

// The amount of hardware currently attached to the system is retrieved
//
PcanStatus result = Api.GetValue(channel, PcanParameter.AttachedChannelsCount, out uint channelsCount);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // Information about the hardware currently attached to the system is retrieved
    //
    PcanChannelInformation[] channels = new PcanChannelInformation[channelsCount];
    result = Api.GetValue(channel, PcanParameter.AttachedChannelsInformation, channels);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        // The information about the channels is shown
        //
        Console.WriteLine($"There are {channelsCount} Channels attached to the system:");
        for (int i = 0; i < channelsCount; i++)
        {
            Console.WriteLine(" {0}) ---------------------------", i + 1);
            Console.WriteLine("    Name: {0}", channels[i].DeviceName);
            Console.WriteLine("    Handle: 0x{0:X}", channels[i].ChannelHandle);
            Console.WriteLine("    Controller: {0}", channels[i].ControllerNumber);
            Console.WriteLine("    Condition: {0}", channels[i].ChannelCondition);
        }
    }
}
Dim channel As PcanChannel = PcanChannel.None

' The amount of hardware currently attached to the system is retrieved
'
Dim channelsCount As UInteger = Nothing
Dim result As PcanStatus = Api.GetValue(channel, PcanParameter.AttachedChannelsCount, channelsCount)
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' Information about the hardware currently attached to the system is retrieved
    '
    Dim channels = New PcanChannelInformation(channelsCount - 1) {}
    result = Api.GetValue(channel, PcanParameter.AttachedChannelsInformation, channels)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        ' The information about the channels is shown
        '
        Console.WriteLine($"There are {channelsCount} Channels attached to the system:")
        For i As Integer = 0 To channelsCount - 1
            Console.WriteLine(" {0}) ---------------------------", i + 1)
            Console.WriteLine("    Name: {0}", channels(i).DeviceName)
            Console.WriteLine("    Handle: 0x{0:X}", channels(i).ChannelHandle)
            Console.WriteLine("    Controller: {0}", channels(i).ControllerNumber)
            Console.WriteLine("    Condition: {0}", channels(i).ChannelCondition)
        Next
    End If
End If
PcanChannel channel = PcanChannel::None;
String^ errorText;
UInt32 channelsCount;

// The amount of hardware currently attached to the system is retrieved
//
PcanStatus result = Api::GetValue(channel, PcanParameter::AttachedChannelsCount, channelsCount);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // Information about the hardware currently attached to the system is retrieved
    //
    array<PcanChannelInformation^>^ channels = gcnew array<PcanChannelInformation^>(channelsCount);
    result = Api::GetValue(channel, PcanParameter::AttachedChannelsInformation, channels);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        // The information about the channels is shown
        //
        Console::WriteLine("There are {0} Channels attached to the system:", channelsCount);
        for (int i = 0; i < channelsCount; i++)
        {
            Console::WriteLine(" {0}) ---------------------------", i + 1);
            Console::WriteLine("    Name: {0}", channels[i]->DeviceName);
            Console::WriteLine("    Handle: 0x{0:X}", channels[i]->ChannelHandle);
            Console::WriteLine("    Controller: {0}", channels[i]->ControllerNumber);
            Console::WriteLine("    Condition: {0}", channels[i]->ChannelCondition);
        }
    }
}
See Also

Reference

Api Class
GetValue Overload
Peak.Can.Basic Namespace
PCAN Parameters
ParameterValue
PcanDeviceFeatures
ServiceStatus
ChannelCondition
SetValue


Api.GetValue(PcanChannel, PcanParameter, String) Method

ApiGetValue(PcanChannel, PcanParameter, String) Method

Retrieves a string parameter value from a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetValue(
    PcanChannel channel,
    PcanParameter parameter,
    out string buffer
)
Public Shared Function GetValue (
    channel As PcanChannel,
    parameter As PcanParameter,
    <OutAttribute> ByRef buffer As String
) As PcanStatus
public:
static PcanStatus GetValue(
    PcanChannel channel,
    PcanParameter parameter,
    [OutAttribute] String^% buffer
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
parameter PcanParameter
The parameter whose value is to be retrieved.
buffer String

Contains the requested string value.

buffer is only valid, if the returned value of this method is OK.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • IllegalHardwareHandle: Indicates that the hardware represented by channel is currently not available (detached or disabled).
  • InvalidParameter: Indicates that the requested parameter value is not implemented or is not supported by the given PCAN Channel.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Use GetValue(PcanChannel, PcanParameter, String) to get the value of parameters like the ApiVersion, and BitrateFdInformation, among others.

Not all parameters are supported for all PCAN Channels. Using a parameter with a non-compatible Channel ends with an error.

Not all parameters have read access. Using a write-only parameter with GetValue ends with an error.

The value of some parameters can only be retrieved if the channel is initialized. For more information see the PcanParameter section.

Example

The following example shows the use of the GetValue(PcanChannel, PcanParameter, String) method using the USB interface (first PCAN-USB hardware). The name of the hardware represented by a PCAN Channel is requested.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;

// The name of the hardware represented by the given handle is retrieved
//
PcanStatus result = Api.GetValue(channel, PcanParameter.HardwareName, out string name);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // The device ID is shown
    //
    Console.WriteLine($"The name of the hardware represented by the handle {channel} is: {name}.");
}
Dim channel As PcanChannel = PcanChannel.Usb01

' The name of the hardware represented by the given handle is retrieved
'
Dim name As String = Nothing
Dim result As PcanStatus = Api.GetValue(channel, PcanParameter.HardwareName, name)
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' The device ID is shown
    '
    Console.WriteLine($"The name of the hardware represented by the handle {channel} is: {name}.")
End If
PcanChannel channel = PcanChannel::Usb01;
String^ errorText;
String^ name;

//  The name of the hardware represented by the given handle is retrieved
//
PcanStatus result = Api::GetValue(channel, PcanParameter::HardwareName, name);
if (result != PcanStatus::OK)
{
    // An error occurred, get a text describing the error and show it
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
    // The device ID is shown
    //
    Console::WriteLine("The name of the hardware represented by the handle {0} is: {1}.", channel, name);
See Also

Reference

Api Class
GetValue Overload
Peak.Can.Basic Namespace
PCAN Parameters
ParameterValue
PcanDeviceFeatures
ServiceStatus
ChannelCondition
SetValue(PcanChannel, PcanParameter, String)


Api.GetValue(PcanChannel, PcanParameter, UInt32) Method

ApiGetValue(PcanChannel, PcanParameter, UInt32) Method

Retrieves a 32-bit numeric parameter value from a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetValue(
    PcanChannel channel,
    PcanParameter parameter,
    out uint buffer
)
Public Shared Function GetValue (
    channel As PcanChannel,
    parameter As PcanParameter,
    <OutAttribute> ByRef buffer As UInteger
) As PcanStatus
public:
static PcanStatus GetValue(
    PcanChannel channel,
    PcanParameter parameter,
    [OutAttribute] unsigned int% buffer
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
parameter PcanParameter
The parameter whose value is to be retrieved.
buffer UInt32

Contains the requested 32-bit numeric value.

buffer is only valid, if the returned value of this method is OK.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • IllegalHardwareHandle: Indicates that the hardware represented by channel is currently not available (detached or disabled).
  • InvalidParameter: Indicates that the requested parameter value is not implemented or is not supported by the given PCAN Channel.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Use GetValue(PcanChannel, PcanParameter, UInt32) to get the value of parameters like the DeviceId, and ControllerNumber, among others.

Not all parameters are supported for all PCAN Channels. Using a parameter with a non-compatible Channel ends with an error.

Not all parameters have read access. Using a write-only parameter with GetValue ends with an error.

The value of some parameters can only be retrieved if the channel is initialized. For more information see the PcanParameter section.

According to the value being retrieved, the type of the value can be treated as an enumeration value. For more information see the PcanParameter section.

Example

The following example shows the use of the GetValue(PcanChannel, PcanParameter, UInt32) method using the USB interface (first PCAN-USB hardware). The device ID is requested on a not initialized Channel.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

    // The acceptance filter is retrieved
    //
    result = Api.GetValue(channel, PcanParameter.AcceptanceFilter11Bit, out ulong acceptanceFilter);
    if (result != PcanStatus.OK)
    {
        // An error occurred, get a text describing the error and show it
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        Console.WriteLine("The 11-bit acceptance filter is configured as follow:");
        // The acceptance code is coded in the most significant 4 bytes
        Console.WriteLine("   Acceptance code: {0:X8}", acceptanceFilter >> 32);
        // The acceptance mask is coded in the less significant 4 bytes
        Console.WriteLine("   Acceptance mask: {0:X8}", acceptanceFilter & 0xFFFFFFFF);
    }

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
Dim channel As PcanChannel = PcanChannel.Usb01
' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
'
Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)

' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then

    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message on connection is shown.
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

    ' The acceptance filter Is retrieved
    '
    Dim acceptanceFilter As UInt64
    result = Api.GetValue(channel, PcanParameter.AcceptanceFilter11Bit, acceptanceFilter)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine("The 11-bit acceptance filter is configured as follow:")
        ' The acceptance code is coded in the most significant 4 bytes
        Console.WriteLine("   Acceptance code: {0:X8}", acceptanceFilter >> 32)
        ' The acceptance mask is coded in the less significant 4 bytes
        Console.WriteLine("   Acceptance mask: {0:X8}", acceptanceFilter And &HFFFFFFFFUI)
    End If

    ' The connection to the hardware is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
PcanChannel channel = PcanChannel::Usb01;
String^ errorText;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

    // The acceptance filter is retrieved
    //
    UInt64 acceptanceFilter;
    result = Api::GetValue(channel, PcanParameter::AcceptanceFilter11Bit, acceptanceFilter);
    if (result != PcanStatus::OK)
    {
        // An error occurred, get a text describing the error and show it
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        Console::WriteLine("The 11-bit acceptance filter is configured as follow:");
        // The acceptance code is coded in the most significant 4 bytes
        Console::WriteLine("   Acceptance code: {0:X8}", acceptanceFilter >> 32);
        // The acceptance mask is coded in the less significant 4 bytes
        Console::WriteLine("   Acceptance mask: {0:X8}", acceptanceFilter & 0xFFFFFFFF);
    }

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api::Uninitialize(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
}
See Also

Reference

Api Class
GetValue Overload
Peak.Can.Basic Namespace
PCAN Parameters
ParameterValue
PcanDeviceFeatures
ServiceStatus
ChannelCondition
SetValue(PcanChannel, PcanParameter, UInt32)


Api.GetValue(PcanChannel, PcanParameter, UInt64) Method

ApiGetValue(PcanChannel, PcanParameter, UInt64) Method

Retrieves a 64-bit numeric parameter value from a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus GetValue(
    PcanChannel channel,
    PcanParameter parameter,
    out ulong buffer
)
Public Shared Function GetValue (
    channel As PcanChannel,
    parameter As PcanParameter,
    <OutAttribute> ByRef buffer As ULong
) As PcanStatus
public:
static PcanStatus GetValue(
    PcanChannel channel,
    PcanParameter parameter,
    [OutAttribute] unsigned long long% buffer
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
parameter PcanParameter
The parameter whose value is to be retrieved.
buffer UInt64

Contains the requested 64-bit numeric value.

buffer is only valid, if the returned value of this method is OK.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • IllegalHardwareHandle: Indicates that the hardware represented by channel is currently not available (detached or disabled).
  • InvalidParameter: Indicates that the requested parameter value is not implemented or is not supported by the given PCAN Channel.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Use GetValue(PcanChannel, PcanParameter, UInt32) to get the value of parameters like the AcceptanceFilter11Bit, and AcceptanceFilter29Bit.

Not all parameters are supported for all PCAN Channels. Using a parameter with a non-compatible Channel ends with an error.

Not all parameters have read access. Using a write-only parameter with GetValue ends with an error.

The value of some parameters can only be retrieved if the channel is initialized. For more information see the PcanParameter section.

Example

The following example shows the use of the GetValue(PcanChannel, PcanParameter, UInt64) method using the USB interface (first PCAN-USB hardware). The 11-bit acceptance filter is requested.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

    // The acceptance filter is retrieved
    //
    result = Api.GetValue(channel, PcanParameter.AcceptanceFilter11Bit, out ulong acceptanceFilter);
    if (result != PcanStatus.OK)
    {
        // An error occurred, get a text describing the error and show it
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        Console.WriteLine("The 11-bit acceptance filter is configured as follow:");
        // The acceptance code is coded in the most significant 4 bytes
        Console.WriteLine("   Acceptance code: {0:X8}", acceptanceFilter >> 32);
        // The acceptance mask is coded in the less significant 4 bytes
        Console.WriteLine("   Acceptance mask: {0:X8}", acceptanceFilter & 0xFFFFFFFF);
    }

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
Dim channel As PcanChannel = PcanChannel.Usb01
' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
'
Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)

' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then

    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message on connection is shown.
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

    ' The acceptance filter Is retrieved
    '
    Dim acceptanceFilter As UInt64
    result = Api.GetValue(channel, PcanParameter.AcceptanceFilter11Bit, acceptanceFilter)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine("The 11-bit acceptance filter is configured as follow:")
        ' The acceptance code is coded in the most significant 4 bytes
        Console.WriteLine("   Acceptance code: {0:X8}", acceptanceFilter >> 32)
        ' The acceptance mask is coded in the less significant 4 bytes
        Console.WriteLine("   Acceptance mask: {0:X8}", acceptanceFilter And &HFFFFFFFFUI)
    End If

    ' The connection to the hardware is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
PcanChannel channel = PcanChannel::Usb01;
String^ errorText;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

    // The acceptance filter is retrieved
    //
    UInt64 acceptanceFilter;
    result = Api::GetValue(channel, PcanParameter::AcceptanceFilter11Bit, acceptanceFilter);
    if (result != PcanStatus::OK)
    {
        // An error occurred, get a text describing the error and show it
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        Console::WriteLine("The 11-bit acceptance filter is configured as follow:");
        // The acceptance code is coded in the most significant 4 bytes
        Console::WriteLine("   Acceptance code: {0:X8}", acceptanceFilter >> 32);
        // The acceptance mask is coded in the less significant 4 bytes
        Console::WriteLine("   Acceptance mask: {0:X8}", acceptanceFilter & 0xFFFFFFFF);
    }

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api::Uninitialize(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
}
See Also

Reference

Api Class
GetValue Overload
Peak.Can.Basic Namespace
PCAN Parameters
ParameterValue
PcanDeviceFeatures
ServiceStatus
ChannelCondition
SetValue(PcanChannel, PcanParameter, UInt64)


Api.Initialize Method

ApiInitialize Method

Overload List
Name | Description
Initialize(PcanChannel, Bitrate) | Initializes a PCAN Channel for classic CAN communication.
Initialize(PcanChannel, BitrateFD) | Initializes a PCAN Channel for CAN communication supporting flexible data rate.
Top
See Also

Reference

Api Class
Peak.Can.Basic Namespace


Api.Initialize(PcanChannel, Bitrate) Method

ApiInitialize(PcanChannel, Bitrate) Method

Initializes a PCAN Channel for classic CAN communication.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus Initialize(
    PcanChannel channel,
    Bitrate bitrate
)
Public Shared Function Initialize (
    channel As PcanChannel,
    bitrate As Bitrate
) As PcanStatus
public:
static PcanStatus Initialize(
    PcanChannel channel,
    Bitrate bitrate
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
bitrate Bitrate
The speed for the communication (BTR0/BTR1 code). Default is 500 kBit/s (Pcan500).

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • Caution: Indicates that the channel has been initialized but at a different bit rate than the specified in bitrate.
  • IllegalHandle: Indicates that the channel contains an invalid value.
  • IllegalHardwareHandle: Indicates that the channel is not available.
  • InvalidOperation: Indicates that an action cannot be executed due to the state of the hardware. Possible causes are:
    • The channel is a PcanLan Channel, which uses a different bit rate than the specified.
  • IllegalMode: Indicates that the hardware is working in a different or incompatible mode than requested. Possible causes are:
    • The channel is being operated in CAN FD mode.
  • Initialize: Indicates that the channel cannot be connected because it is already in use (PCAN-Basic / PCAN-Light environment).
  • NetInUse: Indicates that the channel is being used with a different bit rate (PCAN-View).
  • HardwareInUse: Indicates that the channel is being already used (PcanApi connection).
  • NoDriver: Indicates that the device driver needed for connecting the channel is not loaded.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks
Note Note
For initializing a CAN FD capable Channel for CAN FD communication use the method Initialize instead.
Note Note
This method will fail if an application tries to initialize a PCAN Channel that has been already initialized. The PCAN Channel must be first finalized using the Uninitialize method, to be able to call Initialize or Initialize on it again.

As indicated by its name, the Initialize method initiates a PCAN Channel, preparing it for communicate within the CAN bus connected to it. Calls to other methods will fail if they are used with a Channel handle, different than None, that has not been initialized yet. Each initialized channel should be released when it is not needed anymore.

Initializing a PCAN Channel means:

  • to reserve the Channel for the calling application/process.
  • to allocate Channel resources, like receive and transmit queues.
  • to register/connect the Hardware denoted by the Channel handle.
  • to check and adapt the bus speed, if the Channel is already in use - only if the Channel was configured to adapt an available bit rate (see: BitrateAdapting parameter).
  • to set the Channel in Listen-Only mode - only if the Channel was configured to work in Listen-Only mode (see: ListenOnly parameter).
  • to open the filter, i.e., configure the filter to capture all messages that are transmitted on the bus.
  • to set-up the default values of the different parameters (see method GetValue).
  • to activate the receive status for the Channel. (See: ReceiveStatus parameter).

Take in consideration that initializing a Channel causes a reset of the CAN hardware, when the bus status is other than OK. In this way errors like BusOff, BusLight, and BusHeavy, are removed.

PCAN-LAN Channels

A PCAN-LAN Channel doesn't allow changing the bit rate using PCAN-Basic. In order to connect a PCAN-LAN Channel it is necessary to know the bit rate of the CAN controller on the PCAN-Gateway device that is represented by that Channel. To initialize the Channel without having to specify the correct bit rate, the parameter BitrateAdapting can be used.

Example

The following example shows the initialization and uninitialization processes using the USB interface (first PCAN-USB hardware).

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api.Initialize(channel,  Bitrate.Pcan500);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message is shown
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");
    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if(result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
Dim channel As PcanChannel = PcanChannel.Usb01

' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
'
Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)
If (result <> PcanStatus.OK) Then
    ' An error occurred
    '
    Dim errorText As String = String.Empty
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message is shown
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")
    ' The connection to the hardware Is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If (result <> PcanStatus.OK) Then
        ' An error occurred
        '
        Dim errorText As String = String.Empty
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
    String^ errorText;
PcanChannel channel = PcanChannel::Usb01;

    // The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    //
    PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        // A success message is shown
        //
        Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);
        // The connection to the hardware is finalized when it is no longer needed
        //
        result = Api::Uninitialize(channel);
        if (result != PcanStatus::OK)
        {
            // An error occurred
            //
            Api::GetErrorText(result, errorText);
            Console::WriteLine(errorText);
        }
        else
            Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
    }
See Also

Reference

Api Class
Initialize Overload
Peak.Can.Basic Namespace
Initialize
Uninitialize


Api.Initialize(PcanChannel, BitrateFD) Method

ApiInitialize(PcanChannel, BitrateFD) Method

Initializes a PCAN Channel for CAN communication supporting flexible data rate.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus Initialize(
    PcanChannel channel,
    BitrateFD bitrate
)
Public Shared Function Initialize (
    channel As PcanChannel,
    bitrate As BitrateFD
) As PcanStatus
public:
static PcanStatus Initialize(
    PcanChannel channel,
    BitrateFD^ bitrate
)

Parameters

channel PcanChannel
The handle of a FD capable PCAN Channel.
bitrate BitrateFD
The speed for the communication as a CAN FD bit rate object (see BitrateFD). Default is 500 kBit/s / 2 MBit/s (BitrateSaeJ2284_4).

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • Caution: Indicates that the channel has been initialized but at a different bit rate than the specified in bitrate.
  • IllegalHandle: Indicates that the channel contains an invalid value.
  • IllegalHardwareHandle: Indicates that the channel is not available.
  • InvalidOperation: Indicates that an action cannot be executed due to the state of the hardware. Possible causes are:
    • The channel is not CAN FD capable and cannot be initialized using this method.
    • The channel is a PcanLan Channel, which uses a different bit rate than the specified.
  • IllegalMode: Indicates that the hardware is working in a different or incompatible mode than requested. Possible causes are:
    • The channel is being operated in classic CAN 2.0 A/B mode.
  • Initialize: Indicates that the channel cannot be connected because it is already in use (PCAN-Basic / PCAN-Light environment).
  • NetInUse: Indicates that the channel is being used with a different bit rate (PCAN-View).
  • HardwareInUse: Indicates that the channel is being already used (PcanApi connection).
  • NoDriver: Indicates that the device driver needed for connecting the channel is not loaded.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks
Note Note
For initializing a Channel for CAN communication only (no flexible data rate), use the method Initialize instead.
Note Note
This method will fail if an application tries to initialize a PCAN Channel that has been already initialized. The PCAN Channel must be first finalized using the Uninitialize method, to be able to call Initialize or Initialize on it again.

As indicated by its name, the Initialize method initiates a PCAN Channel, preparing it for communicate within the CAN bus connected to it. Calls to the other methods will fail if they are used with a Channel handle, different than None, that has not been initialized yet. Each initialized channel should be released when it is not needed anymore.

Initializing a PCAN Channel means:

  • to reserve the Channel for the calling application/process.
  • to allocate Channel resources, like receive and transmit queues.
  • to register/connect the Hardware denoted by the Channel handle.
  • to check and adapt the bus speed, if the Channel is already in use - only if the Channel was configured to adapt an available bit rate (see: BitrateAdapting parameter).
  • to set the Channel in Listen-Only mode - only if the Channel was configured to work in Listen-Only mode (see: ListenOnly parameter).
  • to open the filter, i.e., configure the filter to capture all messages that are transmitted on the bus.
  • to set-up the default values of the different parameters (see method GetValue).
  • to activate the receive status for the Channel. (See: ReceiveEvent parameter).

Take in consideration that initializing a Channel causes a reset of the CAN hardware, when the bus status is other than OK. In this way errors like BusOff, BusWarning, and BusPassive, are removed.

PCAN-LAN Channels

A PCAN-LAN Channel doesn't allow changing the bit rate using PCAN-Basic. In order to connect a PCAN-LAN Channel it is necessary to know the bit rate of the CAN controller on the PCAN-Gateway device that is represented by that Channel. To initialize the Channel without having to specify the correct bit rate, the parameter BitrateAdapting can be used.

Example

The following example shows the initialization and uninitialization processes using the USB interface (first PCAN-USB hardware).

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
//
PcanStatus result = Api.Initialize(channel, (BitrateFD)BitrateFD.BitrateSaeJ2284_4);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message is shown
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");
    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
Dim channel As PcanChannel = PcanChannel.Usb01

' The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
'
Dim result As PcanStatus = Api.Initialize(channel, CType(BitrateFD.BitrateSaeJ2284_4, BitrateFD))
If (result <> PcanStatus.OK) Then
    ' An error occurred
    '
    Dim errorText As String = String.Empty
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message is shown
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")
    ' The connection to the hardware Is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If (result <> PcanStatus.OK) Then
        ' An error occurred
        '
        Dim errorText As String = String.Empty
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
String^ errorText;
PcanChannel channel = PcanChannel::Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
//
PcanStatus result = Api::Initialize(channel, (BitrateFD^)BitrateFD::BitrateSaeJ2284_4);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message is shown
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);
    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api::Uninitialize(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
}
See Also

Reference

Api Class
Initialize Overload
Peak.Can.Basic Namespace
Initialize
Uninitialize


Api.LookUpChannel Method

ApiLookUpChannel Method

Finds the handle of a PCAN Channel that matches the given parameters.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus LookUpChannel(
    string parameters,
    out PcanChannel foundChannel
)
Public Shared Function LookUpChannel (
    parameters As String,
    <OutAttribute> ByRef foundChannel As PcanChannel
) As PcanStatus
public:
static PcanStatus LookUpChannel(
    String^ parameters,
    [OutAttribute] PcanChannel% foundChannel
)

Parameters

parameters String
A comma-separated string of search parameters, that is, parameter name/value pairs to be matched within a PCAN Channel.
foundChannel PcanChannel

Contains the matching PCAN Handle, when found in the list of attached Channels.

foundChannel is only valid, if the returned value of this method is OK.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • InvalidValue: Indicates that parameters contains an invalid value.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

The parameters string must contain name/value pairs separated with a '=' character.

Each name/value pair must be separated with a ',' character.

The current supported parameters and their value ranges are described within the ParameterValueLookUp class definition.

Example

The following example shows the use of the LookUpChannel method. The handle of a PCAN Channel of type PCI and ID 7 is requested.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.None;
PcanDevice deviceType = PcanDevice.PcanPci;
uint deviceId = 7;

string paramters = ParameterValue.LookUp.GetCriteriaString(deviceType, deviceId, null, null);

// The Channel query is made with the specified criteria
//
Console.WriteLine($"Searching for PCAN Handle with type {deviceType} and device ID equals to {deviceId}.");
PcanStatus result = Api.LookUpChannel(paramters, out channel);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // Show the results of the search
    //
    if (channel == PcanChannel.None)
        Console.WriteLine("No PCAN Channel matched the search criteria.");
    else
        Console.WriteLine($"The handle of the PCAN Channel is {channel}");
}
Dim channel As PcanChannel = PcanChannel.None
Dim deviceType As PcanDevice = PcanDevice.PcanPci
Dim deviceId As UInt32 = 7

Dim paramters = ParameterValue.LookUp.GetCriteriaString(deviceType, deviceId, Nothing, Nothing)

' The Channel query is made with the specified criteria
'
Console.WriteLine($"Searching for PCAN Handle with type {deviceType} And device ID equals to {deviceId}.")
Dim result As PcanStatus = Api.LookUpChannel(paramters, channel)
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' Show the results of the search
    '
    If channel = PcanChannel.None Then
        Console.WriteLine("No PCAN Channel matched the search criteria.")
    Else
        Console.WriteLine($"The handle of the PCAN Channel Is {channel}")
    End If
End If
String^ errorText = String::Empty;
PcanChannel channel = PcanChannel::None;
PcanDevice deviceType = PcanDevice::PcanPci;
Nullable <UInt32> deviceId = 7;

String^ paramters = ParameterValue::LookUp::GetCriteriaString(Nullable<PcanDevice>(deviceType), Nullable<UInt32>(deviceId), Nullable<UInt32>(), nullptr);

// The Channel query is made with the specified criteria
//
Console::WriteLine("Searching for PCAN Handle with type {0} and device ID equals to {1}.", deviceType, deviceId);
PcanStatus result = Api::LookUpChannel(paramters, channel);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // Show the results of the search
    //
    if (channel == PcanChannel::None)
        Console::WriteLine("No PCAN Channel matched the search criteria.");
    else
        Console::WriteLine("The handle of the PCAN Channel is {0}", channel);
}
See Also

Reference

Api Class
Peak.Can.Basic Namespace
Initialize
Initialize
GetAttachedChannels(PcanChannelInformation)


Api.Read Method

ApiRead Method

Overload List
Name | Description
Read(PcanChannel, PcanMessage) | Reads a CAN message from the receive queue of a PCAN Channel.
Read(PcanChannel, PcanMessage, UInt64) | Reads a CAN message and its timestamp from the receive queue of a PCAN Channel.
Top
See Also

Reference

Api Class
Peak.Can.Basic Namespace


Api.Read(PcanChannel, PcanMessage) Method

ApiRead(PcanChannel, PcanMessage) Method

Reads a CAN message from the receive queue of a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus Read(
    PcanChannel channel,
    out PcanMessage msg
)
Public Shared Function Read (
    channel As PcanChannel,
    <OutAttribute> ByRef msg As PcanMessage
) As PcanStatus
public:
static PcanStatus Read(
    PcanChannel channel,
    [OutAttribute] PcanMessage^% msg
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
msg PcanMessage

Contains the next available CAN frame stored in the FIFO receive queue of channel.

The content of msg is only valid if the returned value of this method is OK.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • InvalidValue: Indicates that one or more of the values passed to the method are invalid.
  • ReceiveQueueEmpty: Indicates that there are no more messages in the receive queue of the Channel.
  • IllegalData: Indicates that the message that has been read is not permitted due to the current settings and has been discarded.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks
Note Note
If the timestamp of message reception is required, use the Read(PcanChannel, PcanMessage, UInt64) method instead.

The Read method returns CAN frames from the receive queue. It is important to call Read repeatedly until the receive queue becomes empty. In case there are no more messages to retrieve, the error ReceiveQueueEmpty is returned. The ReceiveQueueEmpty error is also returned if the reception of messages, configurable through the ReceiveStatus parameter, is disabled.

The receive queue can contain up to 32768 messages.

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 starts a timer that checks for messages every 50 or 100 milliseconds, calling the Read method in a loop until the ReceiveQueueEmpty error 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 placed 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. Consider using the BusOffAutoReset parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset bus errors like BusOff, BusPassive, and others:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter HardResetStatus: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

The MsgType of a PcanMessage object indicates the kind of CAN frame it describes. This value should be checked every time a message has been read successfully.

If the MsgType of a PcanMessage contains the value Error, then the message is an Error Frame.

If the MsgType of a PcanMessage contains the value Status, then the message is a Status Frame.

Example

The following example shows the use of the Read(PcanChannel, PcanMessage) method using the USB interface (first PCAN-USB hardware). A Channel is initialized and used to read messages within 1 second.

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.

C#
VB
C++
Copy
private static void ReadExample()
{
    PcanChannel channel = PcanChannel.Usb01;

    // The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    //
    PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        // A success message on connection is shown.
        //
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

        // Wait some time to get messages stored in the reception queue of the Channel
        //
        Console.WriteLine("The reception queue will be read out after 1 second...");
        System.Threading.Thread.Sleep(1000);

        // Messages are read and processed until the reception queue is empty
        //
        PcanMessage msg;
        do
        {
            result = Api.Read(channel, out msg);
            if (result == PcanStatus.OK)
            {
                // Process the received message
                //
                ProcessMessage(msg);
            }
            else
            {
                if ((result & PcanStatus.ReceiveQueueEmpty) != PcanStatus.ReceiveQueueEmpty)
                {
                    // An unexpected error occurred
                    //
                    Api.GetErrorText(result, out var errorText);
                    Console.WriteLine("Reading process canceled due to unexpected error: " + errorText);
                    break;
                }
            }

        } while ((result & PcanStatus.ReceiveQueueEmpty) != PcanStatus.ReceiveQueueEmpty);

        // The connection to the hardware is finalized when it is no longer needed
        //
        result = Api.Uninitialize(channel);
        if (result != PcanStatus.OK)
        {
            // An error occurred
            //
            Api.GetErrorText(result, out var errorText);
            Console.WriteLine(errorText);
        }
        else
            Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
    }
}

// Formats a CAN frame as string and writes it to the console output
//
private static void ProcessMessage(PcanMessage msg)
{
    string msgText = $"Type: {msg.MsgType} | ";
    if((msg.MsgType & MessageType.Extended) == MessageType.Extended)
        msgText += $"ID: {msg.ID:X8} | ";
    else
        msgText += $"ID: {msg.ID:X4} | ";
    msgText += $"Length: {msg.Length} | ";
    msgText += $"Data: ";
    for (int i = 0; i < msg.Length; i++)
        msgText += $"{msg.Data[i]} ";

    Console.WriteLine(msgText);
}
Private Sub ReadExample()
    Dim channel As PcanChannel = PcanChannel.Usb01

    ' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    '
    Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)
    ' An error occurred
    '
    ' An unexpected error occurred
    '
    Dim errorText = Nothing
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        ' A success message on connection is shown.
        '
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

        ' Wait some time to get messages stored in the reception queue of the Channel
        '
        Console.WriteLine("The reception queue will be read out after 1 second...")
        System.Threading.Thread.Sleep(1000)

        ' Messages are read and processed until the reception queue is empty
        '
        Dim msg As PcanMessage = Nothing
        Do
            result = Api.Read(channel, msg)
            If result = PcanStatus.OK Then
                ' Process the received message
                '
                ProcessMessage(msg)
            Else
                If (result And PcanStatus.ReceiveQueueEmpty) <> PcanStatus.ReceiveQueueEmpty Then
                    Api.GetErrorText(result, errorText)
                    Console.WriteLine("Reading process canceled due to unexpected error: " & errorText)
                    Exit Do
                End If
            End If

        Loop While (result And PcanStatus.ReceiveQueueEmpty) <> PcanStatus.ReceiveQueueEmpty

        ' The connection to the hardware is finalized when it is no longer needed
        '
        result = Api.Uninitialize(channel)

        If result <> PcanStatus.OK Then
            ' An error occurred
            '
            Api.GetErrorText(result, errorText)
            Console.WriteLine(errorText)
        Else
            Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
        End If
    End If
End Sub

' Formats a CAN frame as string and writes it to the console output
'
Private Sub ProcessMessage(ByVal msg As PcanMessage)
    Dim msgText = $"Type: {msg.MsgType} | "
    If (msg.MsgType And MessageType.Extended) = MessageType.Extended Then
        msgText += $"ID: {msg.ID:X8} | "
    Else
        msgText += $"ID: {msg.ID:X4} | "
    End If
    msgText += $"Length: {msg.Length} | "
    msgText += $"Data: "
    For i As Integer = 0 To msg.Length - 1
        msgText += $"{msg.Data(i)} "
    Next

    Console.WriteLine(msgText)
End Sub
void ReadExample()
{
    String^ errorText;
    PcanChannel channel = PcanChannel::Usb01;

    // The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    //
    PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        // A success message on connection is shown.
        //
        Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

        // Wait some time to get messages stored in the reception queue of the Channel
        //
        Console::WriteLine("The reception queue will be read out after 1 second...");
        System::Threading::Thread::Sleep(1000);

        // Messages are read and processed until the reception queue is empty
        //
        PcanMessage^ msg;
        do
        {
            result = Api::Read(channel, msg);
            if (result == PcanStatus::OK)
            {
                // Process the received message
                //
                ProcessMessage(msg);
            }
            else
            {
                if ((result & PcanStatus::ReceiveQueueEmpty) != PcanStatus::ReceiveQueueEmpty)
                {
                    // An unexpected error occurred
                    //
                    Api::GetErrorText(result, errorText);
                    Console::WriteLine("Reading process canceled due to unexpected error: {0}", errorText);
                    break;
                }
            }

        } while ((result & PcanStatus::ReceiveQueueEmpty) != PcanStatus::ReceiveQueueEmpty);

        // The connection to the hardware is finalized when it is no longer needed
        //
        result = Api::Uninitialize(channel);
        if (result != PcanStatus::OK)
        {
            // An error occurred
            //
            Api::GetErrorText(result, errorText);
            Console::WriteLine(errorText);
        }
        else
            Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
    }
}

// Formats a CAN frame as string and writes it to the console output
//
void ProcessMessage(PcanMessage^ msg)
{
    String^ msgText = String::Format("Type: {0} | ", msg->MsgType);
    if ((msg->MsgType & MessageType::Extended) == MessageType::Extended)
        msgText += String::Format("ID: {0:X8} | ", msg->ID);
    else
        msgText += String::Format("ID: {0:X4} | ", msg->ID);
    msgText += String::Format("Length: {0} | ", msg->Length);
    msgText += "Data: ";
    for (int i = 0; i < msg->Length; i++)
        msgText += String::Format("{0:X2} ", msg->Data[i]);

    Console::WriteLine(msgText);
}
See Also

Reference

Api Class
Read Overload
Peak.Can.Basic Namespace
Initialize
Initialize
Write

Other Resources

Using Events
Error Frame
Status Frame


Api.Read(PcanChannel, PcanMessage, UInt64) Method

ApiRead(PcanChannel, PcanMessage, UInt64) Method

Reads a CAN message and its timestamp from the receive queue of a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus Read(
    PcanChannel channel,
    out PcanMessage msg,
    out ulong timestamp
)
Public Shared Function Read (
    channel As PcanChannel,
    <OutAttribute> ByRef msg As PcanMessage,
    <OutAttribute> ByRef timestamp As ULong
) As PcanStatus
public:
static PcanStatus Read(
    PcanChannel channel,
    [OutAttribute] PcanMessage^% msg,
    [OutAttribute] unsigned long long% timestamp
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
msg PcanMessage

Contains the next available CAN frame stored in the FIFO receive queue of channel.

The content of msg is only valid if the returned value of this method is OK.

timestamp UInt64

Contains the timestamp, in microseconds, of when the msg was received.

The content of timestamp is only valid if the returned value of this method is OK.

Note Note

On Windows, the timestamp contains the number of microseconds elapsed since system start.

On Linux, the timestamp contains the number of microseconds elapsed since the epoch (00:00 UTC, January 1st 1970).

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • InvalidValue: Indicates that one or more of the values passed to the method are invalid.
  • ReceiveQueueEmpty: Indicates that there are no more messages in the receive queue of the Channel.
  • IllegalData: Indicates that the message that has been read is not permitted due to the current settings and has been discarded.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks
Note Note
If the timestamp of message reception is not required, use the Read(PcanChannel, PcanMessage) method instead.

The Read method returns CAN frames from the receive queue. It is important to call Read repeatedly until the receive queue becomes empty. In case there are no more messages to retrieve, the error ReceiveQueueEmpty is returned. The ReceiveQueueEmpty error is also returned if the reception of messages, configurable through the ReceiveStatus parameter, is disabled.

The receive queue can contain up to 32768 messages.

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 starts a timer that checks for messages every 50 or 100 milliseconds, calling the Read method in a loop until the ReceiveQueueEmpty error 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 placed 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. Consider using the BusOffAutoReset parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset bus errors like BusOff, BusPassive, and others:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter HardResetStatus: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

The MsgType of a PcanMessage object indicates the kind of CAN frame it describes. This value should be checked every time a message has been read successfully.

If the MsgType of a PcanMessage contains the value Error, then the message is an Error Frame.

If the MsgType of a PcanMessage contains the value Status, then the message is a Status Frame.

Example

The following example shows the use of the Read(PcanChannel, PcanMessage, UInt64) method using the USB interface (first PCAN-USB hardware). A Channel is initialized and used to read messages within 1 second.

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.

C#
VB
C++
Copy
private static void ReadWithTimestampExample()
{
    PcanChannel channel = PcanChannel.Usb01;

    // The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    //
    PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        // A success message on connection is shown.
        //
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

        // Wait some time to get messages stored in the reception queue of the Channel
        //
        Console.WriteLine("The reception queue will be read out after 1 second...");
        System.Threading.Thread.Sleep(1000);

        // Messages are read and processed until the reception queue is empty
        //
        PcanMessage msg;
        ulong timestamp;
        do
        {
            result = Api.Read(channel, out msg, out timestamp);
            if (result == PcanStatus.OK)
            {
                // Process the received message
                //
                ProcessMessage(msg, timestamp);
            }
            else
            {
                if ((result & PcanStatus.ReceiveQueueEmpty) != PcanStatus.ReceiveQueueEmpty)
                {
                    // An unexpected error occurred
                    //
                    Api.GetErrorText(result, out var errorText);
                    Console.WriteLine("Reading process canceled due to unexpected error: " + errorText);
                    break;
                }
            }

        } while ((result & PcanStatus.ReceiveQueueEmpty) != PcanStatus.ReceiveQueueEmpty);

        // The connection to the hardware is finalized when it is no longer needed
        //
        result = Api.Uninitialize(channel);
        if (result != PcanStatus.OK)
        {
            // An error occurred
            //
            Api.GetErrorText(result, out var errorText);
            Console.WriteLine(errorText);
        }
        else
            Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
    }
}

// Formats a CAN frame as string and writes it to the console output
//
private static void ProcessMessage(PcanMessage msg, ulong timestamp)
{
    string msgText = $"Type: {msg.MsgType} | ";
    if ((msg.MsgType & MessageType.Extended) == MessageType.Extended)
        msgText += $"ID: {msg.ID:X8} | ";
    else
        msgText += $"ID: {msg.ID:X4} | ";
    msgText += $"Length: {msg.Length} | ";
    msgText += $"Time (ms): {timestamp / 1000:F1} | ";
    msgText += $"Data: ";
    for (int i = 0; i < msg.Length; i++)
        msgText += $"{msg.Data[i]} ";

    Console.WriteLine(msgText);
}
Private Sub ReadWithTimstampExample()
    Dim channel As PcanChannel = PcanChannel.Usb01

    ' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    '
    Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)
    ' An error occurred
    '
    ' An unexpected error occurred
    '
    Dim errorText = Nothing
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        ' A success message on connection is shown.
        '
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

        ' Wait some time to get messages stored in the reception queue of the Channel
        '
        Console.WriteLine("The reception queue will be read out after 1 second...")
        System.Threading.Thread.Sleep(1000)

        ' Messages are read and processed until the reception queue is empty
        '
        Dim msg As PcanMessage = Nothing
        Dim timestamp As UInt64 = 0

        Do
            result = Api.Read(channel, msg, timestamp)
            If result = PcanStatus.OK Then
                ' Process the received message
                '
                ProcessMessage(msg, timestamp)
            Else
                If (result And PcanStatus.ReceiveQueueEmpty) <> PcanStatus.ReceiveQueueEmpty Then
                    Api.GetErrorText(result, errorText)
                    Console.WriteLine("Reading process canceled due to unexpected error: " & errorText)
                    Exit Do
                End If
            End If
        Loop While (result And PcanStatus.ReceiveQueueEmpty) <> PcanStatus.ReceiveQueueEmpty

        ' The connection to the hardware is finalized when it is no longer needed
        '
        result = Api.Uninitialize(channel)

        If result <> PcanStatus.OK Then
            ' An error occurred
            '
            Api.GetErrorText(result, errorText)
            Console.WriteLine(errorText)
        Else
            Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
        End If
    End If
End Sub

' Formats a CAN frame as string and writes it to the console output
'
Private Sub ProcessMessage(ByVal msg As PcanMessage, ByVal timestamp As ULong)
    Dim msgText = $"Type: {msg.MsgType} | "
    If (msg.MsgType And MessageType.Extended) = MessageType.Extended Then
        msgText += $"ID: {msg.ID:X8} | "
    Else
        msgText += $"ID: {msg.ID:X4} | "
    End If
    msgText += $"Length: {msg.Length} | "
    msgText += $"Time (ms): {timestamp / 1000:F1} | "
    msgText += $"Data: "
    For i As Integer = 0 To msg.Length - 1
        msgText += $"{msg.Data(i)} "
    Next

    Console.WriteLine(msgText)
End Sub
void ReadWithTimestampExample()
{
    String^ errorText;
    PcanChannel channel = PcanChannel::Usb01;

    // The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
    //
    PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        // A success message on connection is shown.
        //
        Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

        // Wait some time to get messages stored in the reception queue of the Channel
        //
        Console::WriteLine("The reception queue will be read out after 1 second...");
        System::Threading::Thread::Sleep(1000);

        // Messages are read and processed until the reception queue is empty
        //
        PcanMessage^ msg;
        UInt64 timestamp;
        do
        {
            result = Api::Read(channel, msg, timestamp);
            if (result == PcanStatus::OK)
            {
                // Process the received message
                //
                ProcessMessage(msg, timestamp);
            }
            else
            {
                if ((result & PcanStatus::ReceiveQueueEmpty) != PcanStatus::ReceiveQueueEmpty)
                {
                    // An unexpected error occurred
                    //
                    Api::GetErrorText(result, errorText);
                    Console::WriteLine("Reading process canceled due to unexpected error: {0}", errorText);
                    break;
                }
            }

        } while ((result & PcanStatus::ReceiveQueueEmpty) != PcanStatus::ReceiveQueueEmpty);
    }
}

// Formats a CAN frame as string and writes it to the console output
//
void ProcessMessage(PcanMessage^ msg, UInt64 timestamp)
{
    String^ msgText = String::Format("Type: {0} | ", msg->MsgType);
    if ((msg->MsgType & MessageType::Extended) == MessageType::Extended)
        msgText += String::Format("ID: {0:X8} | ", msg->ID);
    else
        msgText += String::Format("ID: {0:X4} | ", msg->ID);
    msgText += String::Format("Length: {0} | ", msg->Length);
    msgText += String::Format("Time (ms): {0:F1} | ", timestamp / 1000);
    msgText += "Data: ";
    for (int i = 0; i < msg->Length; i++)
        msgText += String::Format("{0:X2} ", msg->Data[i]);

    Console::WriteLine(msgText);
}
See Also

Reference

Api Class
Read Overload
Peak.Can.Basic Namespace
Initialize
Initialize
Write

Other Resources

Using Events
Error Frame
Status Frame


Api.Reset Method

ApiReset Method

Discards all messages contained in the receive and transmit queues of a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus Reset(
    PcanChannel channel
)
Public Shared Function Reset (
    channel As PcanChannel
) As PcanStatus
public:
static PcanStatus Reset(
    PcanChannel channel
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • IllegalHandle: Indicates that the channel contains an invalid value.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Calling this method ONLY clears the queues of a Channel. A reset of the CAN controller doesn't take place, unless the parameter HardResetStatus is active.

Normally a reset of the CAN Controller is desired when a bus-off occur. In this case an application cannot use the channel to communicate anymore, until the CAN controller is reset. Consider using the BusOffAutoReset parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset bus errors like BusOff, BusPassive, and others:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter HardResetStatus: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

Example

The following example shows the use of the Reset(PcanChannel) method using the USB interface (first PCAN-USB hardware). This example assumes that there is communication taking place on the CAN bus.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    // Since the message filter is open at connection time, the Channel is already receiving and placing messages
    // in the reception queue of this Channel.
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

    // Wait some time to simulate any work in the application.
    //
    System.Threading.Thread.Sleep(1000);

    // Before starting with the actual work, the queue is cleared
    //
    result = Api.Reset(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        // A success message on reset is shown.
        //
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully reset.");

        // Wait some time to simulate any operation in the application...
        //
        System.Threading.Thread.Sleep(1000);

        // The connection to the hardware is finalized when it is no longer needed
        //
        result = Api.Uninitialize(channel);
        if (result != PcanStatus.OK)
        {
            // An error occurred
            //
            Api.GetErrorText(result, out var errorText);
            Console.WriteLine(errorText);
        }
        else
            Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
    }
}
Dim channel As PcanChannel = PcanChannel.Usb01

' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
'
Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)
If (result <> PcanStatus.OK) Then
    ' An error occurred
    '
    Dim errorText As String = String.Empty
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message on connection Is shown.
    ' Since the message filter Is open at connection time, the Channel Is already receiving And placing messages
    ' in the reception queue of this Channel.
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

    ' Wait some time to simulate any work in the application.
    '
    System.Threading.Thread.Sleep(1000)

    ' Before starting with the actual work, the queue is cleared
    '
    result = Api.Reset(channel)
    If (result <> PcanStatus.OK) Then
        ' An error occurred
        '
        Dim errorText As String = String.Empty
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        ' A success message on reset is shown.
        '
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully reset.")

        ' Wait some time to simulate any operation in the application...
        '
        System.Threading.Thread.Sleep(1000)

        ' The connection to the hardware Is finalized when it is no longer needed
        '
        result = Api.Uninitialize(channel)
        If (result <> PcanStatus.OK) Then
            ' An error occurred
            '
            Dim errorText As String = String.Empty
            Api.GetErrorText(result, errorText)
            Console.WriteLine(errorText)
        Else
            Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
        End If
    End If
End If
String^ errorText;
PcanChannel channel = PcanChannel::Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    // Since the message filter is open at connection time, the Channel is already receiving and placing messages
    // in the reception queue of this Channel.
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

    // Wait some time to simulate any work in the application.
    //
    System::Threading::Thread::Sleep(1000);

    // Before starting with the actual work, the queue is cleared
    //
    result = Api::Reset(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        // A success message on reset is shown.
        //
        Console::WriteLine("The hardware represented by the handle {0} was successfully reset.", channel);

        // Wait some time to simulate any operation in the application...
        //
        System::Threading::Thread::Sleep(1000);

        // The connection to the hardware is finalized when it is no longer needed
        //
        result = Api::Uninitialize(channel);
        if (result != PcanStatus::OK)
        {
            // An error occurred
            //
            String^ errorText;
            Api::GetErrorText(result, errorText);
            Console::WriteLine(errorText);
        }
        else
            Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
    }
}
See Also

Reference

Api Class
Peak.Can.Basic Namespace
Initialize
Initialize
Uninitialize


Api.SetValue Method

ApiSetValue Method

Overload List
Name | Description
SetValue(PcanChannel, PcanParameter, String) | Configures a string parameter value of a PCAN Channel.
SetValue(PcanChannel, PcanParameter, UInt32) | Configures a 32-bit numeric parameter value of a PCAN Channel.
SetValue(PcanChannel, PcanParameter, UInt64) | Configures a 64-bit numeric parameter value of a PCAN Channel.
Top
See Also

Reference

Api Class
Peak.Can.Basic Namespace


Api.SetValue(PcanChannel, PcanParameter, String) Method

ApiSetValue(PcanChannel, PcanParameter, String) Method

Configures a string parameter value of a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus SetValue(
    PcanChannel channel,
    PcanParameter parameter,
    string buffer
)
Public Shared Function SetValue (
    channel As PcanChannel,
    parameter As PcanParameter,
    buffer As String
) As PcanStatus
public:
static PcanStatus SetValue(
    PcanChannel channel,
    PcanParameter parameter,
    String^ buffer
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
parameter PcanParameter
The parameter whose value is to be configured.
buffer String
Contains the string value to be set.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • IllegalHardwareHandle: Indicates that the hardware represented by channel is currently not available (detached or disabled).
  • InvalidParameter: Indicates that the requested parameter value is not implemented or is not supported by the given PCAN Channel.
  • InvalidValue: Indicates that one or more of the values passed to the method are invalid.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Use SetValue(PcanChannel, PcanParameter, UInt64) to set the value of parameters like the LogLocation, and TraceLocation, among others.

Not all parameters are supported for all PCAN Channels. Using a parameter with a non-compatible Channel ends with an error.

Not all parameters have write access. Using a read-only parameter with SetValue ends with an error.

Except for a few parameters, the channel has to be initialized first, before being able to configure a value on it. For more information see the PcanParameter section.

Example

The following example shows the use of the SetValue(PcanChannel, PcanParameter, String) method using the default Channel (None). A custom location path for the log file is configured, the logging functionality activated, and a custom entry written.

Note Note
Changing the value of the parameter LogLocation automatically activates the logging functionality.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.None;
string path = System.IO.Path.GetTempPath();

// The temporary folder will be configured as output for the log file
//
PcanStatus result = Api.SetValue(channel, PcanParameter.LogLocation, path);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // The path was changed and the logging functionality activated
    //
    Console.WriteLine($"PCANBasic.log file location set to: {path}");
    Console.WriteLine("Calls to the PCAN-Basic are being logged...");

    result = Api.SetValue(channel, PcanParameter.LogText, "This is a custom entry.");
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        Console.WriteLine($"A custom text was included in the file {path}PCANBasic.log.");
    }
}
Dim channel As PcanChannel = PcanChannel.None
Dim path As String = IO.Path.GetTempPath()

' The temporary folder will be configured as output for the log file
'
Dim result As PcanStatus = Api.SetValue(channel, PcanParameter.LogLocation, path)
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' The path was changed and the logging functionality activated
    '
    Console.WriteLine($"PCANBasic.log file location: {path}")
    Console.WriteLine("Calls to the PCAN-Basic are being logged...")

    result = Api.SetValue(channel, PcanParameter.LogText, "This is a custom entry.")
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"A custom text was included in the file {path}PCANBasic.log.")
    End If
End If
PcanChannel channel = PcanChannel::None;
String^ path = System::IO::Path::GetTempPath();
String^ errorText;

// The temporary folder will be configured as output for the log file
//
PcanStatus result = Api::SetValue(channel, PcanParameter::LogLocation, path);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // The path was changed and the logging functionality activated
    //
    Console::WriteLine("PCANBasic.log file location set to: {0}", path);
    Console::WriteLine("Calls to the PCAN-Basic are being logged...");

    result = Api::SetValue(channel, PcanParameter::LogText, "This is a custom entry.");
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        Console::WriteLine("A custom text was included in the file {0}PCANBasic.log.", path);
    }
}
See Also

Reference

Api Class
SetValue Overload
Peak.Can.Basic Namespace
PCAN Parameters
GetValue


Api.SetValue(PcanChannel, PcanParameter, UInt32) Method

ApiSetValue(PcanChannel, PcanParameter, UInt32) Method

Configures a 32-bit numeric parameter value of a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus SetValue(
    PcanChannel channel,
    PcanParameter parameter,
    uint buffer
)
Public Shared Function SetValue (
    channel As PcanChannel,
    parameter As PcanParameter,
    buffer As UInteger
) As PcanStatus
public:
static PcanStatus SetValue(
    PcanChannel channel,
    PcanParameter parameter,
    unsigned int buffer
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
parameter PcanParameter
The parameter whose value is to be configured.
buffer UInt32
Contains the 32-bit numeric value to be set.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • IllegalHardwareHandle: Indicates that the hardware represented by channel is currently not available (detached or disabled).
  • InvalidParameter: Indicates that the requested parameter value is not implemented or is not supported by the given PCAN Channel.
  • InvalidValue: Indicates that one or more of the values passed to the method are invalid.
  • InvalidOperation: Indicates that an action cannot be executed due to the state of the hardware. Possible causes are:
    • The BitrateAdapting parameter is being configured on an initialized channel.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Use SetValue(PcanChannel, PcanParameter, UInt32) to set the value of parameters like the DeviceId, and ReceiveStatus, among others.

Not all parameters are supported for all PCAN Channels. Using a parameter with a non-compatible Channel ends with an error.

Not all parameters have write access. Using a read-only parameter with SetValue ends with an error.

Except for a few parameters, the channel has to be initialized first, before being able to configure a value on it. For more information see the PcanParameter section.

Example

The following example shows the use of the SetValue(PcanChannel, PcanParameter, UInt32) method using the USB interface (first PCAN-USB hardware). The device ID of the channel is configured to be 7.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;
ulong acceptanceFilter = 0x00001000_00000500;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

    // Configure the acceptance filter of the device to allow receiving the messages with IDs 1100h, 1400h, and 1500h
    //
    result = Api.SetValue(channel, PcanParameter.AcceptanceFilter29Bit, acceptanceFilter);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        Console.WriteLine($"The 29-bit acceptance filter of the hardware represented by the handle {channel} was successfully set to {acceptanceFilter:X16}h.");
    }

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
Dim channel As PcanChannel = PcanChannel.Usb01
Dim acceptanceFilter As ULong = &H00001000_00000500

' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
'
Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message on connection is shown.
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

    ' Configure the acceptance filter of the device to allow receiving the messages with IDs 1100h, 1400h, and 1500h
    '
    result = Api.SetValue(channel, PcanParameter.AcceptanceFilter29Bit, acceptanceFilter)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The 29-bit acceptance filter of the hardware represented by the handle {channel} was successfully set to {acceptanceFilter:X16}h.")
    End If

    ' The connection to the hardware is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
PcanChannel channel = PcanChannel::Usb01;
String^ errorText;
UInt64 acceptanceFilter = 0x00001000'00000500;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

    // Configure the acceptance filter of the device to allow receiving the messages with IDs 1100h, 1400h, and 1500h
    //
    result = Api::SetValue(channel, PcanParameter::AcceptanceFilter29Bit, acceptanceFilter);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        Console::WriteLine("The 29-bit acceptance filter of the hardware represented by the handle {0} was successfully set to {1:X16}h.", channel, acceptanceFilter);
    }

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api::Uninitialize(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
}
See Also

Reference

Api Class
SetValue Overload
Peak.Can.Basic Namespace
PCAN Parameters
GetValue(PcanChannel, PcanParameter, UInt32)


Api.SetValue(PcanChannel, PcanParameter, UInt64) Method

ApiSetValue(PcanChannel, PcanParameter, UInt64) Method

Configures a 64-bit numeric parameter value of a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus SetValue(
    PcanChannel channel,
    PcanParameter parameter,
    ulong buffer
)
Public Shared Function SetValue (
    channel As PcanChannel,
    parameter As PcanParameter,
    buffer As ULong
) As PcanStatus
public:
static PcanStatus SetValue(
    PcanChannel channel,
    PcanParameter parameter,
    unsigned long long buffer
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
parameter PcanParameter
The parameter whose value is to be configured.
buffer UInt64
Contains the 64-bit numeric value to be set.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • IllegalHardwareHandle: Indicates that the hardware represented by channel is currently not available (detached or disabled).
  • InvalidParameter: Indicates that the requested parameter value is not implemented or is not supported by the given PCAN Channel.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Use SetValue(PcanChannel, PcanParameter, UInt64) to set the value of parameters like the AcceptanceFilter11Bit, and AcceptanceFilter29Bit.

Not all parameters are supported for all PCAN Channels. Using a parameter with a non-compatible Channel ends with an error.

Not all parameters have write access. Using a read-only parameter with SetValue ends with an error.

Except for a few parameters, the channel has to be initialized first, before being able to configure a value on it. For more information see the PcanParameter section.

Example

The following example shows the use of the SetValue(PcanChannel, PcanParameter, UInt32) method using the USB interface (first PCAN-USB hardware). The 29-bit acceptance filter is set to accept messages with Ids 1100h, 1400h, and 1500h.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;
ulong acceptanceFilter = 0x00001000_00000500;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api.Initialize(channel, Bitrate.Pcan500);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

    // Configure the acceptance filter of the device to allow receiving the messages with IDs 1100h, 1400h, and 1500h
    //
    result = Api.SetValue(channel, PcanParameter.AcceptanceFilter29Bit, acceptanceFilter);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
    {
        Console.WriteLine($"The 29-bit acceptance filter of the hardware represented by the handle {channel} was successfully set to {acceptanceFilter:X16}h.");
    }

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
Dim channel As PcanChannel = PcanChannel.Usb01
Dim acceptanceFilter As ULong = &H00001000_00000500

' The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
'
Dim result As PcanStatus = Api.Initialize(channel, Bitrate.Pcan500)
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message on connection is shown.
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

    ' Configure the acceptance filter of the device to allow receiving the messages with IDs 1100h, 1400h, and 1500h
    '
    result = Api.SetValue(channel, PcanParameter.AcceptanceFilter29Bit, acceptanceFilter)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The 29-bit acceptance filter of the hardware represented by the handle {channel} was successfully set to {acceptanceFilter:X16}h.")
    End If

    ' The connection to the hardware is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
PcanChannel channel = PcanChannel::Usb01;
String^ errorText;
UInt64 acceptanceFilter = 0x00001000'00000500;

// The hardware represented by the given handle is initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
PcanStatus result = Api::Initialize(channel, Bitrate::Pcan500);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

    // Configure the acceptance filter of the device to allow receiving the messages with IDs 1100h, 1400h, and 1500h
    //
    result = Api::SetValue(channel, PcanParameter::AcceptanceFilter29Bit, acceptanceFilter);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
    {
        Console::WriteLine("The 29-bit acceptance filter of the hardware represented by the handle {0} was successfully set to {1:X16}h.", channel, acceptanceFilter);
    }

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api::Uninitialize(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
}
See Also

Reference

Api Class
SetValue Overload
Peak.Can.Basic Namespace
PCAN Parameters
GetValue(PcanChannel, PcanParameter, UInt64)


Api.Uninitialize Method

ApiUninitialize Method

Uninitializes one or all PCAN Channels initialized by the methods Initialize and Initialize.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus Uninitialize(
    PcanChannel channel
)
Public Shared Function Uninitialize (
    channel As PcanChannel
) As PcanStatus
public:
static PcanStatus Uninitialize(
    PcanChannel channel
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • Initialize: Indicates that the channel cannot be terminated because it was not found in the list of reserved Channels of the calling application.
  • IllegalHandle: Indicates that the channel contains an invalid value.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

This method can be used to achieve two different goals:

  • To release a single Channel: Passing the handle of a PCAN Channel initialized before as parameter (see Initialize / Initialize) terminates the connection with that Chanel. If the given channel cannot be found, an error is returned.
  • To release all connected Channels: Passing the Channel None as parameter, terminates all connections, that have been issued and maintained by the calling application. This operation does not generate errors if no Channels were found and terminated.

Important note Important

When a connection is terminated, the underlying hardware's transmit queue will not be immediately discarded. The API will wait some time before terminating, so that the hardware has time to send (or try to send) the unsent messages. When this time runs out (about 500 milliseconds), the rest of the messages in the queue (if any) are discarded.

Example

  1. The following example shows the single release process using the USB interface (first PCAN-USB hardware).

    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.

    C#
    VB
    C++
    Copy
    PcanChannel channel = PcanChannel.Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
//
PcanStatus result = Api.Initialize(channel, (BitrateFD)BitrateFD.BitrateSaeJ2284_4);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message is shown
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");
    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
    Dim channel As PcanChannel = PcanChannel.Usb01

' The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
'
Dim result As PcanStatus = Api.Initialize(channel, CType(BitrateFD.BitrateSaeJ2284_4, BitrateFD))
If (result <> PcanStatus.OK) Then
    ' An error occurred
    '
    Dim errorText As String = String.Empty
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message is shown
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")
    ' The connection to the hardware Is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If (result <> PcanStatus.OK) Then
        ' An error occurred
        '
        Dim errorText As String = String.Empty
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
    String^ errorText;
PcanChannel channel = PcanChannel::Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
//
PcanStatus result = Api::Initialize(channel, (BitrateFD^)BitrateFD::BitrateSaeJ2284_4);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message is shown
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);
    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api::Uninitialize(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
}

  2. The following example shows the multiple release process using the USB interface (first and second PCAN-USB hardware).

    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.

    C#
    VB
    C++
    Copy
    PcanChannel[] channels = new PcanChannel[] { PcanChannel.Usb01, PcanChannel.Usb02 };

// The hardware represented by the given handles are initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
for (int i = 0; i < channels.Length; i++)
{
    PcanStatus result = Api.Initialize(channels[i], Bitrate.Pcan500);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine($"Error initializing the Channel {channels[i]}: {errorText}");
        break;
    }
    else
        // A success message is shown
        //
        Console.WriteLine($"The hardware represented by the handle {channels[i]} was successfully initialized.");
}

// Any active hardware connection is finalized when no more needed
//
Api.Uninitialize(PcanChannel.None);
Console.WriteLine("All active connections were terminated.");
    Dim result As PcanStatus
Dim channels As PcanChannel() = New PcanChannel() {PcanChannel.Usb01, PcanChannel.Usb02}

' The hardware represented by the given handles are initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
'
For Each channel As PcanChannel In channels

    result = Api.Initialize(channel, Bitrate.Pcan500)
    If (result <> PcanStatus.OK) Then
        ' An error occurred
        '
        Dim errorText As String = String.Empty
        Api.GetErrorText(result, errorText)
        Console.WriteLine($"Error initializing the Channel {channel}: {errorText}")
    Else
        ' A success message is shown
        '
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
Next

' Any active hardware connection Is finalized when no more needed
'
Api.Uninitialize(PcanChannel.None)
Console.WriteLine("All active connections were terminated.")
    String^ errorText;
PcanStatus result;
array<PcanChannel^>^ channels = gcnew  array<PcanChannel^> { PcanChannel::Usb01, PcanChannel::Usb02 };

// The hardware represented by the given handles are initialized with 500 kBit/s bit rate (BTR0/BTR1 0x001C)
//
for (int i = 0; i < channels->Length; i++)
{
    result = Api::Initialize(*channels[i], Bitrate::Pcan500);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine("Error initializing the Channel {0}: {1}", channels[i], errorText);
        break;
    }
    else
        // A success message is shown
        //
        Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channels[i]);
}

// Any active hardware connection is finalized when no more needed
//
Api::Uninitialize(PcanChannel::None);
Console::WriteLine("All active connections were terminated.");
See Also

Reference

Api Class
Peak.Can.Basic Namespace
Initialize
Initialize


Api.Write Method

ApiWrite Method

Places a CAN message in the transmit queue of a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static PcanStatus Write(
    PcanChannel channel,
    PcanMessage msg
)
Public Shared Function Write (
    channel As PcanChannel,
    msg As PcanMessage
) As PcanStatus
public:
static PcanStatus Write(
    PcanChannel channel,
    PcanMessage^ msg
)

Parameters

channel PcanChannel
The handle of a PCAN Channel.
msg PcanMessage
Represents the CAN message to be transmitted through the channel.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • IllegalHandle: Indicates that the channel contains an invalid value.
  • Initialize: Indicates that the channel cannot be used because it was not found in the list of reserved Channels of the calling application.
  • InvalidOperation: Indicates that the channel was not initialized using the Initialize method.
  • InvalidValue: Indicates that one or more of the values passed to the method are invalid.
  • BusOff: Indicates a bus error within the given PCAN Channel. The CAN controller is in bus-off state.
  • TransmitQueueFull: Indicates that the transmit queue of the Channel is full.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

If a bus-off error occur, an application cannot use the channel to communicate anymore, until the CAN controller is reset. Consider using the BusOffAutoReset parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset bus errors like BusOff, BusPassive, and others:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter HardResetStatus: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

Example

The following example shows the use of the Write(PcanChannel, PcanMessage) method using the USB interface (first PCAN-USB hardware). A Channel is initialized and used to write 10 messages.

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.

C#
VB
C++
Copy
PcanChannel channel = PcanChannel.Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
//
PcanStatus result = Api.Initialize(channel, (BitrateFD)BitrateFD.BitrateSaeJ2284_4);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.");

    // Define the message to send
    //
    PcanMessage msg = new PcanMessage(0x100, MessageType.Extended | MessageType.FlexibleDataRate | MessageType.BitRateSwitch, 15, null, true);
    for (int i = 0; i < msg.Length; i++)
        msg.Data[i] = (byte)(64 - i);

    // Send 10 messages
    //
    for (byte i = 1; i <= 10; i++)
    {
        result = Api.Write(channel, msg);
        if (result != PcanStatus.OK)
        {
            // An error occurred
            //
            Api.GetErrorText(result, out var errorText);
            Console.WriteLine(errorText);
            Console.WriteLine($"Application terminated.");
            return;
        }
        else
        {
            // A success message on reset is shown.
            //
            Console.WriteLine($"Message {i} was successfully sent.");
        }
    }

    // Give the driver some time to send the messages...
    //
    System.Threading.Thread.Sleep(50);

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api.Uninitialize(channel);
    if (result != PcanStatus.OK)
    {
        // An error occurred
        //
        Api.GetErrorText(result, out var errorText);
        Console.WriteLine(errorText);
    }
    else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.");
}
Dim channel As PcanChannel = PcanChannel.Usb01

' The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
'
Dim result As PcanStatus = Api.Initialize(channel, CType(BitrateFD.BitrateSaeJ2284_4, BitrateFD))
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
    Api.GetErrorText(result, errorText)
    Console.WriteLine(errorText)
Else
    ' A success message on connection is shown.
    '
    Console.WriteLine($"The hardware represented by the handle {channel} was successfully initialized.")

    ' Define the message to send
    '
    Dim msg As PcanMessage = New PcanMessage(&H100, MessageType.Extended Or MessageType.FlexibleDataRate Or MessageType.BitRateSwitch, 15, Nothing, True)
    For i As Integer = 0 To msg.Length - 1
        msg.Data(i) = 64 - i
    Next

    ' Send 10 messages
    '
    For i As Byte = 1 To 10
        result = Api.Write(channel, msg)
        If result <> PcanStatus.OK Then
            Api.GetErrorText(result, errorText)
            Console.WriteLine(errorText)
            Console.WriteLine($"Application terminated.")
            Return
        Else
            ' A success message on reset is shown.
            '
            Console.WriteLine($"Message {i} was successfully sent.")
        End If
    Next

    ' Give the driver some time to send the messages...
    '
    Threading.Thread.Sleep(50)

    ' The connection to the hardware is finalized when it is no longer needed
    '
    result = Api.Uninitialize(channel)
    If result <> PcanStatus.OK Then
        Api.GetErrorText(result, errorText)
        Console.WriteLine(errorText)
    Else
        Console.WriteLine($"The hardware represented by the handle {channel} was successfully finalized.")
    End If
End If
String^ errorText;
PcanChannel channel = PcanChannel::Usb01;

// The hardware represented by the given handle is initialized with 500 kBit/s nominal and 4 MBit/s data bit rate (SAE J2284-4)
//
PcanStatus result = Api::Initialize(channel, (BitrateFD^)BitrateFD::BitrateSaeJ2284_4);
if (result != PcanStatus::OK)
{
    // An error occurred
    //
    Api::GetErrorText(result, errorText);
    Console::WriteLine(errorText);
}
else
{
    // A success message on connection is shown.
    //
    Console::WriteLine("The hardware represented by the handle {0} was successfully initialized.", channel);

    // Define the message to send
    //
    PcanMessage^ msg = gcnew PcanMessage(0x100, MessageType::Extended | MessageType::FlexibleDataRate | MessageType::BitRateSwitch, 15, nullptr, true);
    for (int i = 0; i < msg->Length; i++)
        msg->Data[i] = (Byte)(64 - i);

    // Send 10 messages
    //
    for (Byte i = 1; i <= 10; i++)
    {
        result = Api::Write(channel, msg);
        if (result != PcanStatus::OK)
        {
            // An error occurred
            //
            Api::GetErrorText(result, errorText);
            Console::WriteLine(errorText);
            Console::WriteLine("Application terminated.");
            return;
        }
        else
        {
            // A success message on reset is shown.
            //
            Console::WriteLine("Message {0} was successfully sent.", i);
        }
    }

    // Give the driver some time to send the messages...
    //
    System::Threading::Thread::Sleep(50);

    // The connection to the hardware is finalized when it is no longer needed
    //
    result = Api::Uninitialize(channel);
    if (result != PcanStatus::OK)
    {
        // An error occurred
        //
        Api::GetErrorText(result, errorText);
        Console::WriteLine(errorText);
    }
    else
        Console::WriteLine("The hardware represented by the handle {0} was successfully finalized.", channel);
}
See Also

Reference

Api Class
Peak.Can.Basic Namespace
Initialize
Read


Bitrate Enumeration

Represents a PCAN bit rate register value.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum Bitrate
Public Enumeration Bitrate
public enum class Bitrate
Members
Member name | Value | Description
Pcan1000 | 20 | 1 MBit/s.
Pcan800 | 22 | 800 KBit/s.
Pcan500 | 28 | 500 kBit/s.
Pcan250 | 284 | 250 kBit/s.
Pcan125 | 796 | 125 kBit/s.
Pcan47 | 5,140 | 47,619 KBit/s.
Pcan100 | 17,199 | 100 kBit/s.
Pcan50 | 18,223 | 50 kBit/s.
Pcan20 | 21,295 | 20 kBit/s.
Pcan10 | 26,415 | 10 kBit/s.
Pcan5 | 32,639 | 5 kBit/s.
Pcan83 | 34,091 | 83,333 KBit/s.
Pcan33 | 35,631 | 33,333 KBit/s.
Pcan95 | 49,998 | 95,238 KBit/s.
See Also

Reference

Peak.Can.Basic Namespace
Initialize


BitrateFD Class

Defines the different configuration parameters used to create a Flexible Data rate string for FD capable PCAN Channels initialization.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicBitrateFD

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public sealed class BitrateFD
Public NotInheritable Class BitrateFD
public ref class BitrateFD sealed

The BitrateFD type exposes the following members.

Constructors
 | Name | Description
Public method | BitrateFD(String) | Initializes an instance of a BitrateFD object.
Public method | BitrateFD(BitrateFDClockFrequency, BitrateFDBitrateSegment, BitrateFDBitrateSegment) | Initializes an instance of a BitrateFD object.
Public method | BitrateFD(BitrateFDClockFrequency, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32) | Initializes an instance of a BitrateFD object.
Top
Properties
 | Name | Description
Public property | Data | Gets or sets the configuration values for the data part of the CAN FD bit rate.
Public property | Frequency | Gets or sets the clock frequency used by this CAN FD bit rate.
Public property | Nominal | Gets or sets the configuration values for the nominal part of the CAN FD bit rate.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns a string that represents a parameterized CAN FD bit rate. (Overrides ObjectToString)
Top
Operators
Name | Description
(String to BitrateFD) | Explicitly converts a parameterized CAN FD bit rate string in an equivalent BitrateFD object.
(BitrateFD to String) | Implicitly converts a BitrateFD instance into its CAN FD bit rate string representation.
Top
Fields
Name | Description
BitrateSaeJ2284_4 | A string representing the bit rate FD SAE J2284-4: Nominal: 500 kBit/s | Data: 2 MBit/s.
BitrateSaeJ2284_5 | A string representing the bit rate FD SAE J2284-5: Nominal: 500 kBit/s | Data: 5 MBit/s.
Top
See Also

Reference

Peak.Can.Basic Namespace


BitrateFD Constructor

Overload List
 | Name | Description
Public method | BitrateFD(String) | Initializes an instance of a BitrateFD object.
Public method | BitrateFD(BitrateFDClockFrequency, BitrateFDBitrateSegment, BitrateFDBitrateSegment) | Initializes an instance of a BitrateFD object.
Public method | BitrateFD(BitrateFDClockFrequency, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32) | Initializes an instance of a BitrateFD object.
Top
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD(String) Constructor

Initializes an instance of a BitrateFD object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public BitrateFD(
    string fdBitrateValues
)
Public Sub New (
    fdBitrateValues As String
)
public:
BitrateFD(
    String^ fdBitrateValues
)

Parameters

fdBitrateValues String
A parameterized string representing a CAN FD bit rate.
See Also

Reference

BitrateFD Class
BitrateFD Overload
Peak.Can.Basic Namespace


BitrateFD(BitrateFD.ClockFrequency, BitrateFD.BitrateSegment, BitrateFD.BitrateSegment) Constructor

BitrateFD(BitrateFDClockFrequency, BitrateFDBitrateSegment, BitrateFDBitrateSegment) Constructor

Initializes an instance of a BitrateFD object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public BitrateFD(
    BitrateFDClockFrequency frequency,
    BitrateFDBitrateSegment nominal,
    BitrateFDBitrateSegment data
)
Public Sub New (
    frequency As BitrateFDClockFrequency,
    nominal As BitrateFDBitrateSegment,
    data As BitrateFDBitrateSegment
)
public:
BitrateFD(
    BitrateFDClockFrequency frequency,
    BitrateFDBitrateSegment nominal,
    BitrateFDBitrateSegment data
)

Parameters

frequency BitrateFDClockFrequency
The clock frequency to use for the CAN FD bit rate.
nominal BitrateFDBitrateSegment
A value describing the nominal part of the CAN FD bit rate.
data BitrateFDBitrateSegment
A value describing the data part of the CAN FD bit rate.
See Also

Reference

BitrateFD Class
BitrateFD Overload
Peak.Can.Basic Namespace


BitrateFD(BitrateFD.ClockFrequency, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32) Constructor

BitrateFD(BitrateFDClockFrequency, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32) Constructor

Initializes an instance of a BitrateFD object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public BitrateFD(
    BitrateFDClockFrequency frequency = BitrateFDClockFrequency.Mhz_80,
    uint nominalBrp = 0,
    uint nominalTseg1 = 0,
    uint nominalTseg2 = 0,
    uint nominalSjw = 0,
    uint dataBrp = 0,
    uint datatTseg1 = 0,
    uint dataTseg2 = 0,
    uint dataSjw = 0
)
Public Sub New (
    Optional frequency As BitrateFDClockFrequency = BitrateFDClockFrequency.Mhz_80,
    Optional nominalBrp As UInteger = 0,
    Optional nominalTseg1 As UInteger = 0,
    Optional nominalTseg2 As UInteger = 0,
    Optional nominalSjw As UInteger = 0,
    Optional dataBrp As UInteger = 0,
    Optional datatTseg1 As UInteger = 0,
    Optional dataTseg2 As UInteger = 0,
    Optional dataSjw As UInteger = 0
)
public:
BitrateFD(
    BitrateFDClockFrequency frequency = BitrateFDClockFrequency::Mhz_80,
    unsigned int nominalBrp = 0,
    unsigned int nominalTseg1 = 0,
    unsigned int nominalTseg2 = 0,
    unsigned int nominalSjw = 0,
    unsigned int dataBrp = 0,
    unsigned int datatTseg1 = 0,
    unsigned int dataTseg2 = 0,
    unsigned int dataSjw = 0
)

Parameters

frequency BitrateFDClockFrequency (Optional)
The clock frequency to use for the CAN FD bit rate.
nominalBrp UInt32 (Optional)
The bit rate prescaler value (BRP) of the nominal part of the CAN FD bit rate.
nominalTseg1 UInt32 (Optional)
The time segment 1 value (TSEG1) of the nominal part of the CAN FD bit rate.
nominalTseg2 UInt32 (Optional)
The time segment 2 value (TSEG2) of the nominal part of the CAN FD bit rate.
nominalSjw UInt32 (Optional)
the resynchronization jump value (SJW) of the nominal part of the CAN FD bit rate.
dataBrp UInt32 (Optional)
The bit rate prescaler value (BRP) of the data part of the CAN FD bit rate.
datatTseg1 UInt32 (Optional)
The time segment 1 value (TSEG1) of the data part of the CAN FD bit rate.
dataTseg2 UInt32 (Optional)
The time segment 2 value (TSEG2) of the data part of the CAN FD bit rate.
dataSjw UInt32 (Optional)
the resynchronization jump width value (SJW) of the data part of the CAN FD bit rate.
See Also

Reference

BitrateFD Class
BitrateFD Overload
Peak.Can.Basic Namespace


BitrateFD Properties

The BitrateFD type exposes the following members.

Properties
 | Name | Description
Public property | Data | Gets or sets the configuration values for the data part of the CAN FD bit rate.
Public property | Frequency | Gets or sets the clock frequency used by this CAN FD bit rate.
Public property | Nominal | Gets or sets the configuration values for the nominal part of the CAN FD bit rate.
Top
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD.Data Property

BitrateFDData Property

Gets or sets the configuration values for the data part of the CAN FD bit rate.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public BitrateFDBitrateSegment Data { get; set; }
Public Property Data As BitrateFDBitrateSegment
    Get
    Set
public:
property BitrateFDBitrateSegment Data {
    BitrateFDBitrateSegment get ();
    void set (BitrateFDBitrateSegment value);
}

Property Value

BitrateFDBitrateSegment
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD.Frequency Property

BitrateFDFrequency Property

Gets or sets the clock frequency used by this CAN FD bit rate.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public BitrateFDClockFrequency Frequency { get; set; }
Public Property Frequency As BitrateFDClockFrequency
    Get
    Set
public:
property BitrateFDClockFrequency Frequency {
    BitrateFDClockFrequency get ();
    void set (BitrateFDClockFrequency value);
}

Property Value

BitrateFDClockFrequency
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD.Nominal Property

BitrateFDNominal Property

Gets or sets the configuration values for the nominal part of the CAN FD bit rate.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public BitrateFDBitrateSegment Nominal { get; set; }
Public Property Nominal As BitrateFDBitrateSegment
    Get
    Set
public:
property BitrateFDBitrateSegment Nominal {
    BitrateFDBitrateSegment get ();
    void set (BitrateFDBitrateSegment value);
}

Property Value

BitrateFDBitrateSegment
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD Methods

The BitrateFD type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns a string that represents a parameterized CAN FD bit rate. (Overrides ObjectToString)
Top
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD.ToString Method

BitrateFDToString Method

Returns a string that represents a parameterized CAN FD bit rate.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override

Return Value

String
A parameterized CAN FD bit rate string.
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD Type Conversions

The BitrateFD type exposes the following members.

Operators
Name | Description
(String to BitrateFD) | Explicitly converts a parameterized CAN FD bit rate string in an equivalent BitrateFD object.
(BitrateFD to String) | Implicitly converts a BitrateFD instance into its CAN FD bit rate string representation.
Top
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD Explicit Conversion (String to BitrateFD)

BitrateFD Conversion (String to BitrateFD)

Explicitly converts a parameterized CAN FD bit rate string in an equivalent BitrateFD object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static explicit operator BitrateFD (
    string bitrate
)
Public Shared Narrowing Operator CType (
    bitrate As String
) As BitrateFD
static explicit operator BitrateFD^ (
    String^ bitrate
)

Parameters

bitrate String
The CAN FD bit rate string to be converted.

Return Value

BitrateFD
A BitrateFD object representing the given CAN FD bit rate string.
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD Implicit Conversion (BitrateFD to String)

BitrateFD Conversion (BitrateFD to String)

Implicitly converts a BitrateFD instance into its CAN FD bit rate string representation.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static implicit operator string (
    BitrateFD bitrate
)
Public Shared Widening Operator CType (
    bitrate As BitrateFD
) As String
static implicit operator String^ (
    BitrateFD^ bitrate
)

Parameters

bitrate BitrateFD
BitrateFD value to be converted.

Return Value

String
A string representing the given BitrateFD value.
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD Fields

The BitrateFD type exposes the following members.

Fields
Name | Description
BitrateSaeJ2284_4 | A string representing the bit rate FD SAE J2284-4: Nominal: 500 kBit/s | Data: 2 MBit/s.
BitrateSaeJ2284_5 | A string representing the bit rate FD SAE J2284-5: Nominal: 500 kBit/s | Data: 5 MBit/s.
Top
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD.BitrateSaeJ2284_4 Field

BitrateFDBitrateSaeJ2284_4 Field

A string representing the bit rate FD SAE J2284-4: Nominal: 500 kBit/s | Data: 2 MBit/s.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string BitrateSaeJ2284_4 = "f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4"
Public Const BitrateSaeJ2284_4 As String = "f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4"
public:
literal String^ BitrateSaeJ2284_4 = "f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4"

Field Value

String
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD.BitrateSaeJ2284_5 Field

BitrateFDBitrateSaeJ2284_5 Field

A string representing the bit rate FD SAE J2284-5: Nominal: 500 kBit/s | Data: 5 MBit/s.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string BitrateSaeJ2284_5 = "f_clock=80000000,nom_brp=1,nom_tseg1=127,nom_tseg2=32,nom_sjw=32,data_brp=1,data_tseg1=11,data_tseg2=4,data_sjw=4"
Public Const BitrateSaeJ2284_5 As String = "f_clock=80000000,nom_brp=1,nom_tseg1=127,nom_tseg2=32,nom_sjw=32,data_brp=1,data_tseg1=11,data_tseg2=4,data_sjw=4"
public:
literal String^ BitrateSaeJ2284_5 = "f_clock=80000000,nom_brp=1,nom_tseg1=127,nom_tseg2=32,nom_sjw=32,data_brp=1,data_tseg1=11,data_tseg2=4,data_sjw=4"

Field Value

String
See Also

Reference

BitrateFD Class
Peak.Can.Basic Namespace


BitrateFD.BitrateSegment Structure

BitrateFDBitrateSegment Structure

Represents single bit rate parameters.
Inheritance Hierarchy
SystemObject
SystemValueType
Peak.Can.BasicBitrateFDBitrateSegment

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public struct BitrateSegment
Public Structure BitrateSegment
public value class BitrateSegment

The BitrateFDBitrateSegment type exposes the following members.

Properties
 | Name | Description
Public property | Brp | The bit rate prescaler.
Public property | Mode | The bit rate type.
Public property | Sjw | The resynchronization jump width.
Public property | Tseg1 | The time segment 1.
Public property | Tseg2 | The time segment 2.
Top
Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the parameterized bit rate string section for this instance. (Overrides ValueTypeToString)
Top
See Also

Reference

Peak.Can.Basic Namespace


BitrateSegment Properties

The BitrateFDBitrateSegment type exposes the following members.

Properties
 | Name | Description
Public property | Brp | The bit rate prescaler.
Public property | Mode | The bit rate type.
Public property | Sjw | The resynchronization jump width.
Public property | Tseg1 | The time segment 1.
Public property | Tseg2 | The time segment 2.
Top
See Also

Reference

BitrateFDBitrateSegment Structure
Peak.Can.Basic Namespace


BitrateFD.BitrateSegment.Brp Property

BitrateFDBitrateSegmentBrp Property

The bit rate prescaler.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint Brp { get; set; }
Public Property Brp As UInteger
    Get
    Set
public:
property unsigned int Brp {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

BitrateFDBitrateSegment Structure
Peak.Can.Basic Namespace


BitrateFD.BitrateSegment.Mode Property

BitrateFDBitrateSegmentMode Property

The bit rate type.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public BitrateFDBitrateType Mode { get; set; }
Public Property Mode As BitrateFDBitrateType
    Get
    Set
public:
property BitrateFDBitrateType Mode {
    BitrateFDBitrateType get ();
    void set (BitrateFDBitrateType value);
}

Property Value

BitrateFDBitrateType
See Also

Reference

BitrateFDBitrateSegment Structure
Peak.Can.Basic Namespace


BitrateFD.BitrateSegment.Sjw Property

BitrateFDBitrateSegmentSjw Property

The resynchronization jump width.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint Sjw { get; set; }
Public Property Sjw As UInteger
    Get
    Set
public:
property unsigned int Sjw {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

BitrateFDBitrateSegment Structure
Peak.Can.Basic Namespace


BitrateFD.BitrateSegment.Tseg1 Property

BitrateFDBitrateSegmentTseg1 Property

The time segment 1.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint Tseg1 { get; set; }
Public Property Tseg1 As UInteger
    Get
    Set
public:
property unsigned int Tseg1 {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

BitrateFDBitrateSegment Structure
Peak.Can.Basic Namespace


BitrateFD.BitrateSegment.Tseg2 Property

BitrateFDBitrateSegmentTseg2 Property

The time segment 2.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint Tseg2 { get; set; }
Public Property Tseg2 As UInteger
    Get
    Set
public:
property unsigned int Tseg2 {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

BitrateFDBitrateSegment Structure
Peak.Can.Basic Namespace


BitrateSegment Methods

The BitrateFDBitrateSegment type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the parameterized bit rate string section for this instance. (Overrides ValueTypeToString)
Top
See Also

Reference

BitrateFDBitrateSegment Structure
Peak.Can.Basic Namespace


BitrateFD.BitrateSegment.ToString Method

BitrateFDBitrateSegmentToString Method

Returns the parameterized bit rate string section for this instance.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override

Return Value

String
The nominal or data bit rate parameters, as a part of a CAN FD bit rate string.
See Also

Reference

BitrateFDBitrateSegment Structure
Peak.Can.Basic Namespace


BitrateFD.BitrateType Enumeration

BitrateFDBitrateType Enumeration

The bit rate representation.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum BitrateType
Public Enumeration BitrateType
public enum class BitrateType
Members
Member name | Value | Description
Default | 0 | Not set, default value.
ArbitrationPhase | 1 | The bit rate is described as CAN FD nominal bit-rate.
DataPhase | 2 | The bit rate is described as CAN FD data bit-rate.
See Also

Reference

Peak.Can.Basic Namespace


BitrateFD.ClockFrequency Enumeration

BitrateFDClockFrequency Enumeration

Represents the supported bit rate clock frequencies.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum ClockFrequency
Public Enumeration ClockFrequency
public enum class ClockFrequency
Members
Member name | Value | Description
Default | 0 | Not set, default value.
Mhz_08 | 8,000,000 | 8 Megahertz, used for SJA1000 only.
Mhz_20 | 20,000,000 | 20 Megahertz.
Mhz_24 | 24,000,000 | 24 Megahertz.
Mhz_30 | 30,000,000 | 30 Megahertz.
Mhz_40 | 40,000,000 | 40 Megahertz.
Mhz_60 | 60,000,000 | 60 Megahertz.
Mhz_80 | 80,000,000 | 80 Megahertz.
See Also

Reference

Peak.Can.Basic Namespace


Broadcast Class

Represents a CAN message that is written periodically.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicBroadcast

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public class Broadcast
Public Class Broadcast
public ref class Broadcast

The Broadcast type exposes the following members.

Constructors
 | Name | Description
Public method | Broadcast | Initializes a new Broadcast object.
Top
Properties
Name | Description
Public property | Active | Gets a value indicating if the CAN message associated to this object is currently being transmitted or not.
Public property | Counter | Gets a value that indicates the number of times the configured Message has been sent.
Public property Index Gets the position of this object within the periodic sending table.
Note Note
A value of -1 (0xFFFFFFFF) indicates, that this object is not registered.
Public property | Interval | Gets or sets the interval used to write the Message periodically.
Public property | Message | Gets or sets the CAN message to be written when the Interval expires.
Top
Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Overrides ObjectEquals(Object))
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ObjectGetHashCode)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ResetCounter | Sets the counter of transmitted messages to 0.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
Operators
Name | Description
Equality(Broadcast, Broadcast) | Checks if two Broadcast instances are equal.
Inequality(Broadcast, Broadcast) | Checks if two Broadcast instances are not equal.
Top
See Also

Reference

Peak.Can.Basic Namespace


Broadcast Constructor

Initializes a new Broadcast object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public Broadcast(
    PcanMessage message,
    int interval
)
Public Sub New (
    message As PcanMessage,
    interval As Integer
)
public:
Broadcast(
    PcanMessage^ message,
    int interval
)

Parameters

message PcanMessage
Represents the CAN message to be written when the given interval expires.
interval Int32
Represents the interval used to write the message periodically.
Exceptions
Exception | Condition
ArgumentNullException | The message parameter value is null. An object of type PcanMessage is required.
Remarks

After creating a Broadcast object, it must be registered using the AddBroadcast method. Unregistered objects can be recognized by checking their index. An unregistered Broadcast object has -1 (0xFFFFFFFF) as index value.

The registration process assign an object a valid index in the broadcast list, trigger it for the first time, and starts its interval timer.

Note Note
After a Broadcast object is registered, any change made to it is applied directly, this means, changes made to the Interval or the Message (the whole message or part of it), will be reflected when the next interval expires.
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast Properties

The Broadcast type exposes the following members.

Properties
Name | Description
Public property | Active | Gets a value indicating if the CAN message associated to this object is currently being transmitted or not.
Public property | Counter | Gets a value that indicates the number of times the configured Message has been sent.
Public property Index Gets the position of this object within the periodic sending table.
Note Note
A value of -1 (0xFFFFFFFF) indicates, that this object is not registered.
Public property | Interval | Gets or sets the interval used to write the Message periodically.
Public property | Message | Gets or sets the CAN message to be written when the Interval expires.
Top
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.Active Property

BroadcastActive Property

Gets a value indicating if the CAN message associated to this object is currently being transmitted or not.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool Active { get; set; }
Public Property Active As Boolean
    Get
    Set
public:
property bool Active {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.Counter Property

BroadcastCounter Property

Gets a value that indicates the number of times the configured Message has been sent.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int Counter { get; }
Public ReadOnly Property Counter As Integer
    Get
public:
property int Counter {
    int get ();
}

Property Value

Int32
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.Index Property

BroadcastIndex Property

Gets the position of this object within the periodic sending table.
Note Note
A value of -1 (0xFFFFFFFF) indicates, that this object is not registered.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int Index { get; }
Public ReadOnly Property Index As Integer
    Get
public:
property int Index {
    int get ();
}

Property Value

Int32
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.Interval Property

BroadcastInterval Property

Gets or sets the interval used to write the Message periodically.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int Interval { get; set; }
Public Property Interval As Integer
    Get
    Set
public:
property int Interval {
    int get ();
    void set (int value);
}

Property Value

Int32
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.Message Property

BroadcastMessage Property

Gets or sets the CAN message to be written when the Interval expires.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public PcanMessage Message { get; set; }
Public Property Message As PcanMessage
    Get
    Set
public:
property PcanMessage^ Message {
    PcanMessage^ get ();
    void set (PcanMessage^ value);
}

Property Value

PcanMessage
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast Methods

The Broadcast type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Overrides ObjectEquals(Object))
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Returns the hash code for this instance. (Overrides ObjectGetHashCode)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ResetCounter | Sets the counter of transmitted messages to 0.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.Equals Method

BroadcastEquals Method

Indicates whether this instance and a specified object are equal.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override

Parameters

obj Object
The object to compare with the current instance.

Return Value

Boolean
true if obj and this instance are the same type and represent the same value; otherwise, false.
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.GetHashCode Method

BroadcastGetHashCode Method

Returns the hash code for this instance.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override

Return Value

Int32
A 32-bit signed integer that is the hash code for this instance.
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.ResetCounter Method

BroadcastResetCounter Method

Sets the counter of transmitted messages to 0.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void ResetCounter()
Public Sub ResetCounter
public:
void ResetCounter()
Remarks
Each time the message associated to a Broadcast object is sent, causes its Counter to be incremented in 1.
Note Note
A message is considered "sent", when it is successfully enqueued for transmission by calling the native method Write. This includes cases where writing a message ends with a bus error, excepting the BusOff error.
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast Operators

The Broadcast type exposes the following members.

Operators
Name | Description
Equality(Broadcast, Broadcast) | Checks if two Broadcast instances are equal.
Inequality(Broadcast, Broadcast) | Checks if two Broadcast instances are not equal.
Top
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.Equality Operator

BroadcastEquality Operator

Checks if two Broadcast instances are equal.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static bool operator ==(
    Broadcast first,
    Broadcast second
)
Public Shared Operator = (
    first As Broadcast,
    second As Broadcast
) As Boolean
public:
static bool operator ==(
    Broadcast^ first,
    Broadcast^ second
)

Parameters

first Broadcast
The first operator of type Broadcast to be compared.
second Broadcast
The second operator of type Broadcast to be compared.

Return Value

Boolean
true if 'first' and 'second' are equal; otherwise, false.
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


Broadcast.Inequality Operator

BroadcastInequality Operator

Checks if two Broadcast instances are not equal.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static bool operator !=(
    Broadcast first,
    Broadcast second
)
Public Shared Operator <> (
    first As Broadcast,
    second As Broadcast
) As Boolean
public:
static bool operator !=(
    Broadcast^ first,
    Broadcast^ second
)

Parameters

first Broadcast
The first operator of type Broadcast to be compared.
second Broadcast
The second operator of type Broadcast to be compared.

Return Value

Boolean
true if 'first' and 'second' are not equal; otherwise, false.
See Also

Reference

Broadcast Class
Peak.Can.Basic Namespace


ChannelCondition Enumeration

Represents the connectivity condition of a PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum ChannelCondition
Public Enumeration ChannelCondition
public enum class ChannelCondition
Members
Member name | Value | Description
ChannelUnavailable | 0 | The PCAN Channel handle i.e. its associated hardware is not available.
ChannelAvailable | 1 | The hardware represented by the PCAN Channel is plugged-in, and valid to connect/initialize.
ChannelOccupied | 2 | The PCAN Channel handle is valid, and is currently being used.
ChannelPCanView | 3 | The PCAN Channel handle is currently being used by a PCAN-View application and is valid to connect.
See Also

Reference

Peak.Can.Basic Namespace


DataBytes Class

Represents an object that manages the Data field for any CAN or CAN FD message.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicDataBytes

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public class DataBytes
Public Class DataBytes
public ref class DataBytes

The DataBytes type exposes the following members.

Constructors
 | Name | Description
Public method | DataBytes(Byte) | Creates a DataBytes manager object.
Public method | DataBytes(Int32) | Creates a DataBytes manager object.
Top
Properties
 | Name | Description
Public property | Item | Access as data iterator.
Public property | MaxLength | The maximum length or count of bytes contained/managed in this DataBytes object.
Top
Methods
 | Name | Description
Public method | Clone | Returns a new copy of this instance with the same data values.
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | SetData | Replaces the content of the managed data bytes.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
Operators
Name | Description
(Byte to DataBytes) | Implicitly converts a byte array in a DataBytes object.
(DataBytes to Byte) | Implicitly converts a DataBytes object in a byte array.
Top
See Also

Reference

Peak.Can.Basic Namespace


DataBytes Constructor

Overload List
 | Name | Description
Public method | DataBytes(Byte) | Creates a DataBytes manager object.
Public method | DataBytes(Int32) | Creates a DataBytes manager object.
Top
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes(Byte[]) Constructor

DataBytes(Byte) Constructor

Creates a DataBytes manager object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public DataBytes(
    byte[] data
)
Public Sub New (
    data As Byte()
)
public:
DataBytes(
    array<unsigned char>^ data
)

Parameters

data Byte
A byte array to manage.
See Also

Reference

DataBytes Class
DataBytes Overload
Peak.Can.Basic Namespace


DataBytes(Int32) Constructor

Creates a DataBytes manager object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public DataBytes(
    int maxLength = 0
)
Public Sub New (
    Optional maxLength As Integer = 0
)
public:
DataBytes(
    int maxLength = 0
)

Parameters

maxLength Int32 (Optional)
Maximum length of the managed data.
See Also

Reference

DataBytes Class
DataBytes Overload
Peak.Can.Basic Namespace


DataBytes Properties

The DataBytes type exposes the following members.

Properties
 | Name | Description
Public property | Item | Access as data iterator.
Public property | MaxLength | The maximum length or count of bytes contained/managed in this DataBytes object.
Top
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes.Item Property

DataBytesItem Property

Access as data iterator.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public byte this[
    int i
] { get; set; }
Public Default Property Item (
    i As Integer
) As Byte
    Get
    Set
public:
property unsigned char default[int i] {
    unsigned char get (int i);
    void set (int i, unsigned char value);
}

Parameters

i Int32
The index of the value to retrieve.

Return Value

Byte
The value requested.
Exceptions
Exception | Condition
IndexOutOfRangeException | The index is outside its bounds.
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes.MaxLength Property

DataBytesMaxLength Property

The maximum length or count of bytes contained/managed in this DataBytes object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int MaxLength { get; }
Public ReadOnly Property MaxLength As Integer
    Get
public:
property int MaxLength {
    int get ();
}

Property Value

Int32
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes Methods

The DataBytes type exposes the following members.

Methods
 | Name | Description
Public method | Clone | Returns a new copy of this instance with the same data values.
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | SetData | Replaces the content of the managed data bytes.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes.Clone Method

DataBytesClone Method

Returns a new copy of this instance with the same data values.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public DataBytes Clone()
Public Function Clone As DataBytes
public:
DataBytes^ Clone()

Return Value

DataBytes
A copy of this DataBytes object.
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes.SetData Method

DataBytesSetData Method

Replaces the content of the managed data bytes.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void SetData(
    byte[] data,
    bool ignoreOverflow = false
)
Public Sub SetData (
    data As Byte(),
    Optional ignoreOverflow As Boolean = false
)
public:
void SetData(
    array<unsigned char>^ data,
    bool ignoreOverflow = false
)

Parameters

data Byte
The new data bytes.
ignoreOverflow Boolean (Optional)
When true, data is truncated, if its length is greater than MaxLength. Otherwise, an exception is thrown.
Exceptions
Exception | Condition
OverflowException | The length of the data passed to the method is greater than the maximum allowed (MaxLength).
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes Type Conversions

The DataBytes type exposes the following members.

Operators
Name | Description
(Byte to DataBytes) | Implicitly converts a byte array in a DataBytes object.
(DataBytes to Byte) | Implicitly converts a DataBytes object in a byte array.
Top
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes Implicit Conversion Operators

DataBytes Conversion Operators

Overload List
Name | Description
(Byte to DataBytes) | Implicitly converts a byte array in a DataBytes object.
(DataBytes to Byte) | Implicitly converts a DataBytes object in a byte array.
Top
See Also

Reference

DataBytes Class
Peak.Can.Basic Namespace


DataBytes Implicit Conversion (Byte[] to DataBytes)

DataBytes Conversion (Byte to DataBytes)

Implicitly converts a byte array in a DataBytes object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static implicit operator DataBytes (
    byte[] data
)
Public Shared Widening Operator CType (
    data As Byte()
) As DataBytes
static implicit operator DataBytes^ (
    array<unsigned char>^ data
)

Parameters

data Byte
A byte array.

Return Value

DataBytes
A DataBytes object based on the given byte array.
See Also

Reference

DataBytes Class
Overload
Peak.Can.Basic Namespace


DataBytes Implicit Conversion (DataBytes to Byte[])

DataBytes Conversion (DataBytes to Byte)

Implicitly converts a DataBytes object in a byte array.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static implicit operator byte[] (
    DataBytes data
)
Public Shared Widening Operator CType (
    data As DataBytes
) As Byte()
static implicit operator array<unsigned char>^ (
    DataBytes^ data
)

Parameters

data DataBytes
A DataBytes object.

Return Value

Byte
A byte array based on the given DataBytes.
See Also

Reference

DataBytes Class
Overload
Peak.Can.Basic Namespace


FilterBehavior Enumeration

The operation that take place when a filtering criterion has a match.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum FilterBehavior
Public Enumeration FilterBehavior
public enum class FilterBehavior
Members
Member name | Value | Description
Include | 0 | If the filter matches, the message is enqueued.
Exclude | 1 | If the filter matches, the message is ignored.
See Also

Reference

Peak.Can.Basic Namespace


FilterData Enumeration

The kind of information used for filtering messages.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum FilterData
Public Enumeration FilterData
public enum class FilterData
Members
Member name | Value | Description
SingleId | 0 | The ID of a message is verified to be a specific one.
IdRange | 1 | The ID of a message is verified to be in a specific ID range [from, to].
MaskAndCode | 2 | The ID of a message is verified to comply with a mask/code filter operation.
MessageType | 3 | The message is verified to be of a specific CAN type (see MessageType).
See Also

Reference

Peak.Can.Basic Namespace


FilteringCriterion Structure

Represents a criterion for filtering CAN messages.
Inheritance Hierarchy
SystemObject
SystemValueType
Peak.Can.BasicFilteringCriterion

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public struct FilteringCriterion
Public Structure FilteringCriterion
public value class FilteringCriterion

The FilteringCriterion type exposes the following members.

Constructors
 | Name | Description
Public method | FilteringCriterion(MessageType, FilterBehavior) | Initializes a filtering criterion for checking the type of a CAN message.
Public method | FilteringCriterion(UInt32, FilterMode, FilterBehavior) | Initializes a filtering criterion for a CAN messages using an specific identifier.
Public method | FilteringCriterion(UInt32, UInt32, FilterMode, Boolean, FilterBehavior) | Initializes a filtering criterion for accepting a range of CAN identifiers, or for matching a mask/code acceptance value filtering.
Top
Properties
 | Name | Description
Public property | AcceptanceCode | Indicates the value of the acceptance code of an acceptance mask/code pair (MaskAndCode).
Public property | AcceptanceMask | Indicates the value of the acceptance mask of an acceptance mask/code pair (MaskAndCode).
Public property | Behavior | Indicates the operation to perform when a CAN message matches this criterion.
Public property | FrameType | Indicates a CAN frame type flags value (MessageType).
Public property | FromId | Indicates the begin of a message id range (IdRange).
Public property | Kind | Indicates the CAN message related data used for filtering.
Public property | Mode | Indicates the type of CAN identifier used for verification (not used when Kind equals MessageType).
Public property | SingleId | Indicates a single CAN identifier (SingleId).
Public property | ToId | Indicates the end of a message id range (IdRange).
Top
Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object))
Public method | GetHashCode | Calculates the hash code for this instance. (Overrides ValueTypeGetHashCode)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | SetIdRange | Configures this instance to do CAN identifier range filtering.
Public method | SetMaskAndCode | Configures this instance for using a mask/code acceptance values filtering
Public method | SetMessageType | Configures this instance to do a CAN message type filtering.
Public method | SetSingleId | Configures this instance to do single CAN identifier filtering.
Public method | ToString | Converts the value of this instance to its equivalent string representation. (Overrides ValueTypeToString)
Top
Operators
Name | Description
Equality(FilteringCriterion, FilteringCriterion) | Checks if two FilteringCriterion instances are equal.
Inequality(FilteringCriterion, FilteringCriterion) | Checks if two FilteringCriterion instances are not equal.
Top
See Also

Reference

Peak.Can.Basic Namespace


FilteringCriterion Constructor

Overload List
 | Name | Description
Public method | FilteringCriterion(MessageType, FilterBehavior) | Initializes a filtering criterion for checking the type of a CAN message.
Public method | FilteringCriterion(UInt32, FilterMode, FilterBehavior) | Initializes a filtering criterion for a CAN messages using an specific identifier.
Public method | FilteringCriterion(UInt32, UInt32, FilterMode, Boolean, FilterBehavior) | Initializes a filtering criterion for accepting a range of CAN identifiers, or for matching a mask/code acceptance value filtering.
Top
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion(MessageType, FilterBehavior) Constructor

Initializes a filtering criterion for checking the type of a CAN message.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public FilteringCriterion(
    MessageType messageTypeFlags,
    FilterBehavior behavior = FilterBehavior.Include
)
Public Sub New (
    messageTypeFlags As MessageType,
    Optional behavior As FilterBehavior = FilterBehavior.Include
)
public:
FilteringCriterion(
    MessageType messageTypeFlags,
    FilterBehavior behavior = FilterBehavior::Include
)

Parameters

messageTypeFlags MessageType
A value indicating the allowed frame types.
Note Note
The value Standard has to be specified alone as a FilteringCriterion value, if standard messages are wanted to be discarded.
behavior FilterBehavior (Optional)
Indicates the operation to perform when a CAN message matches this criterion.
See Also

Reference

FilteringCriterion Structure
FilteringCriterion Overload
Peak.Can.Basic Namespace


FilteringCriterion(UInt32, FilterMode, FilterBehavior) Constructor

Initializes a filtering criterion for a CAN messages using an specific identifier.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public FilteringCriterion(
    uint singleId,
    FilterMode canMode = FilterMode.Standard,
    FilterBehavior behavior = FilterBehavior.Include
)
Public Sub New (
    singleId As UInteger,
    Optional canMode As FilterMode = FilterMode.Standard,
    Optional behavior As FilterBehavior = FilterBehavior.Include
)
public:
FilteringCriterion(
    unsigned int singleId,
    FilterMode canMode = FilterMode::Standard,
    FilterBehavior behavior = FilterBehavior::Include
)

Parameters

singleId UInt32
A value indicating the allowed CAN identifier.
canMode FilterMode (Optional)
A value indicating the filter mode used for CAN identifier verification.
behavior FilterBehavior (Optional)
Indicates the operation to perform when a CAN message matches this criterion.
See Also

Reference

FilteringCriterion Structure
FilteringCriterion Overload
Peak.Can.Basic Namespace


FilteringCriterion(UInt32, UInt32, FilterMode, Boolean, FilterBehavior) Constructor

Initializes a filtering criterion for accepting a range of CAN identifiers, or for matching a mask/code acceptance value filtering.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public FilteringCriterion(
    uint fromIdOrMask,
    uint toIdOrCode,
    FilterMode canMode = FilterMode.Standard,
    bool isIdRange = true,
    FilterBehavior behavior = FilterBehavior.Include
)
Public Sub New (
    fromIdOrMask As UInteger,
    toIdOrCode As UInteger,
    Optional canMode As FilterMode = FilterMode.Standard,
    Optional isIdRange As Boolean = true,
    Optional behavior As FilterBehavior = FilterBehavior.Include
)
public:
FilteringCriterion(
    unsigned int fromIdOrMask,
    unsigned int toIdOrCode,
    FilterMode canMode = FilterMode::Standard,
    bool isIdRange = true,
    FilterBehavior behavior = FilterBehavior::Include
)

Parameters

fromIdOrMask UInt32
For isIdRange equals to true, a value representing the message id used as the start of range. For isIdRange equals to false, a value representing an acceptance mask.
toIdOrCode UInt32
For isIdRange equals to true, a value representing the message id used as the end of range. For isIdRange equals to false, a value representing an acceptance code.
canMode FilterMode (Optional)
A value indicating the filter mode used for CAN identifier verification.
isIdRange Boolean (Optional)
A value indicating whether the parameters fromIdOrMask and toIdOrCode represent a range of CAN Identifiers, or acceptance mask and code values.
behavior FilterBehavior (Optional)
Indicates the operation to perform when a CAN message matches this criterion.
See Also

Reference

FilteringCriterion Structure
FilteringCriterion Overload
Peak.Can.Basic Namespace


FilteringCriterion Properties

The FilteringCriterion type exposes the following members.

Properties
 | Name | Description
Public property | AcceptanceCode | Indicates the value of the acceptance code of an acceptance mask/code pair (MaskAndCode).
Public property | AcceptanceMask | Indicates the value of the acceptance mask of an acceptance mask/code pair (MaskAndCode).
Public property | Behavior | Indicates the operation to perform when a CAN message matches this criterion.
Public property | FrameType | Indicates a CAN frame type flags value (MessageType).
Public property | FromId | Indicates the begin of a message id range (IdRange).
Public property | Kind | Indicates the CAN message related data used for filtering.
Public property | Mode | Indicates the type of CAN identifier used for verification (not used when Kind equals MessageType).
Public property | SingleId | Indicates a single CAN identifier (SingleId).
Public property | ToId | Indicates the end of a message id range (IdRange).
Top
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.AcceptanceCode Property

FilteringCriterionAcceptanceCode Property

Indicates the value of the acceptance code of an acceptance mask/code pair (MaskAndCode).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint AcceptanceCode { get; set; }
Public Property AcceptanceCode As UInteger
    Get
    Set
public:
property unsigned int AcceptanceCode {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.AcceptanceMask Property

FilteringCriterionAcceptanceMask Property

Indicates the value of the acceptance mask of an acceptance mask/code pair (MaskAndCode).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint AcceptanceMask { get; set; }
Public Property AcceptanceMask As UInteger
    Get
    Set
public:
property unsigned int AcceptanceMask {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.Behavior Property

FilteringCriterionBehavior Property

Indicates the operation to perform when a CAN message matches this criterion.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public FilterBehavior Behavior { get; set; }
Public Property Behavior As FilterBehavior
    Get
    Set
public:
property FilterBehavior Behavior {
    FilterBehavior get ();
    void set (FilterBehavior value);
}

Property Value

FilterBehavior
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.FrameType Property

FilteringCriterionFrameType Property

Indicates a CAN frame type flags value (MessageType).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public MessageType FrameType { get; set; }
Public Property FrameType As MessageType
    Get
    Set
public:
property MessageType FrameType {
    MessageType get ();
    void set (MessageType value);
}

Property Value

MessageType
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.FromId Property

FilteringCriterionFromId Property

Indicates the begin of a message id range (IdRange).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint FromId { get; set; }
Public Property FromId As UInteger
    Get
    Set
public:
property unsigned int FromId {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.Kind Property

FilteringCriterionKind Property

Indicates the CAN message related data used for filtering.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public FilterData Kind { get; }
Public ReadOnly Property Kind As FilterData
    Get
public:
property FilterData Kind {
    FilterData get ();
}

Property Value

FilterData
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.Mode Property

FilteringCriterionMode Property

Indicates the type of CAN identifier used for verification (not used when Kind equals MessageType).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public FilterMode Mode { get; }
Public ReadOnly Property Mode As FilterMode
    Get
public:
property FilterMode Mode {
    FilterMode get ();
}

Property Value

FilterMode
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.SingleId Property

FilteringCriterionSingleId Property

Indicates a single CAN identifier (SingleId).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint SingleId { get; set; }
Public Property SingleId As UInteger
    Get
    Set
public:
property unsigned int SingleId {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.ToId Property

FilteringCriterionToId Property

Indicates the end of a message id range (IdRange).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint ToId { get; set; }
Public Property ToId As UInteger
    Get
    Set
public:
property unsigned int ToId {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion Methods

The FilteringCriterion type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Overrides ValueTypeEquals(Object))
Public method | GetHashCode | Calculates the hash code for this instance. (Overrides ValueTypeGetHashCode)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | SetIdRange | Configures this instance to do CAN identifier range filtering.
Public method | SetMaskAndCode | Configures this instance for using a mask/code acceptance values filtering
Public method | SetMessageType | Configures this instance to do a CAN message type filtering.
Public method | SetSingleId | Configures this instance to do single CAN identifier filtering.
Public method | ToString | Converts the value of this instance to its equivalent string representation. (Overrides ValueTypeToString)
Top
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.Equals Method

FilteringCriterionEquals Method

Indicates whether this instance and a specified object are equal.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public override bool Equals(
    Object obj
)
Public Overrides Function Equals (
    obj As Object
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override

Parameters

obj Object
The object to compare with the current instance.

Return Value

Boolean
true if obj and this instance are the same type and represent the same value; otherwise, false.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.GetHashCode Method

FilteringCriterionGetHashCode Method

Calculates the hash code for this instance.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override

Return Value

Int32
A 32-bit signed integer that is the hash code for this instance.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.SetIdRange Method

FilteringCriterionSetIdRange Method

Configures this instance to do CAN identifier range filtering.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void SetIdRange(
    uint from,
    uint to,
    FilterMode mode = FilterMode.Standard,
    FilterBehavior behavior = FilterBehavior.Include
)
Public Sub SetIdRange (
    from As UInteger,
    to As UInteger,
    Optional mode As FilterMode = FilterMode.Standard,
    Optional behavior As FilterBehavior = FilterBehavior.Include
)
public:
void SetIdRange(
    unsigned int from,
    unsigned int to,
    FilterMode mode = FilterMode::Standard,
    FilterBehavior behavior = FilterBehavior::Include
)

Parameters

from UInt32
A value representing the CAN identifier used as the start of range.
to UInt32
A value representing the CAN identifier used as the end of range.
mode FilterMode (Optional)
A value indicating the filter mode used for CAN identifier verification.
behavior FilterBehavior (Optional)
Indicates the operation to perform when a CAN message matches this criterion.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.SetMaskAndCode Method

FilteringCriterionSetMaskAndCode Method

Configures this instance for using a mask/code acceptance values filtering

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void SetMaskAndCode(
    uint mask,
    uint code,
    FilterMode mode = FilterMode.Standard,
    FilterBehavior behavior = FilterBehavior.Include
)
Public Sub SetMaskAndCode (
    mask As UInteger,
    code As UInteger,
    Optional mode As FilterMode = FilterMode.Standard,
    Optional behavior As FilterBehavior = FilterBehavior.Include
)
public:
void SetMaskAndCode(
    unsigned int mask,
    unsigned int code,
    FilterMode mode = FilterMode::Standard,
    FilterBehavior behavior = FilterBehavior::Include
)

Parameters

mask UInt32
A value representing the acceptance mask
code UInt32
A value representing the acceptance code
mode FilterMode (Optional)
A value indicating the filter mode used for CAN identifier verification.
behavior FilterBehavior (Optional)
Indicates the operation to perform when a CAN message matches this criterion.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.SetMessageType Method

FilteringCriterionSetMessageType Method

Configures this instance to do a CAN message type filtering.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void SetMessageType(
    MessageType typesFlag,
    FilterBehavior behavior = FilterBehavior.Include
)
Public Sub SetMessageType (
    typesFlag As MessageType,
    Optional behavior As FilterBehavior = FilterBehavior.Include
)
public:
void SetMessageType(
    MessageType typesFlag,
    FilterBehavior behavior = FilterBehavior::Include
)

Parameters

typesFlag MessageType
A value indicating the allowed CAN message types.
Note Note
The value Standard has to be specified alone as a FilteringCriterion value, if standard messages are wanted to be discarded.
behavior FilterBehavior (Optional)
Indicates the operation to perform when a CAN message matches this criterion.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.SetSingleId Method

FilteringCriterionSetSingleId Method

Configures this instance to do single CAN identifier filtering.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void SetSingleId(
    uint id,
    FilterMode mode = FilterMode.Standard,
    FilterBehavior behavior = FilterBehavior.Include
)
Public Sub SetSingleId (
    id As UInteger,
    Optional mode As FilterMode = FilterMode.Standard,
    Optional behavior As FilterBehavior = FilterBehavior.Include
)
public:
void SetSingleId(
    unsigned int id,
    FilterMode mode = FilterMode::Standard,
    FilterBehavior behavior = FilterBehavior::Include
)

Parameters

id UInt32
A value indicating the allowed CAN identifier.
mode FilterMode (Optional)
A value indicating the filter mode used for CAN identifier verification.
behavior FilterBehavior (Optional)
Indicates the operation to perform when a CAN message matches this criterion.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.ToString Method

FilteringCriterionToString Method

Converts the value of this instance to its equivalent string representation.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override

Return Value

String
The string representation of the value of this instance.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion Operators

The FilteringCriterion type exposes the following members.

Operators
Name | Description
Equality(FilteringCriterion, FilteringCriterion) | Checks if two FilteringCriterion instances are equal.
Inequality(FilteringCriterion, FilteringCriterion) | Checks if two FilteringCriterion instances are not equal.
Top
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.Equality Operator

FilteringCriterionEquality Operator

Checks if two FilteringCriterion instances are equal.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static bool operator ==(
    FilteringCriterion first,
    FilteringCriterion second
)
Public Shared Operator = (
    first As FilteringCriterion,
    second As FilteringCriterion
) As Boolean
public:
static bool operator ==(
    FilteringCriterion first,
    FilteringCriterion second
)

Parameters

first FilteringCriterion
The first operator of type FilteringCriterion to be compared.
second FilteringCriterion
The second operator of type FilteringCriterion to be compared.

Return Value

Boolean
true if 'first' and 'second' are equal, false otherwise.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringCriterion.Inequality Operator

FilteringCriterionInequality Operator

Checks if two FilteringCriterion instances are not equal.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static bool operator !=(
    FilteringCriterion first,
    FilteringCriterion second
)
Public Shared Operator <> (
    first As FilteringCriterion,
    second As FilteringCriterion
) As Boolean
public:
static bool operator !=(
    FilteringCriterion first,
    FilteringCriterion second
)

Parameters

first FilteringCriterion
The first operator of type FilteringCriterion to be compared.
second FilteringCriterion
The second operator of type FilteringCriterion to be compared.

Return Value

Boolean
true if 'first' and 'second' are not equal, false otherwise.
See Also

Reference

FilteringCriterion Structure
Peak.Can.Basic Namespace


FilteringState Enumeration

State of verification of a message filter.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum FilteringState
Public Enumeration FilteringState
public enum class FilteringState
Members
Member name | Value | Description
PassForAll | 0 | Any message will be accepted.
BlockForAll | 1 | Any message will be rejected.
Inspect | 2 | Messages will be accepted or rejected as result of applying all registered filtering criteria.
See Also

Reference

Peak.Can.Basic Namespace


FilterMode Enumeration

Represents a PCAN filter mode.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum FilterMode
Public Enumeration FilterMode
public enum class FilterMode
Members
Member name | Value | Description
Standard | 0 | Mode is Standard (11-bit identifier).
Extended | 2 | Mode is Extended (29-bit identifier).
See Also

Reference

Peak.Can.Basic Namespace


LanDirection Enumeration

Represents the direction of the communication being currently carried out by a PCAN-LAN device.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
[FlagsAttribute]
public enum LanDirection
<FlagsAttribute>
Public Enumeration LanDirection
[FlagsAttribute]
public enum class LanDirection
Members
Member name | Value | Description
Read | 1 | The PCAN Channel is limited to incoming communication only.
Write | 2 | The PCAN Channel is limited to outgoing communication only.
ReadWrite | 3 | The PCAN Channel communication is bidirectional.
See Also

Reference

Peak.Can.Basic Namespace


MessageAvailableEventArgs Class

Represents the arguments for a MessageAvailable event.
Inheritance Hierarchy
SystemObject
SystemEventArgs
Peak.Can.BasicMessageAvailableEventArgs

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public class MessageAvailableEventArgs : EventArgs
Public Class MessageAvailableEventArgs
    Inherits EventArgs
public ref class MessageAvailableEventArgs : public EventArgs

The MessageAvailableEventArgs type exposes the following members.

Properties
 | Name | Description
Public property | QueueIndex | Represents the index of the queue in which the message was stored.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

Peak.Can.Basic Namespace


MessageAvailableEventArgs Properties

The MessageAvailableEventArgs type exposes the following members.

Properties
 | Name | Description
Public property | QueueIndex | Represents the index of the queue in which the message was stored.
Top
See Also

Reference

MessageAvailableEventArgs Class
Peak.Can.Basic Namespace


MessageAvailableEventArgs.QueueIndex Property

MessageAvailableEventArgsQueueIndex Property

Represents the index of the queue in which the message was stored.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int QueueIndex { get; }
Public ReadOnly Property QueueIndex As Integer
    Get
public:
property int QueueIndex {
    int get ();
}

Property Value

Int32
See Also

Reference

MessageAvailableEventArgs Class
Peak.Can.Basic Namespace


MessageAvailableEventArgs Methods

The MessageAvailableEventArgs type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

MessageAvailableEventArgs Class
Peak.Can.Basic Namespace


MessageType Enumeration

Represents the type of a CAN message.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
[FlagsAttribute]
public enum MessageType
<FlagsAttribute>
Public Enumeration MessageType
[FlagsAttribute]
public enum class MessageType
Members
Member name | Value | Description
Standard | 0 | The PCAN message is a CAN Standard Frame (11-bit identifier).
RemoteRequest | 1 | The PCAN message is a CAN Remote-Transfer-Request Frame.
Extended | 2 | The PCAN message is a CAN Extended Frame (29-bit identifier).
FlexibleDataRate | 4 | The PCAN message represents a FD frame in terms of CiA specifications.
BitRateSwitch | 8 | The PCAN message represents a FD bit rate switch (CAN data at a higher bit rate).
ErrorStateIndicator | 16 | The PCAN message represents a FD error state indicator(CAN FD transmitter was error active).
Echo | 32 | The PCAN message represents an echo CAN Frame ( self-received message).
Error | 64 | The PCAN message represents an error frame. See Error Frames for more information.
Status | 128 | The PCAN message represents a PCAN status frame. See Status Frames for more information.
Remarks
Several message types can be combined (bit mask value).
Important note Important
Messages with type FlexibleDataRate, BitRateSwitch, ErrorStateIndicator, or a combination of them, can only be sent/received when the Channel is initialized using the Initialize(PcanChannel, BitrateFD) method.
See Also

Reference

Peak.Can.Basic Namespace


OutputLanguage Enumeration

Represents the available translation languages for error codes.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum OutputLanguage
Public Enumeration OutputLanguage
public enum class OutputLanguage
Members
Member name | Value | Description
Neutral | 0 | Defaults to the operating system language. If it is not supported, English is used as default
German | 7 | Represents the German language.
English | 9 | Represents the English language.
Spanish | 10 | Represents the Spanish language.
French | 12 | Represents the French language.
Italian | 16 | Represents the Italian language.
Remarks
These values represent Primary language IDs as described by Microsoft.
See Also

Reference

Peak.Can.Basic Namespace


ParameterValue Class

Represents the allowed values for PCAN-Basic parameters configuration.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicParameterValue

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static class ParameterValue
Public NotInheritable Class ParameterValue
public ref class ParameterValue abstract sealed

The ParameterValue type exposes the following members.

Fields
Name | Description
MaxBufferedMessages | Represents the maximum amount of CAN messages that the receive queue of a Channel can hold.
MaxCanDataLength | Represents the maximum amount of data bytes a CAN message can have in classic CAN 2.0A/B mode.
MaxCanFdDataLength | Represents the maximum amount of data bytes a CAN message can have in CAN FD mode.
MaxExtendedIdValue | Represents the maximum value that a 29-bit CAN ID can have.
MaxHardwareNameLength | Represents the maximum length that the name of a device can have (32 characters + terminator).
MaxStandardIdValue | Represents the maximum value that a 11-bit CAN ID can have.
MaxVersionStringLength | Represents the maximum length that a version string can have (255 characters + terminator).
Top
Remarks

The values represented by this class and sub-classes are intended to be used:

  • for configuring filter, log, or trace parameters by using the SetValue method.
  • for configuring parameters that can be activated or deactivated by using the SetValue method.
  • for parsing and understanding values retrieved by the GetValue method.
  • for consulting range values, for instance, for preparing buffers to use with the GetValue method.
  • for creating a search string for the LookUpChannel method.
See Also

Reference

Peak.Can.Basic Namespace
ParameterValueActivation
ParameterValueFilter
ParameterValueLog
ParameterValueLookUp
ParameterValueTrace


ParameterValue Fields

The ParameterValue type exposes the following members.

Fields
Name | Description
MaxBufferedMessages | Represents the maximum amount of CAN messages that the receive queue of a Channel can hold.
MaxCanDataLength | Represents the maximum amount of data bytes a CAN message can have in classic CAN 2.0A/B mode.
MaxCanFdDataLength | Represents the maximum amount of data bytes a CAN message can have in CAN FD mode.
MaxExtendedIdValue | Represents the maximum value that a 29-bit CAN ID can have.
MaxHardwareNameLength | Represents the maximum length that the name of a device can have (32 characters + terminator).
MaxStandardIdValue | Represents the maximum value that a 11-bit CAN ID can have.
MaxVersionStringLength | Represents the maximum length that a version string can have (255 characters + terminator).
Top
See Also

Reference

ParameterValue Class
Peak.Can.Basic Namespace


ParameterValue.MaxBufferedMessages Field

ParameterValueMaxBufferedMessages Field

Represents the maximum amount of CAN messages that the receive queue of a Channel can hold.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MaxBufferedMessages = 32768
Public Const MaxBufferedMessages As Integer = 32768
public:
literal int MaxBufferedMessages = 32768

Field Value

Int32
Remarks
When the receive queue is not read on time and more messages are received than the maximum supported, a queue overrun occurs. This means, the newest message will be included into the queue while the oldest one is discarded.
See Also

Reference

ParameterValue Class
Peak.Can.Basic Namespace


ParameterValue.MaxCanDataLength Field

ParameterValueMaxCanDataLength Field

Represents the maximum amount of data bytes a CAN message can have in classic CAN 2.0A/B mode.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MaxCanDataLength = 8
Public Const MaxCanDataLength As Integer = 8
public:
literal int MaxCanDataLength = 8

Field Value

Int32
Remarks
Take care of the difference between data length and DLC (data length code). See DLC for more information.
See Also

Reference

ParameterValue Class
Peak.Can.Basic Namespace


ParameterValue.MaxCanFdDataLength Field

ParameterValueMaxCanFdDataLength Field

Represents the maximum amount of data bytes a CAN message can have in CAN FD mode.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MaxCanFdDataLength = 64
Public Const MaxCanFdDataLength As Integer = 64
public:
literal int MaxCanFdDataLength = 64

Field Value

Int32
Remarks
Take care of the difference between data length and DLC (data length code). See DLC for more information.
See Also

Reference

ParameterValue Class
Peak.Can.Basic Namespace


ParameterValue.MaxExtendedIdValue Field

ParameterValueMaxExtendedIdValue Field

Represents the maximum value that a 29-bit CAN ID can have.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MaxExtendedIdValue = 536870911
Public Const MaxExtendedIdValue As Integer = 536870911
public:
literal int MaxExtendedIdValue = 536870911

Field Value

Int32
See Also

Reference

ParameterValue Class
Peak.Can.Basic Namespace


ParameterValue.MaxHardwareNameLength Field

ParameterValueMaxHardwareNameLength Field

Represents the maximum length that the name of a device can have (32 characters + terminator).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MaxHardwareNameLength = 33
Public Const MaxHardwareNameLength As Integer = 33
public:
literal int MaxHardwareNameLength = 33

Field Value

Int32
See Also

Reference

ParameterValue Class
Peak.Can.Basic Namespace


ParameterValue.MaxStandardIdValue Field

ParameterValueMaxStandardIdValue Field

Represents the maximum value that a 11-bit CAN ID can have.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MaxStandardIdValue = 2047
Public Const MaxStandardIdValue As Integer = 2047
public:
literal int MaxStandardIdValue = 2047

Field Value

Int32
See Also

Reference

ParameterValue Class
Peak.Can.Basic Namespace


ParameterValue.MaxVersionStringLength Field

ParameterValueMaxVersionStringLength Field

Represents the maximum length that a version string can have (255 characters + terminator).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MaxVersionStringLength = 256
Public Const MaxVersionStringLength As Integer = 256
public:
literal int MaxVersionStringLength = 256

Field Value

Int32
See Also

Reference

ParameterValue Class
Peak.Can.Basic Namespace


ParameterValue.Activation Class

ParameterValueActivation Class

Represents values applicable to parameters, that can be activated or deactivated.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicParameterValueActivation

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static class Activation
Public NotInheritable Class Activation
public ref class Activation abstract sealed

The ParameterValueActivation type exposes the following members.

Fields
Name | Description
Off | Value for deactivation (Off status).
On | Value for activation (On status).
Top
See Also

Reference

Peak.Can.Basic Namespace
ParameterValueFilter
ParameterValueLog
ParameterValueLookUp
ParameterValueTrace


Activation Fields

The ParameterValueActivation type exposes the following members.

Fields
Name | Description
Off | Value for deactivation (Off status).
On | Value for activation (On status).
Top
See Also

Reference

ParameterValueActivation Class
Peak.Can.Basic Namespace


ParameterValue.Activation.Off Field

ParameterValueActivationOff Field

Value for deactivation (Off status).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint Off
Public Shared ReadOnly Off As UInteger
public:
static initonly unsigned int Off

Field Value

UInt32
See Also

Reference

ParameterValueActivation Class
Peak.Can.Basic Namespace


ParameterValue.Activation.On Field

ParameterValueActivationOn Field

Value for activation (On status).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint On
Public Shared ReadOnly On As UInteger
public:
static initonly unsigned int On

Field Value

UInt32
See Also

Reference

ParameterValueActivation Class
Peak.Can.Basic Namespace


ParameterValue.Filter Class

ParameterValueFilter Class

Represents values applicable to filter parameters.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicParameterValueFilter

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static class Filter
Public NotInheritable Class Filter
public ref class Filter abstract sealed

The ParameterValueFilter type exposes the following members.

Fields
Name | Description
Close | Represents a closed CAN filter. No messages can be received.
Custom | Represents a customized CAN filter. Only selected messages are received.
Open | Represents an opened CAN filter. Any message is received.
Top
See Also

Reference

Peak.Can.Basic Namespace
ParameterValueActivation
ParameterValueLog
ParameterValueLookUp
ParameterValueTrace


Filter Fields

The ParameterValueFilter type exposes the following members.

Fields
Name | Description
Close | Represents a closed CAN filter. No messages can be received.
Custom | Represents a customized CAN filter. Only selected messages are received.
Open | Represents an opened CAN filter. Any message is received.
Top
See Also

Reference

ParameterValueFilter Class
Peak.Can.Basic Namespace


ParameterValue.Filter.Close Field

ParameterValueFilterClose Field

Represents a closed CAN filter. No messages can be received.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint Close
Public Shared ReadOnly Close As UInteger
public:
static initonly unsigned int Close

Field Value

UInt32
See Also

Reference

ParameterValueFilter Class
Peak.Can.Basic Namespace


ParameterValue.Filter.Custom Field

ParameterValueFilterCustom Field

Represents a customized CAN filter. Only selected messages are received.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint Custom
Public Shared ReadOnly Custom As UInteger
public:
static initonly unsigned int Custom

Field Value

UInt32
See Also

Reference

ParameterValueFilter Class
Peak.Can.Basic Namespace


ParameterValue.Filter.Open Field

ParameterValueFilterOpen Field

Represents an opened CAN filter. Any message is received.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint Open
Public Shared ReadOnly Open As UInteger
public:
static initonly unsigned int Open

Field Value

UInt32
See Also

Reference

ParameterValueFilter Class
Peak.Can.Basic Namespace


ParameterValue.Log Class

ParameterValueLog Class

Represents values applicable to parameters related to data logging.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicParameterValueLog

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static class Log
Public NotInheritable Class Log
public ref class Log abstract sealed

The ParameterValueLog type exposes the following members.

Fields
Name | Description
All | Represents logging any available information.
Default | Represents default information logging, i.e. system exceptions or unknown errors.
FunctionEntries | Represents logging of API function entries.
FunctionExits | Represents logging of API function exits.
FunctionParameters | Represents logging of parameters passed to the API functions.
MessageReading | Represents logging of CAN messages received by the PCAN Channel.
MessageWriting | Represents logging of CAN messages sent from the PCAN Channel to the CAN bus.
Top
Remarks
These values are flags. They can be combined with each other.
See Also

Reference

Peak.Can.Basic Namespace
ParameterValueActivation
ParameterValueFilter
ParameterValueLookUp
ParameterValueTrace


Log Fields

The ParameterValueLog type exposes the following members.

Fields
Name | Description
All | Represents logging any available information.
Default | Represents default information logging, i.e. system exceptions or unknown errors.
FunctionEntries | Represents logging of API function entries.
FunctionExits | Represents logging of API function exits.
FunctionParameters | Represents logging of parameters passed to the API functions.
MessageReading | Represents logging of CAN messages received by the PCAN Channel.
MessageWriting | Represents logging of CAN messages sent from the PCAN Channel to the CAN bus.
Top
See Also

Reference

ParameterValueLog Class
Peak.Can.Basic Namespace


ParameterValue.Log.All Field

ParameterValueLogAll Field

Represents logging any available information.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint All
Public Shared ReadOnly All As UInteger
public:
static initonly unsigned int All

Field Value

UInt32
See Also

Reference

ParameterValueLog Class
Peak.Can.Basic Namespace


ParameterValue.Log.Default Field

ParameterValueLogDefault Field

Represents default information logging, i.e. system exceptions or unknown errors.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint Default
Public Shared ReadOnly Default As UInteger
public:
static initonly unsigned int Default

Field Value

UInt32
See Also

Reference

ParameterValueLog Class
Peak.Can.Basic Namespace


ParameterValue.Log.FunctionEntries Field

ParameterValueLogFunctionEntries Field

Represents logging of API function entries.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint FunctionEntries
Public Shared ReadOnly FunctionEntries As UInteger
public:
static initonly unsigned int FunctionEntries

Field Value

UInt32
See Also

Reference

ParameterValueLog Class
Peak.Can.Basic Namespace


ParameterValue.Log.FunctionExits Field

ParameterValueLogFunctionExits Field

Represents logging of API function exits.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint FunctionExits
Public Shared ReadOnly FunctionExits As UInteger
public:
static initonly unsigned int FunctionExits

Field Value

UInt32
See Also

Reference

ParameterValueLog Class
Peak.Can.Basic Namespace


ParameterValue.Log.FunctionParameters Field

ParameterValueLogFunctionParameters Field

Represents logging of parameters passed to the API functions.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint FunctionParameters
Public Shared ReadOnly FunctionParameters As UInteger
public:
static initonly unsigned int FunctionParameters

Field Value

UInt32
See Also

Reference

ParameterValueLog Class
Peak.Can.Basic Namespace


ParameterValue.Log.MessageReading Field

ParameterValueLogMessageReading Field

Represents logging of CAN messages received by the PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint MessageReading
Public Shared ReadOnly MessageReading As UInteger
public:
static initonly unsigned int MessageReading

Field Value

UInt32
See Also

Reference

ParameterValueLog Class
Peak.Can.Basic Namespace


ParameterValue.Log.MessageWriting Field

ParameterValueLogMessageWriting Field

Represents logging of CAN messages sent from the PCAN Channel to the CAN bus.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint MessageWriting
Public Shared ReadOnly MessageWriting As UInteger
public:
static initonly unsigned int MessageWriting

Field Value

UInt32
See Also

Reference

ParameterValueLog Class
Peak.Can.Basic Namespace


ParameterValue.LookUp Class

ParameterValueLookUp Class

Represents values applicable to parameters related to the LookUpChannel method.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicParameterValueLookUp

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static class LookUp
Public NotInheritable Class LookUp
public ref class LookUp abstract sealed

The ParameterValueLookUp type exposes the following members.

Methods
Name | Description
GetCriteriaString | Builds and retrieves a string to be used as search criteria with the ParameterValueLookUp method.
Top
Fields
Name | Description
ControllerNumber | Search parameter representing a CAN controller value.
DeviceId | Search parameter representing a device ID value.
DeviceType | Search parameter representing a PcanDevice value.
IpAddress | Search parameter representing an IP address value.
Top
Remarks

The field values represent the name of the parameters to use within the search string of the LookUpChannel method.

Use the GetCriteriaString to get the criteria string with the desired parameters.

See Also

Reference

Peak.Can.Basic Namespace
ParameterValueActivation
ParameterValueFilter
ParameterValueLog
ParameterValueTrace


LookUp Methods

The ParameterValueLookUp type exposes the following members.

Methods
Name | Description
GetCriteriaString | Builds and retrieves a string to be used as search criteria with the ParameterValueLookUp method.
Top
See Also

Reference

ParameterValueLookUp Class
Peak.Can.Basic Namespace


ParameterValue.LookUp.GetCriteriaString Method

ParameterValueLookUpGetCriteriaString Method

Builds and retrieves a string to be used as search criteria with the ParameterValueLookUp method.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static string GetCriteriaString(
    PcanDevice? deviceType,
    uint? deviceId,
    uint? controllerNumber,
    string ipAddress
)
Public Shared Function GetCriteriaString (
    deviceType As PcanDevice?,
    deviceId As UInteger?,
    controllerNumber As UInteger?,
    ipAddress As String
) As String
public:
static String^ GetCriteriaString(
    Nullable<PcanDevice> deviceType,
    Nullable<unsigned int> deviceId,
    Nullable<unsigned int> controllerNumber,
    String^ ipAddress
)

Parameters

deviceType Nullable PcanDevice
The type of device to match. It should be set to null in case the device type is not wanted as search criteria.
deviceId Nullable UInt32
The device ID to match. It should be set to null in case the device ID is not wanted as search criteria.
controllerNumber Nullable UInt32
The controller number to match. It should be set to null in case the controller number is not wanted as search criteria.
ipAddress String
The IP address to match. It should be set to null in case the IP address is not wanted as search criteria.

Return Value

String
A formatted string containing the search parameters.
Exceptions
Exception | Condition
PcanBasicException | The current operation ended with an unexpected result. Check the inner exception for more information.
Example

To see an example of this method, please refer to the example of the LookUpChannel method.

See Also

Reference

ParameterValueLookUp Class
Peak.Can.Basic Namespace
LookUpChannel


LookUp Fields

The ParameterValueLookUp type exposes the following members.

Fields
Name | Description
ControllerNumber | Search parameter representing a CAN controller value.
DeviceId | Search parameter representing a device ID value.
DeviceType | Search parameter representing a PcanDevice value.
IpAddress | Search parameter representing an IP address value.
Top
See Also

Reference

ParameterValueLookUp Class
Peak.Can.Basic Namespace


ParameterValue.LookUp.ControllerNumber Field

ParameterValueLookUpControllerNumber Field

Search parameter representing a CAN controller value.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly string ControllerNumber
Public Shared ReadOnly ControllerNumber As String
public:
static initonly String^ ControllerNumber

Field Value

String
Remarks

The controller number is a zero-based index value in range of a double word, [0 .. MaxValue]. It is represented as a number, using decimal or hexadecimal notation.

Example

controllernumber=1

controllernumber=0x1

controllernumber=1h

See Also

Reference

ParameterValueLookUp Class
Peak.Can.Basic Namespace


ParameterValue.LookUp.DeviceId Field

ParameterValueLookUpDeviceId Field

Search parameter representing a device ID value.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly string DeviceId
Public Shared ReadOnly DeviceId As String
public:
static initonly String^ DeviceId

Field Value

String
Remarks

The device ID is a value in range of a double word, [0 .. MaxValue]. It is represented as a number, using decimal or hexadecimal notation.

Example

deviceid=10

deviceid=0xA

deviceid=Ah

See Also

Reference

ParameterValueLookUp Class
Peak.Can.Basic Namespace


ParameterValue.LookUp.DeviceType Field

ParameterValueLookUpDeviceType Field

Search parameter representing a PcanDevice value.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly string DeviceType
Public Shared ReadOnly DeviceType As String
public:
static initonly String^ DeviceType

Field Value

String
Remarks

The PcanDevice value can be represented as follow:

  • As a number, using decimal or hexadecimal notation.
  • As the conversion of the DeviceType value to string.
Example

devicetype=5

devicetype=0x5

devicetype=5h

devicetype=PcanUsb

See Also

Reference

ParameterValueLookUp Class
Peak.Can.Basic Namespace


ParameterValue.LookUp.IpAddress Field

ParameterValueLookUpIpAddress Field

Search parameter representing an IP address value.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly string IpAddress
Public Shared ReadOnly IpAddress As String
public:
static initonly String^ IpAddress

Field Value

String
Remarks

The IP address is string representing an Internet Protocol address in standard notation.

It is made of 4 octets of numbers separated by '.', each with a value in the range of a byte, [0 .. MaxValue].

Example

ipaddress=192.168.2.1

See Also

Reference

ParameterValueLookUp Class
Peak.Can.Basic Namespace


ParameterValue.Trace Class

ParameterValueTrace Class

Represents values applicable to parameters related to CAN data tracing.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicParameterValueTrace

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static class Trace
Public NotInheritable Class Trace
public ref class Trace abstract sealed

The ParameterValueTrace type exposes the following members.

Fields
Name | Description
DateInFileName | The name of the trace files contains the date the trace was started.
MultiFiles | The traced data is spread over multiple files with a maximum size of TraceSize MB each.
OverrideExisting | If a file with the same name of the trace to create already exists, it is overwritten.
SingleFile | A single file is generated until it size reaches TraceSize MB.
TimeInFileName | The name of the trace files contains the time the trace was started.
UseDataLength | The trace file shows the column "Data Length" ('l') instead of the column "Data Length Code" ('L').
Top
Remarks
These values are flags. There can be combined with each other
See Also

Reference

Peak.Can.Basic Namespace
ParameterValueActivation
ParameterValueFilter
ParameterValueLog
ParameterValueLookUp


Trace Fields

The ParameterValueTrace type exposes the following members.

Fields
Name | Description
DateInFileName | The name of the trace files contains the date the trace was started.
MultiFiles | The traced data is spread over multiple files with a maximum size of TraceSize MB each.
OverrideExisting | If a file with the same name of the trace to create already exists, it is overwritten.
SingleFile | A single file is generated until it size reaches TraceSize MB.
TimeInFileName | The name of the trace files contains the time the trace was started.
UseDataLength | The trace file shows the column "Data Length" ('l') instead of the column "Data Length Code" ('L').
Top
See Also

Reference

ParameterValueTrace Class
Peak.Can.Basic Namespace


ParameterValue.Trace.DateInFileName Field

ParameterValueTraceDateInFileName Field

The name of the trace files contains the date the trace was started.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint DateInFileName
Public Shared ReadOnly DateInFileName As UInteger
public:
static initonly unsigned int DateInFileName

Field Value

UInt32
Remarks

The name of the trace file additionally includes the start-date of the tracing process. The date is expressed using 8 digits with the form YYYYMMDD, where YYYY are four digits for the year, MM two digits for the month, and DD two digits for the day, e.g., “20130228_PCAN_USBBUS1.trc” for the 28th of February 2013. If both, DateInFileName and TimeInFileName are configured, the file name starts always with the date: "20130228140733_PCAN_USBBUS1_1.trc".

See Also

Reference

ParameterValueTrace Class
Peak.Can.Basic Namespace


ParameterValue.Trace.MultiFiles Field

ParameterValueTraceMultiFiles Field

The traced data is spread over multiple files with a maximum size of TraceSize MB each.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint MultiFiles
Public Shared ReadOnly MultiFiles As UInteger
public:
static initonly unsigned int MultiFiles

Field Value

UInt32
Remarks

A trace session is stored in several files. A new file is created when a previous file reaches the maximum configured size. The tracing process stays active until it is deactivated, or the PCAN-Channel used is disconnected.

See Also

Reference

ParameterValueTrace Class
Peak.Can.Basic Namespace


ParameterValue.Trace.OverrideExisting Field

ParameterValueTraceOverrideExisting Field

If a file with the same name of the trace to create already exists, it is overwritten.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint OverrideExisting
Public Shared ReadOnly OverrideExisting As UInteger
public:
static initonly unsigned int OverrideExisting

Field Value

UInt32
Remarks

It causes the overwriting of an existence trace file when a new trace process 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.

See Also

Reference

ParameterValueTrace Class
Peak.Can.Basic Namespace


ParameterValue.Trace.SingleFile Field

ParameterValueTraceSingleFile Field

A single file is generated until it size reaches TraceSize MB.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint SingleFile
Public Shared ReadOnly SingleFile As UInteger
public:
static initonly unsigned int SingleFile

Field Value

UInt32
Remarks

A trace session is stored in a single and stays active until the file reaches the maximum configured file size, it is deactivated, or the PCAN Channel used is disconnected.

Tracing is automatically stopped when a file reaches the configured size limit. The SetValue method must be called using the TraceStatus parameter to start the tracing functionality again.

See Also

Reference

ParameterValueTrace Class
Peak.Can.Basic Namespace


ParameterValue.Trace.TimeInFileName Field

ParameterValueTraceTimeInFileName Field

The name of the trace files contains the time the trace was started.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint TimeInFileName
Public Shared ReadOnly TimeInFileName As UInteger
public:
static initonly unsigned int TimeInFileName

Field Value

UInt32
Remarks

The name of the trace file additionally includes the start-time of the tracing session. The time is expressed using 6 digits with the form HHMMSS, where HH are two digits for the hour in 24 hours format, MM two digits for the minutes, and SS two digits for the seconds, e.g., “140733_PCAN_USBBUS1.trc” for the 14:07:33 (02:07:33 PM). If both, DateInFileName and TimeInFileName are configured, the file name starts always with the date: "20130228140733_PCAN_USBBUS1_1.trc".

See Also

Reference

ParameterValueTrace Class
Peak.Can.Basic Namespace


ParameterValue.Trace.UseDataLength Field

ParameterValueTraceUseDataLength Field

The trace file shows the column "Data Length" ('l') instead of the column "Data Length Code" ('L').

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static readonly uint UseDataLength
Public Shared ReadOnly UseDataLength As UInteger
public:
static initonly unsigned int UseDataLength

Field Value

UInt32
Remarks

The "Data Length" represents the actual number of data bytes in a CAN or CAN FD message. Its value range is from 0 to 64. The "Data Length Code", as known as DLC, has a different interpretation in CAN and CAN FD. The first nine codes (0 to 8) represents 0 to 8 bytes for both. The last codes (9 to 15) represent for CAN a data length of 8. For CAN FD, these values indicate a data length between 12 and 64 bytes (see DLC for detailed information).

See Also

Reference

ParameterValueTrace Class
Peak.Can.Basic Namespace


PcanBasicException Class

Represents an exception thrown when a call to a Api functions fails in an unexpected manner.
Inheritance Hierarchy
SystemObject
SystemException
Peak.Can.BasicPcanBasicException

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public class PcanBasicException : Exception
Public Class PcanBasicException
    Inherits Exception
public ref class PcanBasicException : public Exception

The PcanBasicException type exposes the following members.

Constructors
 | Name | Description
Protected method | PcanBasicException | Initializes a new instance of the PcanBasicException class.
Top
Properties
 | Name | Description
Public property | ApiFunction | Name of the last PCAN-Basic API function called before the exception occurred.
Public property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception)
Public property | Error | PcanStatus value returned by the related PCAN-Basic API function.
Public property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception)
Public property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from Exception)
Public property | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception)
Public property | Message | Gets a message that describes the current exception. (Inherited from Exception)
Public property | MethodCaller | Name of the class method within the PCANBasic.NET assembly throwing the exception.
Public property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception)
Public property | StackTrace | Gets a string representation of the immediate frames on the call stack. (Inherited from Exception)
Public property | TargetSite | Gets the method that throws the current exception. (Inherited from Exception)
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetBaseException | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the runtime type of the current instance. (Inherited from Exception)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ToString | Creates and returns a string representation of the current exception. (Inherited from Exception)
Top
Events
 | Name | Description
Protected event | SerializeObjectState | Obsolete. Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. (Inherited from Exception)
Top
See Also

Reference

Peak.Can.Basic Namespace


PcanBasicException Constructor

Initializes a new instance of the PcanBasicException class.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
protected PcanBasicException()
Protected Sub New
protected:
PcanBasicException()
See Also

Reference

PcanBasicException Class
Peak.Can.Basic Namespace


PcanBasicException Properties

The PcanBasicException type exposes the following members.

Properties
 | Name | Description
Public property | ApiFunction | Name of the last PCAN-Basic API function called before the exception occurred.
Public property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception)
Public property | Error | PcanStatus value returned by the related PCAN-Basic API function.
Public property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception)
Public property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from Exception)
Public property | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception)
Public property | Message | Gets a message that describes the current exception. (Inherited from Exception)
Public property | MethodCaller | Name of the class method within the PCANBasic.NET assembly throwing the exception.
Public property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception)
Public property | StackTrace | Gets a string representation of the immediate frames on the call stack. (Inherited from Exception)
Public property | TargetSite | Gets the method that throws the current exception. (Inherited from Exception)
Top
See Also

Reference

PcanBasicException Class
Peak.Can.Basic Namespace


PcanBasicException.ApiFunction Property

PcanBasicExceptionApiFunction Property

Name of the last PCAN-Basic API function called before the exception occurred.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public string ApiFunction { get; }
Public ReadOnly Property ApiFunction As String
    Get
public:
property String^ ApiFunction {
    String^ get ();
}

Property Value

String
See Also

Reference

PcanBasicException Class
Peak.Can.Basic Namespace


PcanBasicException.Error Property

PcanBasicExceptionError Property

PcanStatus value returned by the related PCAN-Basic API function.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public PcanStatus Error { get; }
Public ReadOnly Property Error As PcanStatus
    Get
public:
property PcanStatus Error {
    PcanStatus get ();
}

Property Value

PcanStatus
See Also

Reference

PcanBasicException Class
Peak.Can.Basic Namespace


PcanBasicException.MethodCaller Property

PcanBasicExceptionMethodCaller Property

Name of the class method within the PCANBasic.NET assembly throwing the exception.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public string MethodCaller { get; }
Public ReadOnly Property MethodCaller As String
    Get
public:
property String^ MethodCaller {
    String^ get ();
}

Property Value

String
See Also

Reference

PcanBasicException Class
Peak.Can.Basic Namespace


PcanBasicException Methods

The PcanBasicException type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetBaseException | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the runtime type of the current instance. (Inherited from Exception)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ToString | Creates and returns a string representation of the current exception. (Inherited from Exception)
Top
See Also

Reference

PcanBasicException Class
Peak.Can.Basic Namespace


PcanBasicException Events

The PcanBasicException type exposes the following members.

Events
 | Name | Description
Protected event | SerializeObjectState | Obsolete. Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. (Inherited from Exception)
Top
See Also

Reference

PcanBasicException Class
Peak.Can.Basic Namespace


PcanChannel Enumeration

Represents the different PCAN buses (PCAN Channels) available to use within the API when a PCAN Handle is required.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum PcanChannel
Public Enumeration PcanChannel
public enum class PcanChannel
Members
Member name | Value | Description
None | 0 | Represents a standard PCAN channel. This channel cannot be initialized.
Pci01 | 1,025 | PCAN-PCI interface, channel 1.
Pci02 | 1,026 | PCAN-PCI interface, channel 2.
Pci03 | 1,027 | PCAN-PCI interface, channel 3.
Pci04 | 1,028 | PCAN-PCI interface, channel 4.
Pci05 | 1,029 | PCAN-PCI interface, channel 5.
Pci06 | 1,030 | PCAN-PCI interface, channel 6.
Pci07 | 1,031 | PCAN-PCI interface, channel 7.
Pci08 | 1,032 | PCAN-PCI interface, channel 8.
Pci09 | 1,033 | PCAN-PCI interface, channel 9.
Pci10 | 1,034 | PCAN-PCI interface, channel 10.
Pci11 | 1,035 | PCAN-PCI interface, channel 11.
Pci12 | 1,036 | PCAN-PCI interface, channel 12.
Pci13 | 1,037 | PCAN-PCI interface, channel 13.
Pci14 | 1,038 | PCAN-PCI interface, channel 14.
Pci15 | 1,039 | PCAN-PCI interface, channel 15.
Pci16 | 1,040 | PCAN-PCI interface, channel 16.
Usb01 | 1,281 | PCAN-USB interface, channel 1.
Usb02 | 1,282 | PCAN-USB interface, channel 2.
Usb03 | 1,283 | PCAN-USB interface, channel 3.
Usb04 | 1,284 | PCAN-USB interface, channel 4.
Usb05 | 1,285 | PCAN-USB interface, channel 5.
Usb06 | 1,286 | PCAN-USB interface, channel 6.
Usb07 | 1,287 | PCAN-USB interface, channel 7.
Usb08 | 1,288 | PCAN-USB interface, channel 8.
Usb09 | 1,289 | PCAN-USB interface, channel 9.
Usb10 | 1,290 | PCAN-USB interface, channel 10.
Usb11 | 1,291 | PCAN-USB interface, channel 11.
Usb12 | 1,292 | PCAN-USB interface, channel 12.
Usb13 | 1,293 | PCAN-USB interface, channel 13.
Usb14 | 1,294 | PCAN-USB interface, channel 14.
Usb15 | 1,295 | PCAN-USB interface, channel 15.
Usb16 | 1,296 | PCAN-USB interface, channel 16.
Lan01 | 2,049 | PCAN-LAN interface, channel 1.
Lan02 | 2,050 | PCAN-LAN interface, channel 2.
Lan03 | 2,051 | PCAN-LAN interface, channel 3.
Lan04 | 2,052 | PCAN-LAN interface, channel 4.
Lan05 | 2,053 | PCAN-LAN interface, channel 5.
Lan06 | 2,054 | PCAN-LAN interface, channel 6.
Lan07 | 2,055 | PCAN-LAN interface, channel 7.
Lan08 | 2,056 | PCAN-LAN interface, channel 8.
Lan09 | 2,057 | PCAN-LAN interface, channel 9.
Lan10 | 2,058 | PCAN-LAN interface, channel 10.
Lan11 | 2,059 | PCAN-LAN interface, channel 11.
Lan12 | 2,060 | PCAN-LAN interface, channel 12.
Lan13 | 2,061 | PCAN-LAN interface, channel 13.
Lan14 | 2,062 | PCAN-LAN interface, channel 14.
Lan15 | 2,063 | PCAN-LAN interface, channel 15.
Lan16 | 2,064 | PCAN-LAN interface, channel 16.
See Also

Reference

Peak.Can.Basic Namespace


PcanChannelInformation Class

Represents information about a PCAN Channel.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicPcanChannelInformation

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public sealed class PcanChannelInformation
Public NotInheritable Class PcanChannelInformation
public ref class PcanChannelInformation sealed

The PcanChannelInformation type exposes the following members.

Properties
 | Name | Description
Public property | ChannelCondition | The availability status of the PCAN Channel.
Public property | ChannelHandle | The handle of the PCAN Channel.
Public property | ControllerNumber | The CAN controller index represented by this PCAN Channel.
Public property | DeviceFeatures | The features supported by the device represented by the PCAN Channel.
Public property | DeviceID | The identification number of the device represented by the PCAN Channel.
Public property | DeviceName | The name of the device represented by the PCAN Channel.
Public property | DeviceType | The kind of PCAN device represented by the PCAN Channel.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

Peak.Can.Basic Namespace


PcanChannelInformation Properties

The PcanChannelInformation type exposes the following members.

Properties
 | Name | Description
Public property | ChannelCondition | The availability status of the PCAN Channel.
Public property | ChannelHandle | The handle of the PCAN Channel.
Public property | ControllerNumber | The CAN controller index represented by this PCAN Channel.
Public property | DeviceFeatures | The features supported by the device represented by the PCAN Channel.
Public property | DeviceID | The identification number of the device represented by the PCAN Channel.
Public property | DeviceName | The name of the device represented by the PCAN Channel.
Public property | DeviceType | The kind of PCAN device represented by the PCAN Channel.
Top
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanChannelInformation.ChannelCondition Property

PcanChannelInformationChannelCondition Property

The availability status of the PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public ChannelCondition ChannelCondition { get; }
Public ReadOnly Property ChannelCondition As ChannelCondition
    Get
public:
property ChannelCondition ChannelCondition {
    ChannelCondition get ();
}

Property Value

ChannelCondition
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanChannelInformation.ChannelHandle Property

PcanChannelInformationChannelHandle Property

The handle of the PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public PcanChannel ChannelHandle { get; }
Public ReadOnly Property ChannelHandle As PcanChannel
    Get
public:
property PcanChannel ChannelHandle {
    PcanChannel get ();
}

Property Value

PcanChannel
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanChannelInformation.ControllerNumber Property

PcanChannelInformationControllerNumber Property

The CAN controller index represented by this PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int ControllerNumber { get; }
Public ReadOnly Property ControllerNumber As Integer
    Get
public:
property int ControllerNumber {
    int get ();
}

Property Value

Int32
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanChannelInformation.DeviceFeatures Property

PcanChannelInformationDeviceFeatures Property

The features supported by the device represented by the PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public PcanDeviceFeatures DeviceFeatures { get; }
Public ReadOnly Property DeviceFeatures As PcanDeviceFeatures
    Get
public:
property PcanDeviceFeatures DeviceFeatures {
    PcanDeviceFeatures get ();
}

Property Value

PcanDeviceFeatures
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanChannelInformation.DeviceID Property

PcanChannelInformationDeviceID Property

The identification number of the device represented by the PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint DeviceID { get; }
Public ReadOnly Property DeviceID As UInteger
    Get
public:
property unsigned int DeviceID {
    unsigned int get ();
}

Property Value

UInt32
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanChannelInformation.DeviceName Property

PcanChannelInformationDeviceName Property

The name of the device represented by the PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public string DeviceName { get; }
Public ReadOnly Property DeviceName As String
    Get
public:
property String^ DeviceName {
    String^ get ();
}

Property Value

String
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanChannelInformation.DeviceType Property

PcanChannelInformationDeviceType Property

The kind of PCAN device represented by the PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public PcanDevice DeviceType { get; }
Public ReadOnly Property DeviceType As PcanDevice
    Get
public:
property PcanDevice DeviceType {
    PcanDevice get ();
}

Property Value

PcanDevice
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanChannelInformation Methods

The PcanChannelInformation type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

PcanChannelInformation Class
Peak.Can.Basic Namespace


PcanDevice Enumeration

Represents the type of interface and driver a device uses.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum PcanDevice
Public Enumeration PcanDevice
public enum class PcanDevice
Members
Member name | Value | Description
None | 0 | Undefined, unknown or not selected PCAN device value.
PcanPci | 4 | PCAN-PCI, PCAN-cPCI, PCAN-miniPCI, PCAN-PC/104-Plus, PCAN-PCI Express, PCAN-PCIe FD, PCAN-PCI FD, PCAN-Chip PCIe.
PcanUsb | 5 | PCAN-USB, PCAN-USB Pro, PCAN-USB FD, PCAN-USB Pro FD, PCAN-Chip USB.
PcanLan | 8 | PCAN-Gateway, and PCAN-Gateway FD PCAN devices.
See Also

Reference

Peak.Can.Basic Namespace


PcanDeviceFeatures Enumeration

Represents the features implemented by a PCAN device.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
[FlagsAttribute]
public enum PcanDeviceFeatures
<FlagsAttribute>
Public Enumeration PcanDeviceFeatures
[FlagsAttribute]
public enum class PcanDeviceFeatures
Members
Member name | Value | Description
FlexibleDataRate | 1 | The PCAN Channel represents a device that supports flexible data rate (CAN FD).
InterframeDelay | 2 | The PCAN Channel represents a device that supports the configuration of a delay between sending frames (FPGA devices only).
IoFunctionality | 4 | The PCAN Channel represents a device that supports the configuration of digital and/or analogue IOs (input/output) for using with electronic circuits.
See Also

Reference

Peak.Can.Basic Namespace


PcanMessage Class

Represents a PCAN message from a CAN or CAN FD capable hardware.
Inheritance Hierarchy
SystemObject
Peak.Can.BasicPcanMessage

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public sealed class PcanMessage
Public NotInheritable Class PcanMessage
public ref class PcanMessage sealed

The PcanMessage type exposes the following members.

Constructors
 | Name | Description
Public method | PcanMessage | Initializes an instance of PcanMessage.
Top
Properties
 | Name | Description
Public property | Data | The data associated to the CAN message (CAN DATA[0]..DATA[7], CAN FD DATA[0]..DATA[63]).
Public property | DLC | The Data Length Code (DLC) of the message (0..15).
Public property | ID | A 11/29-bit CAN message identifier.
Public property | Length | The amount of data bytes according to the Data Length Code.
Public property | MaxDataLength | Maximum amount of data bytes supported by this object
Public property | MsgType | The kind of CAN frame represented by this object.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Builds and returns a string that represents the current CAN message. (Overrides ObjectToString)
Top
See Also

Reference

Peak.Can.Basic Namespace


PcanMessage Constructor

Initializes an instance of PcanMessage.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public PcanMessage(
    uint id = 0,
    MessageType msgType = MessageType.Standard,
    byte dlc = 0,
    byte[] data = null,
    bool extendedDataLength = false
)
Public Sub New (
    Optional id As UInteger = 0,
    Optional msgType As MessageType = MessageType.Standard,
    Optional dlc As Byte = 0,
    Optional data As Byte() = Nothing,
    Optional extendedDataLength As Boolean = false
)
public:
PcanMessage(
    unsigned int id = 0,
    MessageType msgType = MessageType::Standard,
    unsigned char dlc = 0,
    array<unsigned char>^ data = nullptr,
    bool extendedDataLength = false
)

Parameters

id UInt32 (Optional)
The 11/29-bit CAN identifier.
msgType MessageType (Optional)
The type of the message.
dlc Byte (Optional)
The Data Length Code (DLC) of the message (0..15)
data Byte (Optional)
The data associated to the message. If null, data default values are used (0).
extendedDataLength Boolean (Optional)
If the data of the message may contain more than 8 bytes (CAN FD).
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage Properties

The PcanMessage type exposes the following members.

Properties
 | Name | Description
Public property | Data | The data associated to the CAN message (CAN DATA[0]..DATA[7], CAN FD DATA[0]..DATA[63]).
Public property | DLC | The Data Length Code (DLC) of the message (0..15).
Public property | ID | A 11/29-bit CAN message identifier.
Public property | Length | The amount of data bytes according to the Data Length Code.
Public property | MaxDataLength | Maximum amount of data bytes supported by this object
Public property | MsgType | The kind of CAN frame represented by this object.
Top
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage.Data Property

PcanMessageData Property

The data associated to the CAN message (CAN DATA[0]..DATA[7], CAN FD DATA[0]..DATA[63]).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public DataBytes Data { get; set; }
Public Property Data As DataBytes
    Get
    Set
public:
property DataBytes^ Data {
    DataBytes^ get ();
    void set (DataBytes^ value);
}

Property Value

DataBytes
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage.DLC Property

PcanMessageDLC Property

The Data Length Code (DLC) of the message (0..15).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public byte DLC { get; set; }
Public Property DLC As Byte
    Get
    Set
public:
property unsigned char DLC {
    unsigned char get ();
    void set (unsigned char value);
}

Property Value

Byte
Remarks

The number of data bytes (Length) in the Data field is indicated by the Data Length Code. Its coding is different in CAN and CAN FD. The first nine codes are the same in both, but the following codes specify different data lengths. There is the following relationship between Data Length Code and the actual number of data bytes:

DLC | Data Length - CAN | Data Length - CAN FD
≤ 8 | DLC | DLC
9 | 8 | 12
10 | 8 | 16
11 | 8 | 20
12 | 8 | 24
13 | 8 | 32
14 | 8 | 48
15 | 8 | 64

See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage.ID Property

PcanMessageID Property

A 11/29-bit CAN message identifier.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint ID { get; set; }
Public Property ID As UInteger
    Get
    Set
public:
property unsigned int ID {
    unsigned int get ();
    void set (unsigned int value);
}

Property Value

UInt32
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage.Length Property

PcanMessageLength Property

The amount of data bytes according to the Data Length Code.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public byte Length { get; }
Public ReadOnly Property Length As Byte
    Get
public:
property unsigned char Length {
    unsigned char get ();
}

Property Value

Byte
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage.MaxDataLength Property

PcanMessageMaxDataLength Property

Maximum amount of data bytes supported by this object

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int MaxDataLength { get; }
Public ReadOnly Property MaxDataLength As Integer
    Get
public:
property int MaxDataLength {
    int get ();
}

Property Value

Int32
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage.MsgType Property

PcanMessageMsgType Property

The kind of CAN frame represented by this object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public MessageType MsgType { get; set; }
Public Property MsgType As MessageType
    Get
    Set
public:
property MessageType MsgType {
    MessageType get ();
    void set (MessageType value);
}

Property Value

MessageType
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage Methods

The PcanMessage type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Builds and returns a string that represents the current CAN message. (Overrides ObjectToString)
Top
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanMessage.ToString Method

PcanMessageToString Method

Builds and returns a string that represents the current CAN message.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public override string ToString()
Public Overrides Function ToString As String
public:
virtual String^ ToString() override

Return Value

String
A string that represents the current CAN message.
See Also

Reference

PcanMessage Class
Peak.Can.Basic Namespace


PcanParameter Enumeration

Represents a PCAN parameter or a PCAN Value that can be read or set.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum PcanParameter
Public Enumeration PcanParameter
public enum class PcanParameter
Members
Member name | Value | Description
DeviceId | 1 | Device identifier parameter. See usage for more information.
Power5Volts | 2 | PCAN "5-volt power" parameter. See usage for more information.
ReceiveEvent | 3 | PCAN receive event handler parameter. See usage for more information.
MessageFilter | 4 | PCAN message filter parameter. See usage for more information.
ApiVersion | 5 | PCAN-Basic API version parameter. See usage for more information.
ChannelVersion | 6 | PCAN device channel version parameter. See usage for more information.
BusOffAutoReset | 7 | PCAN "reset on bus-off" parameter. See usage for more information.
ListenOnly | 8 | PCAN "listen-only" parameter. See usage for more information.
LogLocation | 9 | Directory path for log files. See usage for more information.
LogStatus | 10 | Debug-Log activation status. See usage for more information.
LogConfigure | 11 | Configuration of the debugged information (ParameterValueLog). See usage for more information.
LogText | 12 | Custom insertion of text into the log file. See usage for more information.
ChannelCondition | 13 | Availability status of a PCAN Channel. See usage for more information.
HardwareName | 14 | PCAN "hardware name" parameter. See usage for more information.
ReceiveStatus | 15 | "Receive Status" parameter for incoming messages. See usage for more information.
ControllerNumber | 16 | Zero-based index of a CAN-Controller in a PCAN device. See usage for more information.
TraceLocation | 17 | Directory path for PCAN trace files. See usage for more information.
TraceStatus | 18 | PCAN tracing activation status. See usage for more information.
TraceSize | 19 | Configuration of the maximum file size of a PCAN trace. See usage for more information.
TraceConfigure | 20 | Configuration of the trace file storing modes (ParameterValueTrace). See usage for more information.
ChannelIdentifying | 21 | Physical identification of an USB based PCAN Channel. See usage for more information.
ChannelFeatures | 22 | Capabilities of a PCAN device (PcanDeviceFeatures). See usage for more information.
BitrateAdapting | 23 | Attachment to an existing connection with unknown/different bit rate. See usage for more information.
BitrateInformation | 24 | Current bit rate as BTR0BTR1 value (classic CAN 2.0 A/B). See usage for more information.
BitrateFdInformation | 25 | Current bit rate as FD String value (CAN FD). See usage for more information.
BusSpeedNominal | 26 | Current CAN nominal speed in bits/second. See usage for more information.
BusSpeedData | 27 | Current CAN data speed in bits/second. See usage for more information.
IpAddress | 28 | Remote address as a IPv4 formated string. See usage for more information.
VirtualPcanGatewayStatus | 29 | Running status of the Virtual PCAN-Gateway Service (ServiceStatus). See usage for more information.
AllowStatusFrames | 30 | "Receive Status" parameter for Status frames. See usage for more information.
AllowRtrFrames | 31 | "Receive Status" parameter for RTR frames. See usage for more information.
AllowErrorFrames | 32 | "Receive Status" parameter for Error frames. See usage for more information.
InterframeDelay | 33 | Delay, in microseconds, between sending frames. See usage for more information.
AcceptanceFilter11Bit | 34 | Acceptance filter over code and mask for 11-bit CAN IDs. See usage for more information.
AcceptanceFilter29Bit | 35 | Acceptance filter over code and mask for 29-bit CAN IDs. See usage for more information.
IoDigitalConfiguration | 36 | Activation of digital pins as outputs. See usage for more information.
IoDigitalValue | 37 | Multiple setting of digital pin values. See usage for more information.
IoDigitalSet | 38 | Selective setting of digital pin values to "high". See usage for more information.
IoDigitalClear | 39 | Selective setting of digital pin values to "low". See usage for more information.
IoAnalogValue | 40 | Value reading of a single analog pin. See usage for more information.
FirmwareVersion | 41 | Firmware version of a PCAN device. See usage for more information.
AttachedChannelsCount | 42 | Amount of PCAN channels attached to a system. See usage for more information.
AttachedChannelsInformation | 43 | Information about PCAN channels attached to a system. See usage for more information.
AllowEchoFrames | 44 | "Receive Status" parameter for Echo frames. See usage for more information.
DevicePartNumber | 45 | PEAK's device part number (IPEH number). See usage for more information.
HardResetStatus | 46 | "Activation Status" parameter for the hard reset capability. See usage for more information.
LanChannelDirection | 47 | Communication direction of a PCAN Channel representing a PCAN-LAN interface. See usage for more information.
Remarks
With some exceptions, a channel must first be initialized before their parameters can be read or set.
See Also

Reference

Peak.Can.Basic Namespace

Other Resources

Parameter Classification and Usage


PcanStatus Enumeration

Represents a PCAN status/error code.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
[FlagsAttribute]
public enum PcanStatus
<FlagsAttribute>
Public Enumeration PcanStatus
[FlagsAttribute]
public enum class PcanStatus
Members
Member name | Value | Description
OK | 0 | No error. Success.
TransmitBufferFull | 1 | The transmit buffer in CAN controller is full.
Overrun | 2 | The CAN controller was read too late.
BusLight | 4 | Bus error: an error counter reached the 'light' limit.
BusHeavy | 8 | Bus error: an error counter reached the 'heavy' limit.
BusWarning | 8 | Bus error: an error counter reached the 'warning' limit.
BusOff | 16 | Bus error: the CAN controller is in bus-off state.
ReceiveQueueEmpty | 32 | The reception queue is empty.
ReceiveQueueOverrun | 64 | The reception queue was read too late.
TransmitQueueFull | 128 | The transmit queue is full.
NoDriver | 512 | The driver of the used PCAN device is not loaded.
HardwareInUse | 1,024 | The PCAN-Hardware has already a PCAN-Net attached.
NetInUse | 2,048 | A PCAN-Net has already a PCAN-Client attached.
IllegalHardwareHandle | 5,120 | The handle of the PCAN-Hardware is invalid.
IllegalNetHandle | 6,144 | The handle of the PCAN-Net is invalid.
IllegalClientHandle | 7,168 | The handle of the PCAN-Client is invalid.
IllegalHandle | 7,168 | Mask for all handle errors.
Resource | 8,192 | An internal resource (FIFO, Client, timeout) cannot be created.
InvalidParameter | 16,384 | Unknown parameter.
InvalidValue | 32,768 | Invalid parameter value.
Unknown | 65,536 | Unknown error.
IllegalData | 131,072 | An action, function, or data is invalid within the current context.
BusPassive | 262,144 | Bus error: the CAN controller is error passive.
AnyBusError | 262,172 | Mask for all bus errors.
IllegalMode | 524,288 | The device driver object state is wrong for the attempted operation.
Caution | 33,554,432 | An operation was successfully carried out, however, irregularities were registered.
Initialize | 67,108,864 | The PCAN Channel is not (or could not be) initialized.
InvalidOperation | 134,217,728 | An invalid operation was registered.
Remarks
The PcanStatus values 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.
See Also

Reference

Peak.Can.Basic Namespace


Protocol Enumeration

Represents the transport protocol used for Data transmission.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum Protocol
Public Enumeration Protocol
public enum class Protocol
Members
Member name | Value | Description
Can | 0 | Classic CAN 2.0 A/B, with a maximum of 8 data bytes per frame.
CanFd | 1 | CAN with Flexible data rate, with a maximum of 64 bytes per frame.
See Also

Reference

Peak.Can.Basic Namespace


ServiceStatus Enumeration

Represents the status of the Virtual PCAN-Gateway service.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum ServiceStatus
Public Enumeration ServiceStatus
public enum class ServiceStatus
Members
Member name | Value | Description
Stopped | 1 | The service is not running.
Running | 4 | The service is running.
See Also

Reference

Peak.Can.Basic Namespace


Worker Class

PCAN Worker class implementation.

Worker makes use of the Api class to allows reading and writing from and to a PCAN Channel in an automatic way, using timers and events. It allows a more accurate filtering system that the native one, and the use of multiple receive queues with separate filter configuration.

If direct access to the PCAN-Basic interface is desired, use the Api class instead.

Inheritance Hierarchy
SystemObject
Peak.Can.BasicWorker

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public class Worker
Public Class Worker
public ref class Worker

The Worker type exposes the following members.

Constructors
Name | Description
Worker | Initializes a PCAN-Basic Worker object with its default values.
Worker(PcanChannel, Bitrate, Boolean) | Initializes a PCAN-Basic Worker object.
Worker(PcanChannel, BitrateFD, Boolean) | Initializes a PCAN-Basic Worker object.
Top
Properties
 | Name | Description
Public property | Active | Gets the activation status of this Worker object.
Public property | AllowEchoFrames | Enables or disables receiving echo frames (see Echo).
Public property | AllowErrorFrames | Enables or disables receiving error frames (see Error).
Public property | AllowRemoteRequestFrames | Enables or disables receiving remote request frames (see RemoteRequest).
Public property | AllowStatusFrames | Enables or disables receiving status frames (see Status).
Public property | BitrateCan | Gets or sets the bit rate used for classic CAN 2.0A/B data transmission (see Bitrate).
Public property | BitrateCanFd | Gets or sets the bit rate used for CAN FD data transmission (see BitrateFD).
Public property | BroadcastCount | Retrieves the total amount of periodic messages currently configured within this object.
Public property | Channel | Gets or set the PCAN Channel used for CAN communication.
Public property | ExceptionLanguage | Specifies the language used for exception texts formatting.
Public property | ListenOnly | Configures the CAN feature listen-only in the associated PCAN Channel.
Public property | MessageBroadcasting | Enables or disables the sending of periodic messages.
Public property | MessageFetching | Enables or disable the reading of messages.
Public property | TotalAvailableMessages | Retrieves the total amount of messages currently contained by this object.
Public property | TransmissionProtocol | Gets or sets the transport protocol used for CAN communication.
Top
Methods
 | Name | Description
 | AddBroadcast(Broadcast) | Configures a CAN message to be written periodically.
 | AddBroadcast(PcanMessage, Int32) | Configures a CAN message to be written periodically.
 | AddFilter(FilteringCriterion) | Includes an additional filtering criterion to the message filter of the default receive queue (index 0).
 | AddFilter(Int32, FilteringCriterion) | Configures an additional filtering criterion to the message filter of a receive queue.
 | ClearAllReceiveQueues | Discards all available messages from all receive queues.
 | ClearBroadcasts | Removes all entries from the Worker object's broadcast list.
 | ClearFilters | Removes all filtering criteria from the message filter of the default receive queue (index 0).
 | ClearFilters(Int32) | Removes all filtering criteria from the message filter of the specified receive queue.
 | ClearReceiveQueue | Discards all available messages from the default receive queue (index 0).
 | ClearReceiveQueue(Int32) | Discards all available messages from the given receive queue.
 | Dequeue(PcanMessage, UInt64) | Removes and returns a CAN messages and its timestamp from the default receive queue (index 0).
 | Dequeue(Int32, PcanMessage, UInt64) | Removes and returns a CAN messages and its timestamp from a specific receive queue.
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Finalizes this object. (Overrides ObjectFinalize)
 | GetAvailableMessagesCount | Retrieves the amount of available messages currently contained in the default receive queue (index 0).
 | GetAvailableMessagesCount(Int32) | Retrieves the amount of available messages currently contained in the specified receive queue.
 | GetBroadcast | Retrieves a Broadcast object from the periodic CAN messages list.
 | GetFilters | Retrieves the current configured filtering criteria for the default receive queue (index 0).
 | GetFilters(Int32) | Retrieves the current configured filtering criteria of a specific receive queue.
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
 | PauseBroadcast | Temporarily stops sending a periodic CAN message.
 | RemoveBroacast(Broadcast) | Removes a periodic CAN message from the list of registered Broadcast objects.
 | RemoveBroacast(Int32) | Removes a periodic CAN message from the list of registered Broadcast objects.
 | RemoveFilter(FilteringCriterion) | Removes a filtering criterion from the message filter of the default receive queue (index 0).
 | RemoveFilter(Int32, FilteringCriterion) | Removes a filtering criterion from the message filter of the specified receive queue.
 | ResetHardware | Performs a reset of the CAN controller on the hardware connected by the Worker object.
 | ResetHardware(PcanStatus) | Performs a reset of the CAN controller on the hardware connected by the Worker object.
 | ResumeBroadcast | Resumes the sending of a paused periodic CAN message.
 | SetFilteringState(FilteringState, Boolean) | Configures the behavior of the message filter for the default receive queue (index 0).
 | SetFilteringState(Int32, FilteringState, Boolean) | Configures the behavior of the message filter for a specific receive queue.
 | Start | Establishes a connection to a PCAN Channel, configures it for data transmission and starts the read/write processes.
 | Stop | Disconnects the used PCAN Channel and stops reading and writing data.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
 | Transmit(PcanMessage) | Places a CAN message into the transmit queue of the device driver to be written as soon as possible.
 | Transmit(PcanMessage, PcanStatus) | Places a CAN message into the transmit queue of the device driver to be written as soon as possible.
 | UpdateBroadcast(Int32, PcanMessage) | Adjusts the content of a periodic CAN message from the list of registered Broadcast objects.
 | UpdateBroadcast(Int32, Int32) | Adjusts the sending interval of a periodic CAN message from the list of registered Broadcast objects.
 | UpdateBroadcast(Int32, Int32, PcanMessage) | Adjusts the configuration of a periodic CAN message from the list of registered Broadcast objects.
Top
Events
 | Name | Description
Public event | MessageAvailable | Occurs when a message is received, validated and placed in a receive queue.
Top
Fields
Name | Description
MaximumBroadcastCount | Indicates the maximum amount of periodic messages that can be handled.
ReceiveQueuesCount | Indicates the amount of receive queues available to use.
Top
Remarks

About reading:

The Worker object does have multiple receive queues. Only one of those receive queues is active by default when the object is created, and its filter is configured to receive any message. The remaining receive queues keep their filters closed.

The reading process is executed in an additional thread, making use of the event notification mechanism to fetch CAN messages. Fetched messages can be dequeued for their further processing using the Dequeue method. If needed, messages stored in one or all receive queues may be discarded using the methods ClearReceiveQueue and ClearAllReceiveQueues respectively.

Each receive queue has its own message filter. This message filter can be configured using several filtering criteria, in form of FilteringCriterion data, by using the AddFilter method. The message filtering in a receive queue can also be temporarily disabled/enabled at any time by using the SetFilteringState method. A specific filtering criterion, or all of them, can be removed using the methods RemoveFilter and ClearFilters respectively.

About writing:

There are two approaches for sending messages to the connected CAN network:

  1. Using the Transmit method, which places a CAN message in the connected Channel's transmit queue for immediate sending.

  2. Using a Broadcast message, which periodically places a configured CAN message in the connected Channel's transmit queue for immediate sending.

New Broadcast items can be registered using the AddBroadcast method. The processing of current registered Broadcast items can be stopped and resumed again using their Active property, or the methods PauseBroadcast and ResumeBroadcast respectively. A specific Broadcast item, or all of them, can be removed using the methods RemoveBroacast and ClearBroadcasts respectively.

See Also

Reference

Peak.Can.Basic Namespace


Worker Constructor

Overload List
Name | Description
Worker | Initializes a PCAN-Basic Worker object with its default values.
Worker(PcanChannel, Bitrate, Boolean) | Initializes a PCAN-Basic Worker object.
Worker(PcanChannel, BitrateFD, Boolean) | Initializes a PCAN-Basic Worker object.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker Constructor

Initializes a PCAN-Basic Worker object with its default values.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public Worker()
Public Sub New
public:
Worker()
Remarks

As default, the Worker is configured to use the first connected PCAN USB interface, using classic CAN as protocol, and 500 kBit/s as bit rate.

A single receive queue is used, which is full open at connection time.

Note Note
A Worker object can handle up to 'ReceiveQueuesCount' receive queues. Incoming messages are processed by all queues, so that the same message can be found in more than one queue, if its filter is configured to accept the message.

Only one receive queue is active by default when the object is created, and its filter is configured to receive any message.

Example

The following example shows the initialization of a Worker instance, using its default constructor.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Show information about the object
//
Console.WriteLine("Worker object created.");
Console.WriteLine($"  Channel: {myWorker.Channel}");
Console.WriteLine($"  Protocol: {myWorker.TransmissionProtocol}");
Console.WriteLine($"  Bit rate: {myWorker.BitrateCan}");
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Show information about the object
'
Console.WriteLine("Worker object created.")
Console.WriteLine($"  Channel: {myWorker.Channel}")
Console.WriteLine($"  Protocol: {myWorker.TransmissionProtocol}")
Console.WriteLine($"  Bit rate: {myWorker.BitrateCan}")
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Show information about the object
//
Console::WriteLine("Worker object created.");
Console::WriteLine("  Channel: {0}", myWorker->Channel);
Console::WriteLine("  Protocol: {0}", myWorker->TransmissionProtocol);
Console::WriteLine("  Bit rate: {0}", myWorker->BitrateCan);
See Also

Reference

Worker Class
Worker Overload
Peak.Can.Basic Namespace


Worker(PcanChannel, Bitrate, Boolean) Constructor

Initializes a PCAN-Basic Worker object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public Worker(
    PcanChannel canChannel,
    Bitrate bitrate,
    bool closedFilter = false
)
Public Sub New (
    canChannel As PcanChannel,
    bitrate As Bitrate,
    Optional closedFilter As Boolean = false
)
public:
Worker(
    PcanChannel canChannel,
    Bitrate bitrate,
    bool closedFilter = false
)

Parameters

canChannel PcanChannel
The handle of a PCAN Channel to use for CAN communication.
bitrate Bitrate
The speed for the classic CAN 2.0A/B communication as a BTR0/BTR1 code. Default is 500 kBit/s (Pcan500).
closedFilter Boolean (Optional)
When true, the filter of the first receive queue is set to discard all. Otherwise, any message will be received.
Remarks
Note Note
A Worker object can handle up to 'ReceiveQueuesCount' receive queues. Incoming messages are processed by all queues, so that the same message can be found in more than one queue, if its filter is con figured to accept the message.

Only one receive queue is active by default when the object is created, and its filter is configured to receive any message.

Example

The following example shows the initialization of a Worker instance, using as bit rate 250 kBit/s on the first PCAN-PCI Channel.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using a custom configuration
//
Worker myWorker = new Worker(PcanChannel.Pci01, Bitrate.Pcan250);

// Show information about the object
//
Console.WriteLine("Worker object created.");
Console.WriteLine($"  Channel: {myWorker.Channel}");
Console.WriteLine($"  Protocol: {myWorker.TransmissionProtocol}");
Console.WriteLine($"  Bit rate: {myWorker.BitrateCan}");
' Create the object using a custom configuration
'
Dim myWorker As Worker = New Worker(PcanChannel.Pci01, Bitrate.Pcan250)

' Show information about the object
'
Console.WriteLine("Worker object created.")
Console.WriteLine($"  Channel: {myWorker.Channel}")
Console.WriteLine($"  Protocol: {myWorker.TransmissionProtocol}")
Console.WriteLine($"  Bit rate: {myWorker.BitrateCan}")
// Create the object using a custom configuration
//
Worker^ myWorker = gcnew Worker(PcanChannel::Pci01, Bitrate::Pcan250, false);

// Show information about the object
//
Console::WriteLine("Worker object created.");
Console::WriteLine("  Channel: {0}", myWorker->Channel);
Console::WriteLine("  Protocol: {0}", myWorker->TransmissionProtocol);
Console::WriteLine("  Bit rate: {0}", myWorker->BitrateCan);
See Also

Reference

Worker Class
Worker Overload
Peak.Can.Basic Namespace


Worker(PcanChannel, BitrateFD, Boolean) Constructor

Initializes a PCAN-Basic Worker object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public Worker(
    PcanChannel canChannel,
    BitrateFD bitrate,
    bool closedFilter = false
)
Public Sub New (
    canChannel As PcanChannel,
    bitrate As BitrateFD,
    Optional closedFilter As Boolean = false
)
public:
Worker(
    PcanChannel canChannel,
    BitrateFD^ bitrate,
    bool closedFilter = false
)

Parameters

canChannel PcanChannel
The handle of a PCAN Channel to use for CAN communication.
bitrate BitrateFD
The speed for the communication as a CAN FD bit rate object (see BitrateFD). Default is 500 kBit/s / 2 MBit/s (BitrateSaeJ2284_4).
closedFilter Boolean (Optional)
When true, the filter of the first receive queue is set to discard all. Otherwise, any message will be received.
Remarks
Note Note
A Worker object can handle up to 'ReceiveQueuesCount' receive queues. Incoming messages are processed by all queues, so that the same message can be found in more than one queue, if its filter is con figured to accept the message.

Only one receive queue is active by default when the object is created, and its filter is configured to receive any message.

Example

The following example shows the initialization of a Worker instance, using 500 kBit/s / 5 MBit/s on the first PCAN-PCI Channel.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using a custom configuration
//
Worker myWorker = new Worker(PcanChannel.Pci01, (BitrateFD)BitrateFD.BitrateSaeJ2284_5);

// Show information about the object
//
Console.WriteLine("Worker object created.");
Console.WriteLine($"  Channel: {myWorker.Channel}");
Console.WriteLine($"  Protocol: {myWorker.TransmissionProtocol}");
Console.WriteLine($"  Bit rate: {myWorker.BitrateCanFd}");
' Create the object using a custom configuration
'
Dim myWorker As Worker = New Worker(PcanChannel.Pci01, CType(BitrateFD.BitrateSaeJ2284_5, BitrateFD))

' Show information about the object
'
Console.WriteLine("Worker object created.")
Console.WriteLine($"  Channel: {myWorker.Channel}")
Console.WriteLine($"  Protocol: {myWorker.TransmissionProtocol}")
Console.WriteLine($"  Bit rate: {myWorker.BitrateCanFd}")
// Create the object using a custom configuration
//
Worker^ myWorker = gcnew Worker(PcanChannel::Pci01, (BitrateFD^)BitrateFD::BitrateSaeJ2284_4, false);

// Show information about the object
//
Console::WriteLine("Worker object created.");
Console::WriteLine("  Channel: {0}", myWorker->Channel);
Console::WriteLine("  Protocol: {0}", myWorker->TransmissionProtocol);
Console::WriteLine("  Bit rate: {0}", myWorker->BitrateCanFd);
See Also

Reference

Worker Class
Worker Overload
Peak.Can.Basic Namespace


Worker Properties

The Worker type exposes the following members.

Properties
 | Name | Description
Public property | Active | Gets the activation status of this Worker object.
Public property | AllowEchoFrames | Enables or disables receiving echo frames (see Echo).
Public property | AllowErrorFrames | Enables or disables receiving error frames (see Error).
Public property | AllowRemoteRequestFrames | Enables or disables receiving remote request frames (see RemoteRequest).
Public property | AllowStatusFrames | Enables or disables receiving status frames (see Status).
Public property | BitrateCan | Gets or sets the bit rate used for classic CAN 2.0A/B data transmission (see Bitrate).
Public property | BitrateCanFd | Gets or sets the bit rate used for CAN FD data transmission (see BitrateFD).
Public property | BroadcastCount | Retrieves the total amount of periodic messages currently configured within this object.
Public property | Channel | Gets or set the PCAN Channel used for CAN communication.
Public property | ExceptionLanguage | Specifies the language used for exception texts formatting.
Public property | ListenOnly | Configures the CAN feature listen-only in the associated PCAN Channel.
Public property | MessageBroadcasting | Enables or disables the sending of periodic messages.
Public property | MessageFetching | Enables or disable the reading of messages.
Public property | TotalAvailableMessages | Retrieves the total amount of messages currently contained by this object.
Public property | TransmissionProtocol | Gets or sets the transport protocol used for CAN communication.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.Active Property

WorkerActive Property

Gets the activation status of this Worker object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool Active { get; }
Public ReadOnly Property Active As Boolean
    Get
public:
property bool Active {
    bool get ();
}

Property Value

Boolean
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.AllowEchoFrames Property

WorkerAllowEchoFrames Property

Enables or disables receiving echo frames (see Echo).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool AllowEchoFrames { get; set; }
Public Property AllowEchoFrames As Boolean
    Get
    Set
public:
property bool AllowEchoFrames {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.AllowErrorFrames Property

WorkerAllowErrorFrames Property

Enables or disables receiving error frames (see Error).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool AllowErrorFrames { get; set; }
Public Property AllowErrorFrames As Boolean
    Get
    Set
public:
property bool AllowErrorFrames {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.AllowRemoteRequestFrames Property

WorkerAllowRemoteRequestFrames Property

Enables or disables receiving remote request frames (see RemoteRequest).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool AllowRemoteRequestFrames { get; set; }
Public Property AllowRemoteRequestFrames As Boolean
    Get
    Set
public:
property bool AllowRemoteRequestFrames {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.AllowStatusFrames Property

WorkerAllowStatusFrames Property

Enables or disables receiving status frames (see Status).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool AllowStatusFrames { get; set; }
Public Property AllowStatusFrames As Boolean
    Get
    Set
public:
property bool AllowStatusFrames {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.BitrateCan Property

WorkerBitrateCan Property

Gets or sets the bit rate used for classic CAN 2.0A/B data transmission (see Bitrate).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public Bitrate BitrateCan { get; set; }
Public Property BitrateCan As Bitrate
    Get
    Set
public:
property Bitrate BitrateCan {
    Bitrate get ();
    void set (Bitrate value);
}

Property Value

Bitrate
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.BitrateCanFd Property

WorkerBitrateCanFd Property

Gets or sets the bit rate used for CAN FD data transmission (see BitrateFD).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public string BitrateCanFd { get; set; }
Public Property BitrateCanFd As String
    Get
    Set
public:
property String^ BitrateCanFd {
    String^ get ();
    void set (String^ value);
}

Property Value

String
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.BroadcastCount Property

WorkerBroadcastCount Property

Retrieves the total amount of periodic messages currently configured within this object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int BroadcastCount { get; }
Public ReadOnly Property BroadcastCount As Integer
    Get
public:
property int BroadcastCount {
    int get ();
}

Property Value

Int32
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.Channel Property

WorkerChannel Property

Gets or set the PCAN Channel used for CAN communication.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public PcanChannel Channel { get; set; }
Public Property Channel As PcanChannel
    Get
    Set
public:
property PcanChannel Channel {
    PcanChannel get ();
    void set (PcanChannel value);
}

Property Value

PcanChannel
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.ExceptionLanguage Property

WorkerExceptionLanguage Property

Specifies the language used for exception texts formatting.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public OutputLanguage ExceptionLanguage { get; set; }
Public Property ExceptionLanguage As OutputLanguage
    Get
    Set
public:
property OutputLanguage ExceptionLanguage {
    OutputLanguage get ();
    void set (OutputLanguage value);
}

Property Value

OutputLanguage
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.ListenOnly Property

WorkerListenOnly Property

Configures the CAN feature listen-only in the associated PCAN Channel.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool ListenOnly { get; set; }
Public Property ListenOnly As Boolean
    Get
    Set
public:
property bool ListenOnly {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.MessageBroadcasting Property

WorkerMessageBroadcasting Property

Enables or disables the sending of periodic messages.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool MessageBroadcasting { get; set; }
Public Property MessageBroadcasting As Boolean
    Get
    Set
public:
property bool MessageBroadcasting {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.MessageFetching Property

WorkerMessageFetching Property

Enables or disable the reading of messages.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool MessageFetching { get; set; }
Public Property MessageFetching As Boolean
    Get
    Set
public:
property bool MessageFetching {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.TotalAvailableMessages Property

WorkerTotalAvailableMessages Property

Retrieves the total amount of messages currently contained by this object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int TotalAvailableMessages { get; }
Public ReadOnly Property TotalAvailableMessages As Integer
    Get
public:
property int TotalAvailableMessages {
    int get ();
}

Property Value

Int32
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.TransmissionProtocol Property

WorkerTransmissionProtocol Property

Gets or sets the transport protocol used for CAN communication.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public Protocol TransmissionProtocol { get; set; }
Public Property TransmissionProtocol As Protocol
    Get
    Set
public:
property Protocol TransmissionProtocol {
    Protocol get ();
    void set (Protocol value);
}

Property Value

Protocol
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker Methods

The Worker type exposes the following members.

Methods
 | Name | Description
 | AddBroadcast(Broadcast) | Configures a CAN message to be written periodically.
 | AddBroadcast(PcanMessage, Int32) | Configures a CAN message to be written periodically.
 | AddFilter(FilteringCriterion) | Includes an additional filtering criterion to the message filter of the default receive queue (index 0).
 | AddFilter(Int32, FilteringCriterion) | Configures an additional filtering criterion to the message filter of a receive queue.
 | ClearAllReceiveQueues | Discards all available messages from all receive queues.
 | ClearBroadcasts | Removes all entries from the Worker object's broadcast list.
 | ClearFilters | Removes all filtering criteria from the message filter of the default receive queue (index 0).
 | ClearFilters(Int32) | Removes all filtering criteria from the message filter of the specified receive queue.
 | ClearReceiveQueue | Discards all available messages from the default receive queue (index 0).
 | ClearReceiveQueue(Int32) | Discards all available messages from the given receive queue.
 | Dequeue(PcanMessage, UInt64) | Removes and returns a CAN messages and its timestamp from the default receive queue (index 0).
 | Dequeue(Int32, PcanMessage, UInt64) | Removes and returns a CAN messages and its timestamp from a specific receive queue.
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Finalizes this object. (Overrides ObjectFinalize)
 | GetAvailableMessagesCount | Retrieves the amount of available messages currently contained in the default receive queue (index 0).
 | GetAvailableMessagesCount(Int32) | Retrieves the amount of available messages currently contained in the specified receive queue.
 | GetBroadcast | Retrieves a Broadcast object from the periodic CAN messages list.
 | GetFilters | Retrieves the current configured filtering criteria for the default receive queue (index 0).
 | GetFilters(Int32) | Retrieves the current configured filtering criteria of a specific receive queue.
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
 | PauseBroadcast | Temporarily stops sending a periodic CAN message.
 | RemoveBroacast(Broadcast) | Removes a periodic CAN message from the list of registered Broadcast objects.
 | RemoveBroacast(Int32) | Removes a periodic CAN message from the list of registered Broadcast objects.
 | RemoveFilter(FilteringCriterion) | Removes a filtering criterion from the message filter of the default receive queue (index 0).
 | RemoveFilter(Int32, FilteringCriterion) | Removes a filtering criterion from the message filter of the specified receive queue.
 | ResetHardware | Performs a reset of the CAN controller on the hardware connected by the Worker object.
 | ResetHardware(PcanStatus) | Performs a reset of the CAN controller on the hardware connected by the Worker object.
 | ResumeBroadcast | Resumes the sending of a paused periodic CAN message.
 | SetFilteringState(FilteringState, Boolean) | Configures the behavior of the message filter for the default receive queue (index 0).
 | SetFilteringState(Int32, FilteringState, Boolean) | Configures the behavior of the message filter for a specific receive queue.
 | Start | Establishes a connection to a PCAN Channel, configures it for data transmission and starts the read/write processes.
 | Stop | Disconnects the used PCAN Channel and stops reading and writing data.
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
 | Transmit(PcanMessage) | Places a CAN message into the transmit queue of the device driver to be written as soon as possible.
 | Transmit(PcanMessage, PcanStatus) | Places a CAN message into the transmit queue of the device driver to be written as soon as possible.
 | UpdateBroadcast(Int32, PcanMessage) | Adjusts the content of a periodic CAN message from the list of registered Broadcast objects.
 | UpdateBroadcast(Int32, Int32) | Adjusts the sending interval of a periodic CAN message from the list of registered Broadcast objects.
 | UpdateBroadcast(Int32, Int32, PcanMessage) | Adjusts the configuration of a periodic CAN message from the list of registered Broadcast objects.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.AddBroadcast Method

WorkerAddBroadcast Method

Overload List
Name | Description
AddBroadcast(Broadcast) | Configures a CAN message to be written periodically.
AddBroadcast(PcanMessage, Int32) | Configures a CAN message to be written periodically.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.AddBroadcast(Broadcast) Method

WorkerAddBroadcast(Broadcast) Method

Configures a CAN message to be written periodically.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool AddBroadcast(
    ref Broadcast frame
)
Public Function AddBroadcast (
    ByRef frame As Broadcast
) As Boolean
public:
bool AddBroadcast(
    Broadcast^% frame
)

Parameters

frame Broadcast
Represents a periodic CAN message.

Return Value

Boolean
true if the Broadcast object was configured; false otherwise.
Exceptions
Exception | Condition
ArgumentOutOfRangeException | The Interval value is out of range. This must be in the range [1...MaxValue].
ArgumentNullException | The Message value of the frame parameter is null. An object of type PcanMessage is required.
ArgumentException | The Broadcast object represented by the frame parameter is already registered.
Remarks

The amount of Broadcast that can be registered is limited by MaximumBroadcastCount. Trying to configure more than that causes this method to fail.

The accuracy of the transmission interval when using Broadcast objects depend on the amount of data being transmitted and fill state of the driver's transmit queue.

The transmit queue of the driver has a size of 1 MB, enough to allocate up to 32.768 classic CAN messages or 13.000 CAN FD messages. This queue is constantly in observation so that any new entry is processed and physically sent as fast as possible.

The Worker object uses a performance timer to check the time expiration of registered Broadcast objects. When a Broadcast object time outs, the associated CAN message is placed in the device driver's transmit queue, as if the Write method had just been called.

Single Broadcast objects can be temporarily deactivated using the PauseBroadcast method and reactivated again using the ResumeBroadcast method. Using the property MessageBroadcasting is possible to activate/deactivate the Broadcast object processing.

Note Note
If a Broadcast object represents a CAN FD message but the PCAN Channel used was not initialized with support for CAN FD, it is automatically deactivated (paused), when this situation is detected.
Example

The following example shows how to configure a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create a Broadcast object using a CAN message and its interval
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);
Broadcast broadcast = new Broadcast(message, 100);

// Add the new broadcast using a Broadcast object
//
if (!myWorker.AddBroadcast(ref broadcast))
{
    Console.WriteLine("The broadcast couldn't be configured");
}
else
{
    Console.WriteLine($"The broadcast object with index '{broadcast.Index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();
        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create a Broadcast object using a CAN message and its interval
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)
Dim broadcast As Broadcast = New Broadcast(message, 100)

' Add the new broadcast using a Broadcast object
'
If Not myWorker.AddBroadcast(broadcast) Then
    Console.WriteLine("The broadcast couldn't be configured")
Else
    Console.WriteLine($"The broadcast object with index '{broadcast.Index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create a Broadcast object using a CAN message and its interval
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte> { 1, 2, 3 }, false);
Broadcast^ broadcast = gcnew Broadcast(message, 100);

// Add the new broadcast using a Broadcast object
//
if (!myWorker->AddBroadcast(broadcast))
{
    Console::WriteLine("The broadcast couldn't be configured");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", broadcast->Index);

    try
    {
        // Activate the worker object
        //
        myWorker->Start(false, false, false);
        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
AddBroadcast Overload
Peak.Can.Basic Namespace
RemoveBroacast
ClearBroadcasts
MessageBroadcasting


Worker.AddBroadcast(PcanMessage, Int32) Method

WorkerAddBroadcast(PcanMessage, Int32) Method

Configures a CAN message to be written periodically.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int AddBroadcast(
    PcanMessage message,
    int interval
)
Public Function AddBroadcast (
    message As PcanMessage,
    interval As Integer
) As Integer
public:
int AddBroadcast(
    PcanMessage^ message,
    int interval
)

Parameters

message PcanMessage
Represents the CAN message to be written when the given interval expires.
interval Int32
Represents the interval used to write the message periodically.

Return Value

Int32
The index of the registered Broadcast object; -1 otherwise.
Exceptions
Exception | Condition
ArgumentOutOfRangeException | The interval parameter value is out of range. This must be in the range [1...MaxValue].
ArgumentNullException | The message parameter value is null. An object of type PcanMessage is required.
Remarks

The amount of Broadcast that can be registered is limited by MaximumBroadcastCount. Trying to configure more than that causes this method to fail.

The accuracy of the transmission interval when using Broadcast objects depend on the amount of data being transmitted and fill state of the driver's transmit queue.

The transmit queue of the driver has a size of 1 MB, enough to allocate up to 32.768 classic CAN messages or 13.000 CAN FD messages. This queue is constantly in observation so that any new entry is processed and physically sent as fast as possible.

The Worker object uses a performance timer to check the time expiration of registered Broadcast objects. When a Broadcast object time outs, the associated CAN message is placed in the device driver's transmit queue, as if the Write method had just been called.

Single Broadcast objects can be temporarily deactivated using the PauseBroadcast method and reactivated again using the ResumeBroadcast method. Using the property MessageBroadcasting is possible to activate/deactivate the Broadcast object processing.

Note Note
If a Broadcast object represents a CAN FD message but the PCAN Channel used was not initialized with support for CAN FD, it is automatically deactivated (paused), when this situation is detected.
Example

The following example shows how to configure a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create the CAN message to broadcast
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker.AddBroadcast(message, 100);
if (index < 0)
{
    Console.WriteLine("The broadcast couldn't be configured");
}
else
{
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();
        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create the CAN message to broadcast
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

' Add the new broadcast using a CAN message and its interval
'
Dim index As Integer = myWorker.AddBroadcast(message, 100)

If index < 0 Then
    Console.WriteLine("The broadcast couldn't be configured")
Else
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create the CAN message to broadcast
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker->AddBroadcast(message, 100);
if (index < 0)
{
    Console::WriteLine("The broadcast couldn't be configured");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", index);

    try
    {
        // Activate the worker object
        //
        myWorker->Start(false, false, false);
        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
AddBroadcast Overload
Peak.Can.Basic Namespace
RemoveBroacast
ClearBroadcasts
MessageBroadcasting


Worker.AddFilter Method

WorkerAddFilter Method

Overload List
Name | Description
AddFilter(FilteringCriterion) | Includes an additional filtering criterion to the message filter of the default receive queue (index 0).
AddFilter(Int32, FilteringCriterion) | Configures an additional filtering criterion to the message filter of a receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.AddFilter(FilteringCriterion) Method

WorkerAddFilter(FilteringCriterion) Method

Includes an additional filtering criterion to the message filter of the default receive queue (index 0).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool AddFilter(
    FilteringCriterion filter
)
Public Function AddFilter (
    filter As FilteringCriterion
) As Boolean
public:
bool AddFilter(
    FilteringCriterion filter
)

Parameters

filter FilteringCriterion
A FilteringCriterion value representing a filter criterion.

Return Value

Boolean
A value indicating whether the filtering criterion was successfully added or not.
Remarks

The Worker registers 'ReceiveQueuesCount' receive queues. These are 0-indexed. The first queue (index 0) is open by default when the object is created, meaning, its message filter is set to PassForAll. All other queues remain closed, that is, their filters are configured as BlockForAll. The methods associated with a receive queue are overloaded, allowing either the direct use of the default queue (index 0) without specifying an index, or the use of a specific queue by passing an index.

To allow a message filter to apply filtering criteria, the status of it must be Inspect.

Duplicate filter criteria are not allowed. Attempting to include an item that already exists causes this method to fail.

Important note Important
Each time a filtering criterion is added using AddFilter the state of the message filter of the associated receive queue is automatically set to Inspect.
Note Note
Filtering criteria with Behavior equals to Exclude are validated first. If there is no match, those with Behavior equals to Include are validated. The criteria are validated in the same order as they were registered, the oldest registered criterion is validated first, the newest one is validated last.
Important note Important
If only exclusive filter criteria are used, messages that do not match any of them will be accepted and placed in the receive queue.
Example

The following example shows how to configure the message filter of the default receive queue to avoid receiving messages with extended IDs 0x00000010, 0x00000011, and 0x00000012.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the default receive queue to discard messages
// with extended IDs 0x00000010, 0x00000011, and 0x00000012
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetIdRange(0x10, 0x12, FilterMode.Extended, FilterBehavior.Exclude);
if(!myWorker.AddFilter(criterion))
    Console.WriteLine($"The given filter is already registered.");
else
    Console.WriteLine($"Filter configured successfully.");

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully - Messages with extended ID 10h, 11h, and 12h are being ignored.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the default receive queue to discard messages
' with extended IDs 0x00000010, 0x00000011, and 0x00000012
'
Dim criterion As FilteringCriterion = New FilteringCriterion()
criterion.SetIdRange(&H10, &H12, FilterMode.Extended, FilterBehavior.Exclude)
If Not myWorker.AddFilter(criterion) Then
    Console.WriteLine($"The given filter is already registered.")
Else
    Console.WriteLine($"Filter configured successfully.")
End If

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully - Messages with extended ID 10h, 11h, and 12h are being ignored.")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the default receive queue to discard messages
// with extended IDs 0x00000010, 0x00000011, and 0x00000012
//
FilteringCriterion criterion;
criterion.SetIdRange(0x10, 0x12, FilterMode::Extended, FilterBehavior::Exclude);
if (!myWorker->AddFilter(criterion))
    Console::WriteLine("The given filter is already registered.");
else
    Console::WriteLine("Filter configured successfully.");

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully - Two receive queues are used.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
AddFilter Overload
Peak.Can.Basic Namespace
SetFilteringState
GetFilters
RemoveFilter


Worker.AddFilter(Int32, FilteringCriterion) Method

WorkerAddFilter(Int32, FilteringCriterion) Method

Configures an additional filtering criterion to the message filter of a receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool AddFilter(
    int queueIndex,
    FilteringCriterion filter
)
Public Function AddFilter (
    queueIndex As Integer,
    filter As FilteringCriterion
) As Boolean
public:
bool AddFilter(
    int queueIndex,
    FilteringCriterion filter
)

Parameters

queueIndex Int32
Zero-based index that identifies the receive queue to be configured.
filter FilteringCriterion
A FilteringCriterion value representing a filter criterion.

Return Value

Boolean
A value indicating whether the filtering criterion was successfully added or not.
Exceptions
Exception | Condition
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1].
Remarks

The Worker registers 'ReceiveQueuesCount' receive queues. These are 0-indexed. The first queue (index 0) is open by default when the object is created, meaning, its message filter is set to PassForAll. All other queues remain closed, that is, their filters are configured as BlockForAll. The methods associated with a receive queue are overloaded, allowing either the direct use of the default queue (index 0) without specifying an index, or the use of a specific queue by passing an index.

To allow a message filter to apply filtering criteria, the status of it must be Inspect.

Duplicate filter criteria are not allowed. Attempting to include an item that already exists causes this method to fail.

Important note Important
Each time a filtering criterion is added using AddFilter the state of the message filter of the associated receive queue is automatically set to Inspect.
Note Note
Filtering criteria with Behavior equals to Exclude are validated first. If there is no match, those with Behavior equals to Include are validated. The criteria are validated in the same order as they were registered, the oldest registered criterion is validated first, the newest one is validated last.
Important note Important
If only exclusive filter criteria are used, messages that do not match any of them will be accepted and placed in the receive queue..
Example

The following example shows how to configure the message filter of the second receive queue to avoid receiving messages with extended IDs 0x00000010, 0x00000011, and 0x00000012.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the second receive queue (index 1) to discard messages
// with extended IDs 0x00000010, 0x00000011, and 0x00000012
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetIdRange(0x10, 0x12, FilterMode.Extended, FilterBehavior.Exclude);
if (!myWorker.AddFilter(1, criterion))
    Console.WriteLine($"The given filter is already registered.");
else
    Console.WriteLine($"Filter configured successfully.");

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully - Messages with extended ID 10h, 11h, and 12h are being ignored.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the second receive queue (index 1) to discard messages
' with extended IDs 0x00000010, 0x00000011, and 0x00000012
'
Dim criterion As FilteringCriterion = New FilteringCriterion()
criterion.SetIdRange(&H10, &H12, FilterMode.Extended, FilterBehavior.Exclude)
If Not myWorker.AddFilter(1, criterion) Then
    Console.WriteLine($"The given filter is already registered.")
Else
    Console.WriteLine($"Filter configured successfully.")
End If

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully - Messages with extended ID 10h, 11h, and 12h are being ignored.")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the second receive queue (index 1) to discard messages
// with extended IDs 0x00000010, 0x00000011, and 0x00000012
//
FilteringCriterion criterion;
criterion.SetIdRange(0x10, 0x12, FilterMode::Extended, FilterBehavior::Exclude);
if (!myWorker->AddFilter(1, criterion))
    Console::WriteLine("The given filter is already registered.");
else
    Console::WriteLine("Filter configured successfully.");

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully - Two receive queues are used.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch(Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
AddFilter Overload
Peak.Can.Basic Namespace
SetFilteringState
GetFilters
RemoveFilter


Worker.ClearAllReceiveQueues Method

WorkerClearAllReceiveQueues Method

Discards all available messages from all receive queues.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void ClearAllReceiveQueues()
Public Sub ClearAllReceiveQueues
public:
void ClearAllReceiveQueues()
Remarks
Unlike the Api class, the Worker class doesn't clear the receive queues on disconnect. A Worker object muss explicitly be instructed to clear its receive queues when deactivating the connection, i.e. by calling the Stop method, or by calling the ClearReceiveQueue/ClearAllReceiveQueues methods at any time.

This implies, that an application can keep processing messages after a connection to a PCAN Channel has been terminated.

Example

The following example shows how to clear all receive queues.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Set the second filter (index 1) to pass all messages
    //
    myWorker.SetFilteringState(1, FilteringState.PassForAll);

    // Wait for sometime to get messages in the receive queue
    //
    Console.WriteLine("Waiting for messages......");
    System.Threading.Thread.Sleep(5000);

    // Get and show the amount of messages contained in the first and second receive queues
    //
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the first receive queue. ");
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue. ");

    // Clear all receive queues and show the amount of messages in them again
    //
    myWorker.ClearAllReceiveQueues();
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the first receive queue. ");
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue. ");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Set the second filter (index 1) to pass all messages
    '
    myWorker.SetFilteringState(1, FilteringState.PassForAll)

    ' Wait for sometime to get messages in the receive queue
    '
    Console.WriteLine("Waiting for messages......")
    Threading.Thread.Sleep(5000)

    ' Get And show the amount of messages contained in the first And second receive queues
    '
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the first receive queue. ")
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue. ")

    ' Clear all receive queues and show the amount of messages in them again
    '
    myWorker.ClearAllReceiveQueues()
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the first receive queue.")
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue.")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Set the second filter (index 1) to pass all messages
    //
    myWorker->SetFilteringState(1, FilteringState::PassForAll, false);

    // Wait for sometime to get messages in the receive queue
    //
    Console::WriteLine("Waiting for messages......");
    System::Threading::Thread::Sleep(5000);

    // Get and show the amount of messages contained in the first and second receive queues
    //
    Console::WriteLine("There are {0} messages in the first receive queue. ", myWorker->GetAvailableMessagesCount());
    Console::WriteLine("There are {0} messages in the second receive queue. ", myWorker->GetAvailableMessagesCount(1));

    // Clear all receive queues and show the amount of messages in them again
    //
    myWorker->ClearAllReceiveQueues();
    Console::WriteLine("There are {0} messages in the first receive queue. ", myWorker->GetAvailableMessagesCount());
    Console::WriteLine("There are {0} messages in the second receive queue. ", myWorker->GetAvailableMessagesCount(1));

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
Peak.Can.Basic Namespace
ClearReceiveQueue


Worker.ClearBroadcasts Method

WorkerClearBroadcasts Method

Removes all entries from the Worker object's broadcast list.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void ClearBroadcasts()
Public Sub ClearBroadcasts
public:
void ClearBroadcasts()
Example

The following example shows how to clear the Worker object's broadcast list.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create a Broadcast object using a CAN message and its interval
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);
Broadcast broadcast = new Broadcast(message, 100);

// Add the new broadcast using a Broadcast object
//
if (!myWorker.AddBroadcast(ref broadcast))
{
    Console.WriteLine("The first broadcast couldn't be configured.");
}
else
{
    Console.WriteLine($"The broadcast object with index '{broadcast.Index}' was configured successfully.");

    // add a second broadcast
    //
    PcanMessage message2 = new PcanMessage(0x200, MessageType.Standard, 8, new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 }, false);
    Broadcast broadcast2 = new Broadcast(message2, 500);
    if (!myWorker.AddBroadcast(ref broadcast2))
    {
        Console.WriteLine("The second broadcast couldn't be configured.");
    }
    else
    {
        Console.WriteLine($"The broadcast object with index '{broadcast2.Index}' was configured successfully.");

        try
        {
            // Activate the worker object
            //
            myWorker.Start();
            Console.WriteLine("The Worker object was activated successfully.");

            // Wait sometime for the messages to be sent several times
            //
            Console.WriteLine("Broadcasting ....");
            System.Threading.Thread.Sleep(5000);

            // Clear all broadcasts
            //
            myWorker.ClearBroadcasts();
            Console.WriteLine("All broadcast objects were removed.");

            // Wait sometime to validate that the message is not sent anymore
            //
            System.Threading.Thread.Sleep(3000);

            // Deactivate the worker object, when it is no longer needed
            //
            myWorker.Stop();
            Console.WriteLine("The Worker object was deactivated.");
        }
        catch(Exception ex)
        {
            Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
        }
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create a Broadcast object using a CAN message and its interval
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)
Dim broadcast As Broadcast = New Broadcast(message, 100)

' Add the new broadcast using a Broadcast object
'
If Not myWorker.AddBroadcast(broadcast) Then
    Console.WriteLine("The first broadcast couldn't be configured.")
Else
    Console.WriteLine($"The broadcast object with index '{broadcast.Index}' was configured successfully.")

    ' add a second broadcast
    '
    Dim message2 As PcanMessage = New PcanMessage(&H200, MessageType.Standard, 8, New Byte() {8, 7, 6, 5, 4, 3, 2, 1}, False)
    Dim broadcast2 As Broadcast = New Broadcast(message2, 500)
    If Not myWorker.AddBroadcast(broadcast2) Then
        Console.WriteLine("The second broadcast couldn't be configured.")
    Else
        Console.WriteLine($"The broadcast object with index '{broadcast2.Index}' was configured successfully.")

        Try
            ' Activate the worker object
            '
            myWorker.Start()
            Console.WriteLine("The Worker object was activated successfully.")

            ' Wait sometime for the messages to be sent several times
            '
            Console.WriteLine("Broadcasting ....")
            Threading.Thread.Sleep(5000)

            ' Clear all broadcasts
            '
            myWorker.ClearBroadcasts()
            Console.WriteLine("All broadcast objects were removed.")

            ' Wait sometime to validate that the message is not sent anymore
            '
            Threading.Thread.Sleep(3000)

            ' Deactivate the worker object, when it is no longer needed
            '
            myWorker.[Stop]()
            Console.WriteLine("The Worker object was deactivated.")
        Catch ex As Exception
            Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
        End Try
    End If
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create a Broadcast object using a CAN message and its interval
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);
Broadcast^ broadcast = gcnew Broadcast(message, 100);

// Add the new broadcast using a Broadcast object
//
if (!myWorker->AddBroadcast(broadcast))
{
    Console::WriteLine("The first broadcast couldn't be configured.");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", broadcast->Index);

    // add a second broadcast
    //
    PcanMessage^ message2 = gcnew PcanMessage(0x200, MessageType::Standard, 8, gcnew array<Byte>{ 8, 7, 6, 5, 4, 3, 2, 1 }, false);
    Broadcast^ broadcast2 = gcnew Broadcast(message2, 500);
    if (!myWorker->AddBroadcast(broadcast2))
    {
        Console::WriteLine("The second broadcast couldn't be configured.");
    }
    else
    {
        Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", broadcast2->Index);

        try
        {
            // Activate the worker object
            //
            myWorker->Start(false, false, false);

            Console::WriteLine("The Worker object was activated successfully.");

            // Wait sometime for the messages to be sent several times
            //
            Console::WriteLine("Broadcasting ....");
            System::Threading::Thread::Sleep(5000);

            // Clear all broadcasts
            //
            myWorker->ClearBroadcasts();
            Console::WriteLine("All broadcast objects were removed.");

            // Wait sometime to validate that the message is not sent anymore
            //
            System::Threading::Thread::Sleep(3000);

            // Deactivate the worker object, when it is no longer needed
            //
            myWorker->Stop(false, false, false);
            Console::WriteLine("The Worker object was deactivated.");
        }
        catch (Exception^ ex)
        {
            Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
        }
    }
}
See Also

Reference

Worker Class
Peak.Can.Basic Namespace
AddBroadcast


Worker.ClearFilters Method

WorkerClearFilters Method

Overload List
Name | Description
ClearFilters | Removes all filtering criteria from the message filter of the default receive queue (index 0).
ClearFilters(Int32) | Removes all filtering criteria from the message filter of the specified receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.ClearFilters Method

WorkerClearFilters Method

Removes all filtering criteria from the message filter of the default receive queue (index 0).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void ClearFilters()
Public Sub ClearFilters
public:
void ClearFilters()
Example

The following example shows how to remove all filtering criteria from the message filter of the default receive queue (index 0).

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the default receive queue (index 0) to receive only echo messages with ID 0x15
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include);
if (myWorker.AddFilter(criterion))
{
    criterion.SetSingleId(0x15, FilterMode.Extended);
    if (myWorker.AddFilter(criterion))
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
    else
        Console.WriteLine("The given filter is already registered.");
}
else
    Console.WriteLine("The given filter is already registered.");

// All filtering criteria from the message filter of the default receive queue (index 0) are removed
//
myWorker.ClearFilters();
Console.WriteLine("All filtering criteria were removed.");
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the default receive queue (index 0) to receive only echo messages with ID 0x15
'
Dim criterion As FilteringCriterion = New FilteringCriterion()
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include)
If myWorker.AddFilter(criterion) Then
    criterion.SetSingleId(&H15, FilterMode.Extended)
    If myWorker.AddFilter(criterion) Then
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...")
    Else
        Console.WriteLine("The given filter is already registered.")
    End If
Else
    Console.WriteLine("The given filter is already registered.")
End If

' All filtering criteria from the message filter of the default receive queue (index 0) are removed
'
myWorker.ClearFilters()
Console.WriteLine("All filtering criteria were removed.")
    // Create the object using the default configuration
    //
    Worker^ myWorker = gcnew Worker();

// Set the filter of the default receive queue (index 0) to receive only echo messages with ID 0x15
//
FilteringCriterion criterion;
criterion.SetMessageType(MessageType::Echo, FilterBehavior::Include);
if (myWorker->AddFilter(criterion))
{
    criterion.SetSingleId(0x15, FilterMode::Extended, FilterBehavior::Include);
    if (myWorker->AddFilter(criterion))
        Console::WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
    else
        Console::WriteLine("The given filter is already registered.");
}
else
    Console::WriteLine("The given filter is already registered.");

// All filtering criteria from the message filter of the default receive queue (index 0) are removed
//
myWorker->ClearFilters();
Console::WriteLine("All filtering criteria were removed.");
See Also

Reference

Worker Class
ClearFilters Overload
Peak.Can.Basic Namespace
SetFilteringState
AddFilter
RemoveFilter


Worker.ClearFilters(Int32) Method

WorkerClearFilters(Int32) Method

Removes all filtering criteria from the message filter of the specified receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void ClearFilters(
    int queueIndex
)
Public Sub ClearFilters (
    queueIndex As Integer
)
public:
void ClearFilters(
    int queueIndex
)

Parameters

queueIndex Int32
Zero-based index that identifies the receive queue whose filter criteria are to be removed.
Exceptions
Exception | Condition
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1].
Example

The following example shows how to remove all filtering criteria from the message filter of the second receive queue (index 1).

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the second receive queue (index 1) to receive only echo messages with ID 0x15
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include);
if (myWorker.AddFilter(1, criterion))
{
    criterion.SetSingleId(0x15, FilterMode.Extended);
    if (myWorker.AddFilter(1, criterion))
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
    else
        Console.WriteLine("The given filter is already registered.");
}
else
    Console.WriteLine("The given filter is already registered.");

// All filtering criteria from the message filter of the second receive queue (index 1) are removed
//
myWorker.ClearFilters(1);
Console.WriteLine("All filtering criteria were removed.");
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the second receive queue (index 1) to receive only echo messages with ID 0x15
'
Dim criterion As FilteringCriterion = New FilteringCriterion()
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include)
If myWorker.AddFilter(1, criterion) Then
    criterion.SetSingleId(&H15, FilterMode.Extended)
    If myWorker.AddFilter(1, criterion) Then
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...")
    Else
        Console.WriteLine("The given filter is already registered.")
    End If
Else
    Console.WriteLine("The given filter is already registered.")
End If

' All filtering criteria from the message filter of the second receive queue (index 1) are removed
'
myWorker.ClearFilters(1)
Console.WriteLine("All filtering criteria were removed.")
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the default receive queue (index 0) to receive only echo messages with ID 0x15
//
FilteringCriterion criterion;
criterion.SetMessageType(MessageType::Echo, FilterBehavior::Include);
if (myWorker->AddFilter(1, criterion))
{
    criterion.SetSingleId(0x15, FilterMode::Extended, FilterBehavior::Include);
    if (myWorker->AddFilter(1, criterion))
        Console::WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
    else
        Console::WriteLine("The given filter is already registered.");
}
else
    Console::WriteLine("The given filter is already registered.");

// All filtering criteria from the message filter of the default receive queue (index 0) are removed
//
myWorker->ClearFilters(1);
Console::WriteLine("All filtering criteria were removed.");
See Also

Reference

Worker Class
ClearFilters Overload
Peak.Can.Basic Namespace
SetFilteringState
AddFilter
RemoveFilter


Worker.ClearReceiveQueue Method

WorkerClearReceiveQueue Method

Overload List
Name | Description
ClearReceiveQueue | Discards all available messages from the default receive queue (index 0).
ClearReceiveQueue(Int32) | Discards all available messages from the given receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.ClearReceiveQueue Method

WorkerClearReceiveQueue Method

Discards all available messages from the default receive queue (index 0).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void ClearReceiveQueue()
Public Sub ClearReceiveQueue
public:
void ClearReceiveQueue()
Remarks
Unlike the Api class, the Worker class doesn't clear the receive queues on disconnect. A Worker object muss explicitly be instructed to clear its receive queues when deactivating the connection, i.e. by calling the Stop method, or by calling the ClearReceiveQueue/ClearAllReceiveQueues methods at any time.

This implies, that an application can keep processing messages after a connection to a PCAN Channel has been terminated.

Example

The following example shows how to clear the default receive queue (index 0).

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Wait for sometime to get messages in the receive queue
    //
    Console.WriteLine("Waiting for messages......");
    System.Threading.Thread.Sleep(5000);

    // Get and show the amount of messages contained in the default receive queue (index 0)
    //
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the default receive queue. ");

    // Clear the default receive queue and show the amount of messages in it again
    //
    myWorker.ClearReceiveQueue();
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the default receive queue, after clearing it. ");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Wait for sometime to get messages in the receive queue
    '
    Console.WriteLine("Waiting for messages......")
    Threading.Thread.Sleep(5000)

    ' Get and show the amount of messages contained in the default receive queue (index 0)
    '
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(0)} messages in the default receive queue. ")

    ' Clear the second receive queue and show the amount of messages in it again
    '
    myWorker.ClearReceiveQueue()
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the default receive queue, after clearing it. ")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Wait for sometime to get messages in the receive queue
    //
    Console::WriteLine("Waiting for messages......");
    System::Threading::Thread::Sleep(5000);

    // Get and show the amount of messages contained in the default receive queue (index 0)
    //
    Console::WriteLine("There are {0} messages in the default receive queue. ", myWorker->GetAvailableMessagesCount());

    //  Clear the default receive queue and show the amount of messages in it again
    //
    myWorker->ClearReceiveQueue();
    Console::WriteLine("There are {0} messages in the default receive queue, after clearing it. ", myWorker->GetAvailableMessagesCount());

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
ClearReceiveQueue Overload
Peak.Can.Basic Namespace
ClearAllReceiveQueues


Worker.ClearReceiveQueue(Int32) Method

WorkerClearReceiveQueue(Int32) Method

Discards all available messages from the given receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void ClearReceiveQueue(
    int queueIndex
)
Public Sub ClearReceiveQueue (
    queueIndex As Integer
)
public:
void ClearReceiveQueue(
    int queueIndex
)

Parameters

queueIndex Int32
Index of the receive queue whose messages are to be discarded
Exceptions
Exception | Condition
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1].
Remarks
Unlike the Api class, the Worker class doesn't clear the receive queues on disconnect. A Worker object muss explicitly be instructed to clear its receive queues when deactivating the connection, i.e. by calling the Stop method, or by calling the ClearReceiveQueue/ClearAllReceiveQueues methods at any time.

This implies, that an application can keep processing messages after a connection to a PCAN Channel has been terminated.

Example

The following example shows how to clear the second receive queue (index 1).

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Set the second filter (index 1) to pass all messages
    //
    myWorker.SetFilteringState(1, FilteringState.PassForAll);

    // Wait for sometime to get messages in the receive queue
    //
    Console.WriteLine("Waiting for messages......");
    System.Threading.Thread.Sleep(5000);

    // Get and show the amount of messages contained in the first and second receive queues
    //
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the first receive queue. ");
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue. ");

    // Clear the second receive queue and show the amount of messages in the queues again
    //
    myWorker.ClearReceiveQueue(1);
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the first receive queue. ");
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue, after clearing it. ");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Set the second filter (index 1) to pass all messages
    '
    myWorker.SetFilteringState(1, FilteringState.PassForAll)

    ' Wait for sometime to get messages in the receive queue
    '
    Console.WriteLine("Waiting for messages......")
    Threading.Thread.Sleep(5000)

    ' Get And show the amount of messages contained in the first And second receive queues
    '
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the first receive queue. ")
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue. ")

    ' Clear the second receive queue and show the amount of messages in the queues again
    '
    myWorker.ClearReceiveQueue(1)
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the first receive queue. ")
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue, after clearing it. ")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Set the second filter (index 1) to pass all messages
    //
    myWorker->SetFilteringState(1, FilteringState::PassForAll, false);

    // Wait for sometime to get messages in the receive queue
    //
    Console::WriteLine("Waiting for messages......");
    System::Threading::Thread::Sleep(5000);

    // Get and show the amount of messages contained in the first and second receive queues
    //
    Console::WriteLine("There are {0} messages in the first receive queue. ", myWorker->GetAvailableMessagesCount());
    Console::WriteLine("There are {0} messages in the second receive queue. ", myWorker->GetAvailableMessagesCount(1));

    // Clear the second receive queue and show the amount of messages in the queues again
    //
    myWorker->ClearReceiveQueue(1);
    Console::WriteLine("There are {0} messages in the first receive queue. ", myWorker->GetAvailableMessagesCount());
    Console::WriteLine("There are {0} messages in the second receive queue, after clearing it. ", myWorker->GetAvailableMessagesCount(1));

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
ClearReceiveQueue Overload
Peak.Can.Basic Namespace
ClearAllReceiveQueues


Worker.Dequeue Method

WorkerDequeue Method

Overload List
Name | Description
Dequeue(PcanMessage, UInt64) | Removes and returns a CAN messages and its timestamp from the default receive queue (index 0).
Dequeue(Int32, PcanMessage, UInt64) | Removes and returns a CAN messages and its timestamp from a specific receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.Dequeue(PcanMessage, UInt64) Method

WorkerDequeue(PcanMessage, UInt64) Method

Removes and returns a CAN messages and its timestamp from the default receive queue (index 0).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool Dequeue(
    out PcanMessage message,
    out ulong timestamp
)
Public Function Dequeue (
    <OutAttribute> ByRef message As PcanMessage,
    <OutAttribute> ByRef timestamp As ULong
) As Boolean
public:
bool Dequeue(
    [OutAttribute] PcanMessage^% message,
    [OutAttribute] unsigned long long% timestamp
)

Parameters

message PcanMessage
A PcanMessage object representing a received CAN message.
timestamp UInt64
The timestamp of the message, in microseconds.
Note Note

On Windows, the timestamp contains the number of microseconds elapsed since system start.

On Linux, the timestamp contains the number of microseconds elapsed since the epoch (00:00 UTC, January 1st 1970).

Return Value

Boolean
true if a message was successfully dequeued; otherwise, false.
Remarks
Unlike the Api class, the Worker class doesn't clear the receive queues on disconnect. A Worker object muss explicitly be instructed to clear its receive queues when deactivating the connection, i.e. by calling the Stop method, or by calling the ClearReceiveQueue/ClearAllReceiveQueues methods at any time.

This implies, that an application can keep processing messages after a connection to a PCAN Channel has been terminated.

Example

The following example shows how to retrieve a message from the default receive queue (index 0).

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();

    Console.WriteLine("The Worker object was activated successfully.");

    // Wait for sometime to get messages in the receive queue
    //
    System.Threading.Thread.Sleep(5000);

    PcanMessage message;
    ulong timestamp;
    if (myWorker.Dequeue(out message, out timestamp))
    {
        Console.WriteLine("New message retrieved. ");
        Console.WriteLine($"Timestamp: {timestamp} | {message}");
    }

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Wait for sometime to get messages in the receive queue
    '
    Threading.Thread.Sleep(5000)

    Dim message As PcanMessage = Nothing
    Dim timestamp As ULong
    If myWorker.Dequeue(message, timestamp) Then
        Console.WriteLine("New message retrieved. ")
        Console.WriteLine($"Timestamp: {timestamp} | {message}")
    End If

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Wait for sometime to get messages in the receive queue
    //
    System::Threading::Thread::Sleep(5000);

    PcanMessage^ message;
    UInt64 timestamp;
    if (myWorker->Dequeue(message, timestamp))
    {
        Console::WriteLine("New message retrieved. ");
        Console::WriteLine("Timestamp: {0} | {1}", timestamp, message);
    }

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
Dequeue Overload
Peak.Can.Basic Namespace
Start
Stop


Worker.Dequeue(Int32, PcanMessage, UInt64) Method

WorkerDequeue(Int32, PcanMessage, UInt64) Method

Removes and returns a CAN messages and its timestamp from a specific receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool Dequeue(
    int queueIndex,
    out PcanMessage message,
    out ulong timestamp
)
Public Function Dequeue (
    queueIndex As Integer,
    <OutAttribute> ByRef message As PcanMessage,
    <OutAttribute> ByRef timestamp As ULong
) As Boolean
public:
bool Dequeue(
    int queueIndex,
    [OutAttribute] PcanMessage^% message,
    [OutAttribute] unsigned long long% timestamp
)

Parameters

queueIndex Int32
Zero-based index that identifies the receive queue from which the message should be taken.
message PcanMessage
A PcanMessage object representing a received CAN message.
timestamp UInt64
The timestamp of the message, in microseconds.
Note Note

On Windows, the timestamp contains the number of microseconds elapsed since system start.

On Linux, the timestamp contains the number of microseconds elapsed since the epoch (00:00 UTC, January 1st 1970).

Return Value

Boolean
true if a message was successfully dequeued; otherwise, false.
Exceptions
Exception | Condition
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1].
Remarks
Unlike the Api class, the Worker class doesn't clear the receive queues on disconnect. A Worker object muss explicitly be instructed to clear its receive queues when deactivating the connection, i.e. by calling the Stop method, or by calling the ClearReceiveQueue/ClearAllReceiveQueues methods at any time.

This implies, that an application can keep processing messages after a connection to a PCAN Channel has been terminated.

Example

The following example shows how to retrieve a message from the second receive queue (index 1).

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();

    Console.WriteLine("The Worker object was activated successfully.");

    // Set the second filter (index 1) to pass all messages
    //
    myWorker.SetFilteringState(1, FilteringState.PassForAll);

    // Wait for sometime to get messages in the receive queue
    //
    System.Threading.Thread.Sleep(5000);

    PcanMessage message;
    ulong timestamp;
    if (myWorker.Dequeue(1, out message, out timestamp))
    {
        Console.WriteLine("New message retrieved. ");
        Console.WriteLine($"Timestamp: {timestamp} | {message}");
    }

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Set the second filter (index 1) to pass all messages
    '
    myWorker.SetFilteringState(1, FilteringState.PassForAll)

    ' Wait for sometime to get messages in the receive queue
    '
    Threading.Thread.Sleep(5000)

    Dim message As PcanMessage = Nothing
    Dim timestamp As ULong
    If myWorker.Dequeue(1, message, timestamp) Then
        Console.WriteLine("New message retrieved. ")
        Console.WriteLine($"Timestamp: {timestamp} | {message}")
    End If

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Set the second filter (index 1) to pass all messages
    //
    myWorker->SetFilteringState(1, FilteringState::PassForAll, false);

    // Wait for sometime to get messages in the receive queue
    //
    System::Threading::Thread::Sleep(5000);

    PcanMessage^ message;
    UInt64 timestamp;
    if (myWorker->Dequeue(1, message, timestamp))
    {
        Console::WriteLine("New message retrieved. ");
        Console::WriteLine("Timestamp: {0} | {1}", timestamp, message);
    }

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
Dequeue Overload
Peak.Can.Basic Namespace
Start
Stop


Worker.Finalize Method

WorkerFinalize Method

Finalizes this object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
protected override void Finalize()
Protected Overrides Sub Finalize
protected:
virtual void Finalize() override

Implements

ObjectFinalize
See Also

Reference

Worker Class
Peak.Can.Basic Namespace
Worker


Worker.GetAvailableMessagesCount Method

WorkerGetAvailableMessagesCount Method

Overload List
Name | Description
GetAvailableMessagesCount | Retrieves the amount of available messages currently contained in the default receive queue (index 0).
GetAvailableMessagesCount(Int32) | Retrieves the amount of available messages currently contained in the specified receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.GetAvailableMessagesCount Method

WorkerGetAvailableMessagesCount Method

Retrieves the amount of available messages currently contained in the default receive queue (index 0).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int GetAvailableMessagesCount()
Public Function GetAvailableMessagesCount As Integer
public:
int GetAvailableMessagesCount()

Return Value

Int32
The amount of messages currently contained in the default receive queue (index 0).
Remarks
Unlike the Api class, the Worker class doesn't clear the receive queues on disconnect. A Worker object muss explicitly be instructed to clear its receive queues when deactivating the connection, i.e. by calling the Stop method, or by calling the ClearReceiveQueue/ClearAllReceiveQueues methods at any time.

This implies, that an application can keep processing messages after a connection to a PCAN Channel has been terminated.

Example

The following example shows how to retrieve the amount of messages contained in the default receive queue (index 0).

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Wait for sometime to get messages in the receive queue
    //
    Console.WriteLine("Waiting for messages......");
    System.Threading.Thread.Sleep(5000);

    // Get and show the amount of messages contained in the default receive queue (index 0)
    //
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the default receive queue. ");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Wait for sometime to get messages in the receive queue
    '
    Console.WriteLine("Waiting for messages......")
    Threading.Thread.Sleep(5000)

    ' Get and show the amount of messages contained in the default receive queue (index 0)
    '
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount()} messages in the default receive queue. ")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    PcanBasicException^ error;
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Wait for sometime to get messages in the receive queue
    //
    Console::WriteLine("Waiting for messages......");
    System::Threading::Thread::Sleep(5000);

    // Get and show the amount of messages contained in the default receive queue (index 0)
    //
    Console::WriteLine("There are {0} messages in the default receive queue. ", myWorker->GetAvailableMessagesCount());

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
GetAvailableMessagesCount Overload
Peak.Can.Basic Namespace
Dequeue
ClearReceiveQueue
SetFilteringState


Worker.GetAvailableMessagesCount(Int32) Method

WorkerGetAvailableMessagesCount(Int32) Method

Retrieves the amount of available messages currently contained in the specified receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int GetAvailableMessagesCount(
    int queueIndex
)
Public Function GetAvailableMessagesCount (
    queueIndex As Integer
) As Integer
public:
int GetAvailableMessagesCount(
    int queueIndex
)

Parameters

queueIndex Int32
Zero-based index that identifies the receive queue from which the amount of available messages should be retrieved.

Return Value

Int32
The amount of messages currently contained in the specified receive queue.
Exceptions
Exception | Condition
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1].
Remarks
Unlike the Api class, the Worker class doesn't clear the receive queues on disconnect. A Worker object muss explicitly be instructed to clear its receive queues when deactivating the connection, i.e. by calling the Stop method, or by calling the ClearReceiveQueue/ClearAllReceiveQueues methods at any time.

This implies, that an application can keep processing messages after a connection to a PCAN Channel has been terminated.

Example

The following example shows how to retrieve the amount of messages contained in the second receive queue (index 1).

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Set the second filter (index 1) to pass all messages
    //
    myWorker.SetFilteringState(1, FilteringState.PassForAll);

    // Wait for sometime to get messages in the receive queue
    //
    Console.WriteLine("Waiting for messages......");
    System.Threading.Thread.Sleep(5000);

    // Get and show the amount of messages contained in the second receive queue (index 1)
    //
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue. ");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Set the second filter (index 1) to pass all messages
    '
    myWorker.SetFilteringState(1, FilteringState.PassForAll)

    ' Wait for sometime to get messages in the receive queue
    '
    Console.WriteLine("Waiting for messages......")
    Threading.Thread.Sleep(5000)

    ' Get and show the amount of messages contained in the second receive queue (index 1)
    '
    Console.WriteLine($"There are {myWorker.GetAvailableMessagesCount(1)} messages in the second receive queue. ")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Set the second filter (index 1) to pass all messages
    //
    myWorker->SetFilteringState(1, FilteringState::PassForAll, false);

    // Wait for sometime to get messages in the receive queue
    //
    Console::WriteLine("Waiting for messages......");
    System::Threading::Thread::Sleep(5000);

    // Get and show the amount of messages contained in the second receive queue (index 1)
    //
    Console::WriteLine("There are {0} messages in the second receive queue. ", myWorker->GetAvailableMessagesCount(1));

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
GetAvailableMessagesCount Overload
Peak.Can.Basic Namespace
Dequeue
ClearReceiveQueue
SetFilteringState


Worker.GetBroadcast Method

WorkerGetBroadcast Method

Retrieves a Broadcast object from the periodic CAN messages list.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public Broadcast GetBroadcast(
    int index
)
Public Function GetBroadcast (
    index As Integer
) As Broadcast
public:
Broadcast^ GetBroadcast(
    int index
)

Parameters

index Int32
Represents the zero-based index of the periodic CAN message to be retrieved.

Return Value

Broadcast
A NullableT value with a valid periodic message, otherwise null
Exceptions
Exception | Condition
IndexOutOfRangeException | The index parameter value is out of range. This must be in the range [0...MaximumBroadcastCount-1].
Remarks
Changes made to an object retrieved by this method are automatically updated in the Worker object's broadcast list.
Example

The following example shows how to retrieve a Broadcast object from the Worker object's broadcast list.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create the CAN message to broadcast
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker.AddBroadcast(message, 100);
if (index < 0)
{
    Console.WriteLine("The broadcast couldn't be configured.");
}
else
{
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();
        Console.WriteLine("The Worker object was activated successfully.");

        // Wait some time for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Get the broadcast object to modify it directly
        //
        Broadcast broadcast = myWorker.GetBroadcast(index);

        if (broadcast != null)
        {
            // Update the CAN message being sent and its interval
            //
            broadcast.Message.ID = 0x200;
            broadcast.Message.DLC = 8;
            broadcast.Message.Data = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 };
            broadcast.Interval = 1000;

            // Wait some time for the modified message to be sent several times
            //
            Console.WriteLine("The broadcast object was modified.");
            System.Threading.Thread.Sleep(5000);
        }
        else
        {
            Console.WriteLine($"The broadcast object with index '{index}' could not be retrieved.");
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create the CAN message to broadcast
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

' Add the new broadcast using a CAN message and its interval
'
Dim index As Integer = myWorker.AddBroadcast(message, 100)

If index < 0 Then
    Console.WriteLine("The broadcast couldn't be configured.")
Else
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait some time for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Get the broadcast object to modify it directly
        '
        Dim broadcast As Broadcast = myWorker.GetBroadcast(index)

        If broadcast IsNot Nothing Then
            ' Update the CAN message being sent and its interval
            '
            broadcast.Message.ID = &H200
            broadcast.Message.DLC = 8
            broadcast.Message.Data = New Byte() {8, 7, 6, 5, 4, 3, 2, 1}
            broadcast.Interval = 1000

            ' Wait some time for the modified message to be sent several times
            '
            Console.WriteLine("The broadcast object was modified.")
            Threading.Thread.Sleep(5000)
        Else
            Console.WriteLine($"The broadcast object with index '{index}' could not be retrieved.")
        End If

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create the CAN message to broadcast
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker->AddBroadcast(message, 100);
if (index < 0)
{
    Console::WriteLine("The broadcast couldn't be configured.");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", index);

    try
    {
        // Activate the worker object
        //
        myWorker->Start(false, false, false);

        Console::WriteLine("The Worker object was activated successfully.");

        // Wait some time for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Get the broadcast object to modify it directly
        //
        Broadcast^ broadcast = myWorker->GetBroadcast(index);

        if (broadcast != nullptr)
        {
            // Update the CAN message being sent and its interval
            //
            broadcast->Message->ID = 0x200;
            broadcast->Message->DLC = 8;
            broadcast->Message->Data = gcnew array<Byte>{ 8, 7, 6, 5, 4, 3, 2, 1 };
            broadcast->Interval = 1000;

            // Wait some time for the modified message to be sent several times
            //
            Console::WriteLine("The broadcast object was modified.");
            System::Threading::Thread::Sleep(5000);
        }
        else
        {
            Console::WriteLine("The broadcast object with index '{0}' could not be retrieved.", index);
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch(Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
Peak.Can.Basic Namespace
AddBroadcast
PauseBroadcast
ResumeBroadcast
UpdateBroadcast


Worker.GetFilters Method

WorkerGetFilters Method

Overload List
Name | Description
GetFilters | Retrieves the current configured filtering criteria for the default receive queue (index 0).
GetFilters(Int32) | Retrieves the current configured filtering criteria of a specific receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.GetFilters Method

WorkerGetFilters Method

Retrieves the current configured filtering criteria for the default receive queue (index 0).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public FilteringCriterion[] GetFilters()
Public Function GetFilters As FilteringCriterion()
public:
array<FilteringCriterion>^ GetFilters()

Return Value

FilteringCriterion
An array containing all registered filtering criteria.
Remarks
The FilteringCriterion returned by this methods cannot be modified. If it is desired to change any already registered filter criterion, it has to be removed first using the RemoveFilter method and added again using the AddFilter method.
Example

The following example shows how to configure the message filter of the default receive queue (index 0) to receive only echo messages with extended ID 0x15. After this, the filtering criteria are read and sent to the console output.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the default receive queue (index 0) to receive only echo messages
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include);
if (!myWorker.AddFilter(criterion))
    Console.WriteLine("The given filter is already registered.");
else
    Console.WriteLine("Filter for Echo messages was configured successfully.");

// Set the filter of the default receive queue (index 0) to receive only
// messages with extended ID 0x00000015
//
criterion.SetSingleId(0x15, FilterMode.Extended);
if (!myWorker.AddFilter(criterion))
    Console.WriteLine("The given filter is already registered.");
else
    Console.WriteLine("Filter for messages with extended ID equals to 0x15 was configured successfully.");

// Get and show the filtering criteria
//
Console.WriteLine("Following criteria are configured:");
foreach (FilteringCriterion item in myWorker.GetFilters())
{
    Console.WriteLine($" -> {item}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the default receive queue (index 0) to receive only echo messages
'
Dim criterion As FilteringCriterion = New FilteringCriterion()
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include)
If Not myWorker.AddFilter(criterion) Then
    Console.WriteLine("The given filter is already registered.")
Else
    Console.WriteLine("Filter for Echo messages was configured successfully.")
End If

' Set the filter of the default receive queue (index 0) to receive only
' messages with extended ID 0x00000015
'
criterion.SetSingleId(&H15, FilterMode.Extended)
If Not myWorker.AddFilter(criterion) Then
    Console.WriteLine("The given filter is already registered.")
Else
    Console.WriteLine("Filter for messages with extended ID equals to 0x15 was configured successfully.")
End If

' Get and show the filtering criteria
'
Console.WriteLine("Following criteria are configured:")
For Each item As FilteringCriterion In myWorker.GetFilters()
    Console.WriteLine($" -> {item}")
Next
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the default receive queue (index 0) to receive only echo messages
//
FilteringCriterion criterion;
criterion.SetMessageType(MessageType::Echo, FilterBehavior::Include);
if (!myWorker->AddFilter(criterion))
    Console::WriteLine("The given filter is already registered.");
else
    Console::WriteLine("Filter configured successfully.");

// Set the filter of the default receive queue (index 0) to receive only
// messages with extended ID 0x00000015
//
criterion.SetSingleId(0x15, FilterMode::Extended, FilterBehavior::Include);
if (!myWorker->AddFilter(criterion))
    Console::WriteLine("The given filter is already registered.");
else
    Console::WriteLine("Filter for messages with extended ID equals to 0x15 was configured successfully.");

// Get and show the filtering criteria
//
Console::WriteLine("Following criteria are configured:");
for each(FilteringCriterion item in myWorker->GetFilters())
{
    Console::WriteLine(" -> {0}", item);
}
See Also

Reference

Worker Class
GetFilters Overload
Peak.Can.Basic Namespace
SetFilteringState
AddFilter
RemoveFilter


Worker.GetFilters(Int32) Method

WorkerGetFilters(Int32) Method

Retrieves the current configured filtering criteria of a specific receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public FilteringCriterion[] GetFilters(
    int queueIndex
)
Public Function GetFilters (
    queueIndex As Integer
) As FilteringCriterion()
public:
array<FilteringCriterion>^ GetFilters(
    int queueIndex
)

Parameters

queueIndex Int32
Zero-based index that identifies the receive queue whose filters criteria are to be retrieved.

Return Value

FilteringCriterion
An array containing all registered filtering criteria.
Exceptions
Exception | Condition
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1].
Remarks
The FilteringCriterion returned by this methods cannot be modified. If it is desired to change any already registered filter criterion, it has to be removed first using the RemoveFilter method and added again using the AddFilter method.
Example

The following example shows how to configure the message filter of the second receive queue to receive only echo messages with extended ID 0x15. After this, the filtering criteria are read and sent to the console output.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the second receive queue (index 1) to receive only echo messages
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include);
if (!myWorker.AddFilter(1, criterion))
    Console.WriteLine("The given filter is already registered.");
else
    Console.WriteLine("Filter for Echo messages was configured successfully.");

// Set the filter of the second receive queue (index 1) to receive only
// messages with extended ID 0x00000015
//
criterion.SetSingleId(0x15, FilterMode.Extended);
if (!myWorker.AddFilter(1, criterion))
    Console.WriteLine("The given filter is already registered.");
else
    Console.WriteLine("Filter for messages with extended ID equals to 0x15 was configured successfully.");

// Get and show the filtering criteria
//
Console.WriteLine("Following criteria are configured:");
foreach (FilteringCriterion item in myWorker.GetFilters(1))
{
    Console.WriteLine($" -> {item}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the second receive queue (index 1) to receive only echo messages
'
Dim criterion As FilteringCriterion = New FilteringCriterion()
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include)
If Not myWorker.AddFilter(1, criterion) Then
    Console.WriteLine("The given filter is already registered.")
Else
    Console.WriteLine("Filter for Echo messages was configured successfully.")
End If

' Set the filter of the second receive queue (index 1) to receive only
' messages with extended ID 0x00000015
'
criterion.SetSingleId(&H15, FilterMode.Extended)
If Not myWorker.AddFilter(1, criterion) Then
    Console.WriteLine("The given filter is already registered.")
Else
    Console.WriteLine("Filter for messages with extended ID equals to 0x15 was configured successfully.")
End If

' Get and show the filtering criteria
'
Console.WriteLine("Following criteria are configured:")
For Each item As FilteringCriterion In myWorker.GetFilters(1)
    Console.WriteLine($" -> {item}")
Next
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the second receive queue (index 1) to receive only echo messages
//
FilteringCriterion criterion;
criterion.SetMessageType(MessageType::Echo, FilterBehavior::Include);
if (!myWorker->AddFilter(1, criterion))
    Console::WriteLine("The given filter is already registered.");
else
    Console::WriteLine("Filter configured successfully.");

// Set the filter of the second receive queue (index 1) to receive only
// messages with extended ID 0x00000015
//
criterion.SetSingleId(0x15, FilterMode::Extended, FilterBehavior::Include);
if (!myWorker->AddFilter(1, criterion))
    Console::WriteLine("The given filter is already registered.");
else
    Console::WriteLine("Filter for messages with extended ID equals to 0x15 was configured successfully.");

// Get and show the filtering criteria
//
Console::WriteLine("Following criteria are configured:");
for each (FilteringCriterion item in myWorker->GetFilters(1))
{
    Console::WriteLine(" -> {0}", item);
}
See Also

Reference

Worker Class
GetFilters Overload
Peak.Can.Basic Namespace
SetFilteringState
AddFilter
RemoveFilter


Worker.PauseBroadcast Method

WorkerPauseBroadcast Method

Temporarily stops sending a periodic CAN message.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool PauseBroadcast(
    int index
)
Public Function PauseBroadcast (
    index As Integer
) As Boolean
public:
bool PauseBroadcast(
    int index
)

Parameters

index Int32
Represents the zero-based index of the periodic CAN message to be stopped.

Return Value

Boolean
true if the Broadcast object was deactivated; false otherwise.
Exceptions
Exception | Condition
IndexOutOfRangeException | The index parameter value is out of range. This must be in the range [0...MaximumBroadcastCount-1].
Remarks
This method allows the deactivation of a single broadcast. The property MessageBroadcasting activates/deactivates the broadcasting feature in general.
Example

The following example shows how to deactivate/pause a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create the CAN message to broadcast
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker.AddBroadcast(message, 100);
if (index < 0)
{
    Console.WriteLine("The broadcast couldn't be configured.");
}
else
{
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();

        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Stop sending the CAN message
        //
        if (myWorker.PauseBroadcast(index))
        {
            Console.WriteLine($"The broadcast object with index '{index}' was successfully paused.");

            // Wait sometime to validate that the message is not sent anymore
            //
            System.Threading.Thread.Sleep(3000);

            // Resume sending the CAN message
            //
            if (myWorker.ResumeBroadcast(index))
            {
                // Wait sometime for the message to be sent several times
                //
                Console.WriteLine($"The broadcast object with index '{index}' was successfully resumed.");
                System.Threading.Thread.Sleep(5000);
            }
            else
            {
                Console.WriteLine($"The broadcast object with index '{index}' couldn't be resumed.");
            }
        }
        else
        {
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be paused.");
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create the CAN message to broadcast
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

' Add the new broadcast using a CAN message and its interval
'
Dim index As Integer = myWorker.AddBroadcast(message, 100)

If index < 0 Then
    Console.WriteLine("The broadcast couldn't be configured.")
Else
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Stop sending the CAN message
        '
        If myWorker.PauseBroadcast(index) Then
            Console.WriteLine($"The broadcast object with index '{index}' was successfully paused.")

            ' Wait sometime to validate that the message is not sent anymore
            '
            Threading.Thread.Sleep(3000)

            ' Resume sending the CAN message
            '
            If myWorker.ResumeBroadcast(index) Then
                ' Wait sometime for the message to be sent several times
                '
                Console.WriteLine($"The broadcast object with index '{index}' was successfully resumed.")
                Threading.Thread.Sleep(5000)
            Else
                Console.WriteLine($"The broadcast object with index '{index}' couldn't be resumed.")
            End If
        Else
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be paused.")
        End If

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create the CAN message to broadcast
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker->AddBroadcast(message, 100);
if (index < 0)
{
    Console::WriteLine("The broadcast couldn't be configured.");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", index);

    try
    {

        // Activate the worker object
        //
        myWorker->Start(false, false, false);

        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Stop sending the CAN message
        //
        if (myWorker->PauseBroadcast(index))
        {
            Console::WriteLine("The broadcast object with index '{0}' was successfully paused.", index);

            // Wait sometime to validate that the message is not sent anymore
            //
            System::Threading::Thread::Sleep(3000);

            // Resume sending the CAN message
            //
            if (myWorker->ResumeBroadcast(index))
            {
                // Wait sometime for the message to be sent several times
                //
                Console::WriteLine("The broadcast object with index '{0}' was successfully resumed.", index);
                System::Threading::Thread::Sleep(5000);
            }
            else
            {
                Console::WriteLine("The broadcast object with index '{0}' couldn't be resumed.", index);
            }
        }
        else
        {
            Console::WriteLine("The broadcast object with index '{0}' couldn't be paused.", index);
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
Peak.Can.Basic Namespace
ResumeBroadcast
MessageBroadcasting


Worker.RemoveBroacast Method

WorkerRemoveBroacast Method

Overload List
Name | Description
RemoveBroacast(Broadcast) | Removes a periodic CAN message from the list of registered Broadcast objects.
RemoveBroacast(Int32) | Removes a periodic CAN message from the list of registered Broadcast objects.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.RemoveBroacast(Broadcast) Method

WorkerRemoveBroacast(Broadcast) Method

Removes a periodic CAN message from the list of registered Broadcast objects.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool RemoveBroacast(
    ref Broadcast broadcast
)
Public Function RemoveBroacast (
    ByRef broadcast As Broadcast
) As Boolean
public:
bool RemoveBroacast(
    Broadcast^% broadcast
)

Parameters

broadcast Broadcast
Represents the Broadcast object to be removed.

Return Value

Boolean
true if the Broadcast object was removed; false otherwise.
Exceptions
Exception | Condition
ArgumentNullException | The broadcast parameter value is null. An object of type Broadcast is required.
Remarks

If a Broadcast object needs to be temporarily deactivated, it is not needed to delete it and create it again. Single Broadcast objects can be temporarily deactivated using the PauseBroadcast method and reactivated again using the ResumeBroadcast method. Using the property MessageBroadcasting is possible to activate/deactivate the Broadcast object processing.

Example

The following example shows how to remove a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create a Broadcast object using a CAN message and its interval
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);
Broadcast broadcast = new Broadcast(message, 100);

// Add the new broadcast using a Broadcast object
//
if (!myWorker.AddBroadcast(ref broadcast))
{
    Console.WriteLine("The broadcast couldn't be configured");
}
else
{
    Console.WriteLine($"The broadcast object with index '{broadcast.Index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();
        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Remove the broadcast using an object
        //
        if (myWorker.RemoveBroacast(ref broadcast))
        {
            Console.WriteLine("The broadcast object was successfully removed.");

            // Wait sometime to see the message is no being sent anymore
            //
            System.Threading.Thread.Sleep(3000);
        }
        else
            Console.WriteLine($"The broadcast with index {broadcast.Index} couldn't be removed.");

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create a Broadcast object using a CAN message and its interval
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)
Dim broadcast As Broadcast = New Broadcast(message, 100)

' Add the new broadcast using a Broadcast object
'
If Not myWorker.AddBroadcast(broadcast) Then
    Console.WriteLine("The broadcast couldn't be configured")
Else
    Console.WriteLine($"The broadcast object with index '{broadcast.Index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Remove the broadcast using an object
        '
        If myWorker.RemoveBroacast(broadcast) Then
            Console.WriteLine("The broadcast object was successfully removed.")

            ' Wait sometime to see the message is no being sent anymore
            '
            Threading.Thread.Sleep(3000)
        Else
            Console.WriteLine($"The broadcast with index {broadcast.Index} couldn't be removed.")
        End If

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create a Broadcast object using a CAN message and its interval
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);
Broadcast^ broadcast = gcnew Broadcast(message, 100);

// Add the new broadcast using a Broadcast object
//
if (!myWorker->AddBroadcast(broadcast))
{
    Console::WriteLine("The broadcast couldn't be configured");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", broadcast->Index);

    try
    {
        // Activate the worker object
        //
        myWorker->Start(false, false, false);
        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Remove the broadcast using an object
        //
        if (myWorker->RemoveBroacast(broadcast))
        {
            Console::WriteLine("The broadcast object was successfully removed.");

            // Wait sometime to see the message is no being sent anymore
            //
            System::Threading::Thread::Sleep(3000);
        }
        else
            Console::WriteLine("The broadcast with index {0} couldn't be removed.", broadcast->Index);

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
RemoveBroacast Overload
Peak.Can.Basic Namespace
AddBroadcast
ClearBroadcasts
MessageBroadcasting


Worker.RemoveBroacast(Int32) Method

WorkerRemoveBroacast(Int32) Method

Removes a periodic CAN message from the list of registered Broadcast objects.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool RemoveBroacast(
    int index
)
Public Function RemoveBroacast (
    index As Integer
) As Boolean
public:
bool RemoveBroacast(
    int index
)

Parameters

index Int32
Represents the zero-based index associated to a Broadcast object.

Return Value

Boolean
true if the Broadcast object was removed; false otherwise.
Exceptions
Exception | Condition
IndexOutOfRangeException | The index parameter value is out of range. This must be in the range [0...MaximumBroadcastCount-1].
Remarks

If a Broadcast object needs to be temporarily deactivated, it is not needed to delete it and create it again. Single Broadcast objects can be temporarily deactivated using the PauseBroadcast method and reactivated again using the ResumeBroadcast method. Using the property MessageBroadcasting is possible to activate/deactivate the Broadcast object processing.

Example

The following example shows how to remove a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create the CAN message to broadcast
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker.AddBroadcast(message, 100);
if (index < 0)
{
    Console.WriteLine("The broadcast couldn't be configured");
}
else
{
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();
        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Remove the broadcast using an index
        //
        if(myWorker.RemoveBroacast(index))
        {
            Console.WriteLine($"The broadcast object with index '{index}' was successfully removed.");

            // Wait sometime to see the message is no being sent anymore
            //
            System.Threading.Thread.Sleep(3000);
        }
        else
            Console.WriteLine($"The broadcast with index {index} couldn't be removed.");

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create the CAN message to broadcast
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

' Add the new broadcast using a CAN message and its interval
'
Dim index As Integer = myWorker.AddBroadcast(message, 100)

If index < 0 Then
    Console.WriteLine("The broadcast couldn't be configured")
Else
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Remove the broadcast using an index
        '
        If myWorker.RemoveBroacast(index) Then
            Console.WriteLine($"The broadcast object with index '{index}' was successfully removed.")

            ' Wait sometime to see the message is no being sent anymore
            '
            Threading.Thread.Sleep(3000)
        Else
            Console.WriteLine($"The broadcast with index {index} couldn't be removed.")
        End If

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create the CAN message to broadcast
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker->AddBroadcast(message, 100);
if (index < 0)
{
    Console::WriteLine("The broadcast couldn't be configured");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", index);

    try
    {
        // Activate the worker object
        //
        PcanBasicException^ error;
        myWorker->Start(false, false, false);
        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Remove the broadcast using an index
        //
        if (myWorker->RemoveBroacast(index))
        {
            Console::WriteLine("The broadcast object with index '{0}' was successfully removed.", index);

            // Wait sometime to see the message is no being sent anymore
            //
            System::Threading::Thread::Sleep(3000);
        }
        else
            Console::WriteLine("The broadcast with index {0} couldn't be removed.", index);

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
RemoveBroacast Overload
Peak.Can.Basic Namespace
AddBroadcast
ClearBroadcasts
MessageBroadcasting


Worker.RemoveFilter Method

WorkerRemoveFilter Method

Overload List
Name | Description
RemoveFilter(FilteringCriterion) | Removes a filtering criterion from the message filter of the default receive queue (index 0).
RemoveFilter(Int32, FilteringCriterion) | Removes a filtering criterion from the message filter of the specified receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.RemoveFilter(FilteringCriterion) Method

WorkerRemoveFilter(FilteringCriterion) Method

Removes a filtering criterion from the message filter of the default receive queue (index 0).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool RemoveFilter(
    FilteringCriterion filter
)
Public Function RemoveFilter (
    filter As FilteringCriterion
) As Boolean
public:
bool RemoveFilter(
    FilteringCriterion filter
)

Parameters

filter FilteringCriterion
The filtering criterion to be removed.

Return Value

Boolean
true if the criterion is successfully removed; otherwise, false.
Example

The following example shows how to configure the message filter of the default receive queue (index 0) to receive only echo messages with extended ID 0x15. After this, the filtering criteria for the CAN identifier is removed, so that any echo message can be received.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the default receive queue (index 0) to receive only echo messages with ID 0x15
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include);
if (myWorker.AddFilter(criterion))
{
    criterion.SetSingleId(0x15, FilterMode.Extended);
    if (myWorker.AddFilter(criterion))
    {
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
        // Remove the filter for ID 0x15, to receive echo messages with any ID
        //
        if(myWorker.RemoveFilter(criterion))
            Console.WriteLine("Receiving now any Echo message...");
        else
            Console.WriteLine("The specified criterion could not be found.");
    }
    else
        Console.WriteLine("The given filter is already registered.");
}
else
    Console.WriteLine("The given filter is already registered.");
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the default receive queue (index 0) to receive only echo messages with ID 0x15
'
Dim criterion As FilteringCriterion = New FilteringCriterion()
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include)
If myWorker.AddFilter(criterion) Then
    criterion.SetSingleId(&H15, FilterMode.Extended)
    If myWorker.AddFilter(criterion) Then
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...")
        ' Remove the filter for ID 0x15, to receive echo messages with any ID
        '
        If myWorker.RemoveFilter(criterion) Then
            Console.WriteLine("Receiving now any Echo message...")
        Else
            Console.WriteLine("The specified criterion could not be found.")
        End If
    Else
        Console.WriteLine("The given filter is already registered.")
    End If
Else
    Console.WriteLine("The given filter is already registered.")
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the default receive queue (index 0) to receive only echo messages with ID 0x15
//
FilteringCriterion criterion;
criterion.SetMessageType(MessageType::Echo, FilterBehavior::Include);
if (myWorker->AddFilter(criterion))
{
    criterion.SetSingleId(0x15, FilterMode::Extended, FilterBehavior::Include);
    if (myWorker->AddFilter(criterion))
    {
        Console::WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
        // Remove the filter for ID 0x15, to receive echo messages with any ID
        //
        if (myWorker->RemoveFilter(criterion))
            Console::WriteLine("Receiving now any Echo message...");
        else
            Console::WriteLine("The specified criterion could not be found.");
    }
    else
        Console::WriteLine("The given filter is already registered.");
}
else
    Console::WriteLine("The given filter is already registered.");
See Also

Reference

Worker Class
RemoveFilter Overload
Peak.Can.Basic Namespace
SetFilteringState
AddFilter
GetFilters


Worker.RemoveFilter(Int32, FilteringCriterion) Method

WorkerRemoveFilter(Int32, FilteringCriterion) Method

Removes a filtering criterion from the message filter of the specified receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool RemoveFilter(
    int queueIndex,
    FilteringCriterion filter
)
Public Function RemoveFilter (
    queueIndex As Integer,
    filter As FilteringCriterion
) As Boolean
public:
bool RemoveFilter(
    int queueIndex,
    FilteringCriterion filter
)

Parameters

queueIndex Int32
Zero-based index that identifies the receive queue whose filter criterion is to be removed.
filter FilteringCriterion
The filtering criterion to be removed.

Return Value

Boolean
true if the filter is successfully removed; otherwise, false.
Exceptions
Exception | Condition
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1].
Example

The following example shows how to configure the message filter of a specific receive queue to receive only echo messages with extended ID 0x15. After this, the filtering criteria for the CAN identifier is removed, so that any echo message can be received.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the second receive queue (index 1) to receive only echo messages with ID 0x15
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include);
if (myWorker.AddFilter(1, criterion))
{
    criterion.SetSingleId(0x15, FilterMode.Extended);
    if (myWorker.AddFilter(1, criterion))
    {
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
        // Remove the filter for ID 0x15, to receive echo messages with any ID
        //
        if (myWorker.RemoveFilter(1, criterion))
            Console.WriteLine("Receiving now any Echo message...");
        else
            Console.WriteLine("The specified criterion could not be found.");
    }
    else
        Console.WriteLine("The given filter is already registered.");
}
else
    Console.WriteLine("The given filter is already registered.");
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the second receive queue (index 1) to receive only echo messages with ID 0x15
'
Dim criterion As FilteringCriterion = New FilteringCriterion()
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include)
If myWorker.AddFilter(1, criterion) Then
    criterion.SetSingleId(&H15, FilterMode.Extended)
    If myWorker.AddFilter(1, criterion) Then
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...")
        ' Remove the filter for ID 0x15, to receive echo messages with any ID
        '
        If myWorker.RemoveFilter(1, criterion) Then
            Console.WriteLine("Receiving now any Echo message...")
        Else
            Console.WriteLine("The specified criterion could not be found.")
        End If
    Else
        Console.WriteLine("The given filter is already registered.")
    End If
Else
    Console.WriteLine("The given filter is already registered.")
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the second receive queue (index 1) to receive only echo messages
//
FilteringCriterion criterion;
criterion.SetMessageType(MessageType::Echo, FilterBehavior::Include);
if (myWorker->AddFilter(1, criterion))
{
    criterion.SetSingleId(0x15, FilterMode::Extended, FilterBehavior::Include);
    if (myWorker->AddFilter(1, criterion))
    {
        Console::WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
        if (myWorker->RemoveFilter(1, criterion))
            Console::WriteLine("Receiving now any Echo message...");
        else
            Console::WriteLine("The specified criterion could not be found.");
    }
    else
        Console::WriteLine("The given filter is already registered.");
}
else
    Console::WriteLine("The given filter is already registered.");
See Also

Reference

Worker Class
RemoveFilter Overload
Peak.Can.Basic Namespace
SetFilteringState
AddFilter
GetFilters


Worker.ResetHardware Method

WorkerResetHardware Method

Overload List
Name | Description
ResetHardware | Performs a reset of the CAN controller on the hardware connected by the Worker object.
ResetHardware(PcanStatus) | Performs a reset of the CAN controller on the hardware connected by the Worker object.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.ResetHardware Method

WorkerResetHardware Method

Performs a reset of the CAN controller on the hardware connected by the Worker object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool ResetHardware()
Public Function ResetHardware As Boolean
public:
bool ResetHardware()

Return Value

Boolean
true if the Worker object could perform a hardware reset; false otherwise.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Performing a hardware reset will cause the CAN controller to go bus off for a while. This can momentarily disrupt CAN communication and affect other clients connected to the same hardware, generating error frames from other nodes and preventing messages from being sent/received.

Resetting the hardware does not discard messages that have already been read by the Worker object. If it is desired to discard the received messages, the ClearAllReceiveQueues method should also be called.

Example

The following example shows how to perform a hardware reset on a PCAN channel connected by a Worker object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Call the reset method
    //
    if (myWorker.ResetHardware(out var error))
        Console.WriteLine("The underlying device was successfully reset.");
    else
        Console.WriteLine($"The device couldn't be reset: {error}.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch (Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Call the reset method
    '
    Dim [error] = Nothing
    If myWorker.ResetHardware([error]) Then
        Console.WriteLine("The underlying device was successfully reset.")
    Else
        Console.WriteLine($"The device couldn't be reset: {[error]}.")
    End If

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Activate the worker object
//
try
{
    myWorker->Start(false, false, false);

    Console::WriteLine("The Worker object was activated successfully.");

    // Create a CAN message and send it
    //
    PcanStatus error;
    if (myWorker->ResetHardware(error))
        Console::WriteLine("The underlying device was successfully reset.");
    else
        Console::WriteLine("The device couldn't be reset: {0}.", error);

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
ResetHardware Overload
Peak.Can.Basic Namespace
Start
Stop


Worker.ResetHardware(PcanStatus) Method

WorkerResetHardware(PcanStatus) Method

Performs a reset of the CAN controller on the hardware connected by the Worker object.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool ResetHardware(
    out PcanStatus error
)
Public Function ResetHardware (
    <OutAttribute> ByRef error As PcanStatus
) As Boolean
public:
bool ResetHardware(
    [OutAttribute] PcanStatus% error
)

Parameters

error PcanStatus
In case of failure, the PcanStatus error code resulting when trying to reset the hardware.

Return Value

Boolean
true if the Worker object could perform a hardware reset; false otherwise.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

Performing a hardware reset will cause the CAN controller to go bus off for a while. This can momentarily disrupt CAN communication and affect other clients connected to the same hardware, generating error frames from other nodes and preventing messages from being sent/received.

Resetting the hardware does not discard messages that have already been read by the Worker object. If it is desired to discard the received messages, the ClearAllReceiveQueues method should also be called.

Example

The following example shows how to perform a hardware reset on a PCAN channel connected by a Worker object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Call the reset method
    //
    if (myWorker.ResetHardware(out var error))
        Console.WriteLine("The underlying device was successfully reset.");
    else
        Console.WriteLine($"The device couldn't be reset: {error}.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch (Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Call the reset method
    '
    Dim [error] = Nothing
    If myWorker.ResetHardware([error]) Then
        Console.WriteLine("The underlying device was successfully reset.")
    Else
        Console.WriteLine($"The device couldn't be reset: {[error]}.")
    End If

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Activate the worker object
//
try
{
    myWorker->Start(false, false, false);

    Console::WriteLine("The Worker object was activated successfully.");

    // Create a CAN message and send it
    //
    PcanStatus error;
    if (myWorker->ResetHardware(error))
        Console::WriteLine("The underlying device was successfully reset.");
    else
        Console::WriteLine("The device couldn't be reset: {0}.", error);

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
ResetHardware Overload
Peak.Can.Basic Namespace
Start
Stop


Worker.ResumeBroadcast Method

WorkerResumeBroadcast Method

Resumes the sending of a paused periodic CAN message.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool ResumeBroadcast(
    int index
)
Public Function ResumeBroadcast (
    index As Integer
) As Boolean
public:
bool ResumeBroadcast(
    int index
)

Parameters

index Int32
Represents the zero-based index of the periodic CAN message to be resumed.

Return Value

Boolean
true if the Broadcast object was resumed; false otherwise.
Exceptions
Exception | Condition
IndexOutOfRangeException | The index parameter value is out of range. This must be in the range [0...MaximumBroadcastCount-1].
Remarks
This method allows resuming a single broadcast. The property MessageBroadcasting activates/deactivates the broadcasting feature in general.
Example

The following example shows how to reactivate/resume a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create the CAN message to broadcast
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker.AddBroadcast(message, 100);
if (index < 0)
{
    Console.WriteLine("The broadcast couldn't be configured.");
}
else
{
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();

        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Stop sending the CAN message
        //
        if (myWorker.PauseBroadcast(index))
        {
            Console.WriteLine($"The broadcast object with index '{index}' was successfully paused.");

            // Wait sometime to validate that the message is not sent anymore
            //
            System.Threading.Thread.Sleep(3000);

            // Resume sending the CAN message
            //
            if (myWorker.ResumeBroadcast(index))
            {
                // Wait sometime for the message to be sent several times
                //
                Console.WriteLine($"The broadcast object with index '{index}' was successfully resumed.");
                System.Threading.Thread.Sleep(5000);
            }
            else
            {
                Console.WriteLine($"The broadcast object with index '{index}' couldn't be resumed.");
            }
        }
        else
        {
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be paused.");
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create the CAN message to broadcast
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

' Add the new broadcast using a CAN message and its interval
'
Dim index As Integer = myWorker.AddBroadcast(message, 100)

If index < 0 Then
    Console.WriteLine("The broadcast couldn't be configured.")
Else
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Stop sending the CAN message
        '
        If myWorker.PauseBroadcast(index) Then
            Console.WriteLine($"The broadcast object with index '{index}' was successfully paused.")

            ' Wait sometime to validate that the message is not sent anymore
            '
            Threading.Thread.Sleep(3000)

            ' Resume sending the CAN message
            '
            If myWorker.ResumeBroadcast(index) Then
                ' Wait sometime for the message to be sent several times
                '
                Console.WriteLine($"The broadcast object with index '{index}' was successfully resumed.")
                Threading.Thread.Sleep(5000)
            Else
                Console.WriteLine($"The broadcast object with index '{index}' couldn't be resumed.")
            End If
        Else
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be paused.")
        End If

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create the CAN message to broadcast
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker->AddBroadcast(message, 100);
if (index < 0)
{
    Console::WriteLine("The broadcast couldn't be configured.");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", index);

    try
    {

        // Activate the worker object
        //
        myWorker->Start(false, false, false);

        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Stop sending the CAN message
        //
        if (myWorker->PauseBroadcast(index))
        {
            Console::WriteLine("The broadcast object with index '{0}' was successfully paused.", index);

            // Wait sometime to validate that the message is not sent anymore
            //
            System::Threading::Thread::Sleep(3000);

            // Resume sending the CAN message
            //
            if (myWorker->ResumeBroadcast(index))
            {
                // Wait sometime for the message to be sent several times
                //
                Console::WriteLine("The broadcast object with index '{0}' was successfully resumed.", index);
                System::Threading::Thread::Sleep(5000);
            }
            else
            {
                Console::WriteLine("The broadcast object with index '{0}' couldn't be resumed.", index);
            }
        }
        else
        {
            Console::WriteLine("The broadcast object with index '{0}' couldn't be paused.", index);
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
Peak.Can.Basic Namespace
PauseBroadcast
MessageBroadcasting


Worker.SetFilteringState Method

WorkerSetFilteringState Method

Overload List
Name | Description
SetFilteringState(FilteringState, Boolean) | Configures the behavior of the message filter for the default receive queue (index 0).
SetFilteringState(Int32, FilteringState, Boolean) | Configures the behavior of the message filter for a specific receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.SetFilteringState(FilteringState, Boolean) Method

WorkerSetFilteringState(FilteringState, Boolean) Method

Configures the behavior of the message filter for the default receive queue (index 0).

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void SetFilteringState(
    FilteringState state,
    bool discardCurrentMessages = false
)
Public Sub SetFilteringState (
    state As FilteringState,
    Optional discardCurrentMessages As Boolean = false
)
public:
void SetFilteringState(
    FilteringState state,
    bool discardCurrentMessages = false
)

Parameters

state FilteringState
Indicates the desired filtering behavior for the default receive queue (index 0).
discardCurrentMessages Boolean (Optional)
Indicates if messages currently contained by the default receive queue (index 0) are to be discarded on status change.
Remarks
The Worker registers 'ReceiveQueuesCount' receive queues. These are zero-based indexed. The first queue (index 0) is open by default when the object is created, meaning, its message filter is set to PassForAll. All other queues remain closed, that is, their filters are configured as BlockForAll. The methods associated with a receive queue are overloaded, allowing either the direct use of the default queue (index 0) without specifying an index, or the use of a specific queue by passing an index.
Example

The following example shows how to deactivate the default receive queue, after creating a Worker object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the default receive queue to discard all messages
//
myWorker.SetFilteringState(FilteringState.BlockForAll);

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully - Messages are being discarded.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the default receive queue to discard all messages
'
myWorker.SetFilteringState(FilteringState.BlockForAll)

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully - Messages are being discarded.")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.Stop()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the default receive queue to discard all messages
//
myWorker->SetFilteringState(FilteringState::BlockForAll, false);

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully - Messages are being discarded.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
SetFilteringState Overload
Peak.Can.Basic Namespace
AddFilter
Dequeue


Worker.SetFilteringState(Int32, FilteringState, Boolean) Method

WorkerSetFilteringState(Int32, FilteringState, Boolean) Method

Configures the behavior of the message filter for a specific receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void SetFilteringState(
    int queueIndex,
    FilteringState state,
    bool discardCurrentMessages = false
)
Public Sub SetFilteringState (
    queueIndex As Integer,
    state As FilteringState,
    Optional discardCurrentMessages As Boolean = false
)
public:
void SetFilteringState(
    int queueIndex,
    FilteringState state,
    bool discardCurrentMessages = false
)

Parameters

queueIndex Int32
Zero-based index that identifies the receive queue to be configured.
state FilteringState
Indicates the desired filtering behavior for a receive queue.
discardCurrentMessages Boolean (Optional)
Indicates if messages currently contained by the receive queue are to be discarded on status change.
Exceptions
Exception | Condition
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1].
Remarks
The Worker registers 'ReceiveQueuesCount' receive queues. These are 0-indexed. The first queue (index 0) is open by default when the object is created, meaning, its message filter is set to PassForAll. All other queues remain closed, that is, their filters are configured as BlockForAll. The methods associated with a receive queue are overloaded, allowing either the direct use of the default queue (index 0) without specifying an index, or the use of a specific queue by passing an index.
Example

The following example shows how to activate a second queue, after creating a Worker object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the default receive queue to discard all messages
//
myWorker.SetFilteringState(FilteringState.BlockForAll);

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully - Messages are being discarded.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Set the filter of the default receive queue to discard all messages
'
myWorker.SetFilteringState(FilteringState.BlockForAll)

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully - Messages are being discarded.")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.Stop()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Set the filter of the default receive queue to discard all messages
//
myWorker->SetFilteringState(FilteringState::BlockForAll, false);

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully - Messages are being discarded.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
SetFilteringState Overload
Peak.Can.Basic Namespace
AddFilter
Dequeue


Worker.Start Method

WorkerStart Method

Establishes a connection to a PCAN Channel, configures it for data transmission and starts the read/write processes.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void Start(
    bool ignoreBitrateCheck = false,
    bool deactivateReading = false,
    bool deactivateBroadcasting = false
)
Public Sub Start (
    Optional ignoreBitrateCheck As Boolean = false,
    Optional deactivateReading As Boolean = false,
    Optional deactivateBroadcasting As Boolean = false
)
public:
void Start(
    bool ignoreBitrateCheck = false,
    bool deactivateReading = false,
    bool deactivateBroadcasting = false
)

Parameters

ignoreBitrateCheck Boolean (Optional)
If the connection should still occur, even if the PCAN channel is already initialized with a different bit rate (FD) as the specified.
deactivateReading Boolean (Optional)
If message fetching should be deactivated on connection. After connection, the status of message fetching can be controlled by using the property MessageFetching.
deactivateBroadcasting Boolean (Optional)
If message broadcasting should be deactivated on connection. After connection, the status of message broadcasting can be controlled by using the property MessageBroadcasting.
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related operation ended with an unexpected result.
Remarks

About reading:

A Worker object can handle multiple receive queues. Only one receive queue is active by default when the object is created, and its filter is configured to receive any message.

The reading process is executed in an additional thread, making use of the event notification mechanism to fetch CAN messages. Fetched messages can be dequeued for their further processing using the Dequeue method. If needed, messages stored in one or all receive queues may be discarded using the methods ClearReceiveQueue and ClearAllReceiveQueues respectively.

Each receive queue has its own message filter. This message filter can be configured using several filtering criteria, in form of FilteringCriterion data, by using the AddFilter method. The message filtering in a receive queue can also be temporarily disabled/enabled at any time by using the SetFilteringState method. A specific filtering criterion, or all of them, can be removed using the methods RemoveFilter and ClearFilters respectively.

About writing:

There are two approaches for sending messages to the connected CAN network:

  1. Using the Transmit method, which places a CAN message in the connected Channel's transmit queue for immediate sending.

  2. Using a Broadcast message, which periodically places a configured CAN message in the connected Channel's transmit queue for immediate sending.

New Broadcast items can be configured using the AddBroadcast method. The processing of current registered Broadcast items can be stopped and resumed again using the methods PauseBroadcast and ResumeBroadcast respectively. A specific Broadcast item, or all of them, can be removed using the methods RemoveBroacast and ClearBroadcasts respectively.

Example

The following example shows the activation and deactivation of a Worker object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.Stop()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch(Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
Peak.Can.Basic Namespace
Transmit
Dequeue
Stop


Worker.Stop Method

WorkerStop Method

Disconnects the used PCAN Channel and stops reading and writing data.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public void Stop(
    bool clearQueues = false,
    bool clearBroatcasts = false,
    bool resetQueueFilters = false
)
Public Sub Stop (
    Optional clearQueues As Boolean = false,
    Optional clearBroatcasts As Boolean = false,
    Optional resetQueueFilters As Boolean = false
)
public:
void Stop(
    bool clearQueues = false,
    bool clearBroatcasts = false,
    bool resetQueueFilters = false
)

Parameters

clearQueues Boolean (Optional)
Indicates if any remaining message within any receive queue should be discarded.
clearBroatcasts Boolean (Optional)
Indicates if defined Broadcast objects should be removed.
resetQueueFilters Boolean (Optional)
Indicates if defined filtering criteria within the message filter of any receive queue should be removed.
Example

The following example shows the activation and deactivation of a Worker object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.Stop()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

try
{
    // Activate the worker object
    //
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch(Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
Peak.Can.Basic Namespace
Start


Worker.Transmit Method

WorkerTransmit Method

Overload List
Name | Description
Transmit(PcanMessage) | Places a CAN message into the transmit queue of the device driver to be written as soon as possible.
Transmit(PcanMessage, PcanStatus) | Places a CAN message into the transmit queue of the device driver to be written as soon as possible.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.Transmit(PcanMessage) Method

WorkerTransmit(PcanMessage) Method

Places a CAN message into the transmit queue of the device driver to be written as soon as possible.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool Transmit(
    PcanMessage message
)
Public Function Transmit (
    message As PcanMessage
) As Boolean
public:
bool Transmit(
    PcanMessage^ message
)

Parameters

message PcanMessage
The CAN message to be written.

Return Value

Boolean
A PcanStatus value as result of the write operation
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

The driver's transmit queue is 1 MB in size, which is enough to allocate up to 32.768 classic CAN messages or 13.000 CAN FD messages. This queue is constantly monitored so that any new message is processed and physically sent as fast as possible.

Example

The following example shows how to send a CAN message.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Create a CAN message and send it
    //
    PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

    if(myWorker.Transmit(message))
        Console.WriteLine("The message was successfully sent.");
    else
        Console.WriteLine("The message couldn't be sent.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Create a CAN message and send it
    '
    Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

    If myWorker.Transmit(message) Then
        Console.WriteLine("The message was successfully sent.")
    Else
        Console.WriteLine("The message couldn't be sent.")
    End If

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Activate the worker object
//
try
{
    myWorker->Start(false, false, false);
    Console::WriteLine("The Worker object was activated successfully.");

    // Create a CAN message and send it
    //
    PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

    if (myWorker->Transmit(message))
        Console::WriteLine("The message was successfully sent.");
    else
        Console::WriteLine("The message couldn't be sent.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
Transmit Overload
Peak.Can.Basic Namespace
AddBroadcast


Worker.Transmit(PcanMessage, PcanStatus) Method

WorkerTransmit(PcanMessage, PcanStatus) Method

Places a CAN message into the transmit queue of the device driver to be written as soon as possible.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool Transmit(
    PcanMessage message,
    out PcanStatus error
)
Public Function Transmit (
    message As PcanMessage,
    <OutAttribute> ByRef error As PcanStatus
) As Boolean
public:
bool Transmit(
    PcanMessage^ message,
    [OutAttribute] PcanStatus% error
)

Parameters

message PcanMessage
The CAN message to be written.
error PcanStatus
In case of failure, the PcanStatus error code resulting when trying to send the message.

Return Value

Boolean
A PcanStatus value as result of the write operation
Exceptions
Exception | Condition
DllNotFoundException | The underlying PCANBasic.dll library could not be found.
PcanBasicException | The execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.
Remarks

The driver's transmit queue is 1 MB in size, which is enough to allocate up to 32.768 classic CAN messages or 13.000 CAN FD messages. This queue is constantly monitored so that any new message is processed and physically sent as fast as possible.

Example

The following example shows how to send a CAN message.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

try
{
    // Activate the worker object
    //
    myWorker.Start();
    Console.WriteLine("The Worker object was activated successfully.");

    // Create a CAN message and send it
    //
    PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);
    if (myWorker.Transmit(message, out var error))
        Console.WriteLine("The message was successfully sent.");
    else
        Console.WriteLine($"The message couldn't be sent: {error}.");

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker.Stop();
    Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

Try
    ' Activate the worker object
    '
    myWorker.Start()
    Console.WriteLine("The Worker object was activated successfully.")

    ' Create a CAN message and send it
    '
    Dim [error] = Nothing
    Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)
    If myWorker.Transmit(message, [error]) Then
        Console.WriteLine("The message was successfully sent.")
    Else
        Console.WriteLine($"The message couldn't be sent: {[error]}.")
    End If

    ' Deactivate the worker object, when it is no longer needed
    '
    myWorker.[Stop]()
    Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
    Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Activate the worker object
//
try
{
    myWorker->Start(false, false, false);

    Console::WriteLine("The Worker object was activated successfully.");

    // Create a CAN message and send it
    //
    PcanStatus error;
    PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);
    if (myWorker->Transmit(message, error))
        Console::WriteLine("The message was successfully sent.");
    else
        Console::WriteLine("The message couldn't be sent: {0}.", error);

    // Deactivate the worker object, when it is no longer needed
    //
    myWorker->Stop(false, false, false);
    Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
    Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}
See Also

Reference

Worker Class
Transmit Overload
Peak.Can.Basic Namespace
AddBroadcast


Worker.UpdateBroadcast Method

WorkerUpdateBroadcast Method

Overload List
Name | Description
UpdateBroadcast(Int32, PcanMessage) | Adjusts the content of a periodic CAN message from the list of registered Broadcast objects.
UpdateBroadcast(Int32, Int32) | Adjusts the sending interval of a periodic CAN message from the list of registered Broadcast objects.
UpdateBroadcast(Int32, Int32, PcanMessage) | Adjusts the configuration of a periodic CAN message from the list of registered Broadcast objects.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.UpdateBroadcast(Int32, PcanMessage) Method

WorkerUpdateBroadcast(Int32, PcanMessage) Method

Adjusts the content of a periodic CAN message from the list of registered Broadcast objects.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool UpdateBroadcast(
    int index,
    PcanMessage message
)
Public Function UpdateBroadcast (
    index As Integer,
    message As PcanMessage
) As Boolean
public:
bool UpdateBroadcast(
    int index,
    PcanMessage^ message
)

Parameters

index Int32
Represents the zero-based index associated to a Broadcast object.
message PcanMessage
The CAN message to be periodically written.

Return Value

Boolean
true if the Broadcast object was modified; false otherwise.
Exceptions
Exception | Condition
IndexOutOfRangeException | The index parameter value is out of range. This must be in the range [0...MaximumBroadcastCount-1].
ArgumentNullException | The message parameter value is null. An object of type PcanMessage is required.
Example

The following example shows how to update a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create the CAN message to broadcast
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker.AddBroadcast(message, 100);
if (index < 0)
{
    Console.WriteLine("The broadcast couldn't be configured");
}
else
{
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();
        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Update the CAN message being sent
        //
        message.ID = 0x200;
        message.DLC = 8;
        message.Data = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 };
        if(myWorker.UpdateBroadcast(index, message))
        {
            Console.WriteLine($"The broadcast object with index '{index}' was successfully updated.");

            // Wait sometime for the message to be sent several times
            //
            Console.WriteLine("Broadcast is working....");
            System.Threading.Thread.Sleep(5000);
        }
        else
        {
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be updated.");
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create the CAN message to broadcast
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

' Add the new broadcast using a CAN message and its interval
'
Dim index As Integer = myWorker.AddBroadcast(message, 100)

If index < 0 Then
    Console.WriteLine("The broadcast couldn't be configured")
Else
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Update the CAN message being sent
        '
        message.ID = &H200
        message.DLC = 8
        message.Data = New Byte() {8, 7, 6, 5, 4, 3, 2, 1}
        If myWorker.UpdateBroadcast(index, message) Then
            Console.WriteLine($"The broadcast object with index '{index}' was successfully updated.")

            ' Wait sometime for the message to be sent several times
            '
            Console.WriteLine("Broadcast is working....")
            Threading.Thread.Sleep(5000)
        Else
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be updated.")
        End If

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create the CAN message to broadcast
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker->AddBroadcast(message, 100);
if (index < 0)
{
    Console::WriteLine("The broadcast couldn't be configured");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", index);

    try
    {
        // Activate the worker object
        //
        myWorker->Start(false, false, false);
        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Update the CAN message being sent
        //
        message->ID = 0x200;
        message->DLC = 8;
        message->Data = gcnew array<Byte>{ 8, 7, 6, 5, 4, 3, 2, 1 };
        if (myWorker->UpdateBroadcast(index, message))
        {
            Console::WriteLine("The broadcast object with index '{0}' was successfully updated.", index);

            // Wait sometime for the message to be sent several times
            //
            Console::WriteLine("Broadcast is working....");
            System::Threading::Thread::Sleep(5000);
        }
        else
        {
            Console::WriteLine("The broadcast object with index '{0}' couldn't be updated.", index);
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
UpdateBroadcast Overload
Peak.Can.Basic Namespace
AddBroadcast
RemoveBroacast
ClearBroadcasts


Worker.UpdateBroadcast(Int32, Int32) Method

WorkerUpdateBroadcast(Int32, Int32) Method

Adjusts the sending interval of a periodic CAN message from the list of registered Broadcast objects.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool UpdateBroadcast(
    int index,
    int interval
)
Public Function UpdateBroadcast (
    index As Integer,
    interval As Integer
) As Boolean
public:
bool UpdateBroadcast(
    int index,
    int interval
)

Parameters

index Int32
Represents the zero-based index associated to a Broadcast object.
interval Int32
The desired interval at which the periodic CAN message should be written.

Return Value

Boolean
true if the Broadcast object was modified; false otherwise.
Exceptions
Exception | Condition
IndexOutOfRangeException | The index parameter value is out of range. This must be in the range [0...MaximumBroadcastCount-1].
ArgumentOutOfRangeException | The interval parameter value is out of range. This must be in the range [1...MaxValue].
Example

The following example shows how to update a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create the CAN message to broadcast
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker.AddBroadcast(message, 100);
if (index < 0)
{
    Console.WriteLine("The broadcast couldn't be configured");
}
else
{
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();
        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Update the interval at which the CAN message is being sent
        //
        if (myWorker.UpdateBroadcast(index, 1000))
        {
            Console.WriteLine($"The broadcast object with index '{index}' was successfully updated.");

            // Wait sometime for the message to be sent several times
            //
            Console.WriteLine("Broadcast is working....");
            System.Threading.Thread.Sleep(5000);
        }
        else
        {
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be updated.");
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create the CAN message to broadcast
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

' Add the new broadcast using a CAN message and its interval
'
Dim index As Integer = myWorker.AddBroadcast(message, 100)

If index < 0 Then
    Console.WriteLine("The broadcast couldn't be configured")
Else
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Update the interval at which the CAN message is being sent
        '
        If myWorker.UpdateBroadcast(index, 1000) Then
            Console.WriteLine($"The broadcast object with index '{index}' was successfully updated.")

            ' Wait sometime for the message to be sent several times
            '
            Console.WriteLine("Broadcast is working....")
            Threading.Thread.Sleep(5000)
        Else
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be updated.")
        End If

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create the CAN message to broadcast
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker->AddBroadcast(message, 100);
if (index < 0)
{
    Console::WriteLine("The broadcast couldn't be configured");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", index);

    try
    {
        // Activate the worker object
        //
        myWorker->Start(false, false, false);
        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Update the interval at which the CAN message is being sent
        //
        if (myWorker->UpdateBroadcast(index, 1000))
        {
            Console::WriteLine("The broadcast object with index '{0}' was successfully updated.", index);

            // Wait sometime for the message to be sent several times
            //
            Console::WriteLine("Broadcast is working....");
            System::Threading::Thread::Sleep(5000);
        }
        else
        {
            Console::WriteLine("The broadcast object with index '{0}' couldn't be updated.", index);
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
UpdateBroadcast Overload
Peak.Can.Basic Namespace
AddBroadcast
RemoveBroacast
ClearBroadcasts


Worker.UpdateBroadcast(Int32, Int32, PcanMessage) Method

WorkerUpdateBroadcast(Int32, Int32, PcanMessage) Method

Adjusts the configuration of a periodic CAN message from the list of registered Broadcast objects.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool UpdateBroadcast(
    int index,
    int interval,
    PcanMessage message
)
Public Function UpdateBroadcast (
    index As Integer,
    interval As Integer,
    message As PcanMessage
) As Boolean
public:
bool UpdateBroadcast(
    int index,
    int interval,
    PcanMessage^ message
)

Parameters

index Int32
Represents the zero-based index associated to a Broadcast object.
interval Int32
The desired interval at which the periodic CAN message should be written.
message PcanMessage
The CAN message to be periodically written.

Return Value

Boolean
true if the Broadcast object was modified; false otherwise.
Exceptions
Exception | Condition
IndexOutOfRangeException | The index parameter value is out of range. This must be in the range [0...MaximumBroadcastCount-1].
ArgumentOutOfRangeException | The interval parameter value is out of range. This must be in the range [1...MaxValue].
Example

The following example shows how to update a Broadcast object.

In case of failure, an error messages is written to the console output using English as output language.

C#
VB
C++
Copy
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Create the CAN message to broadcast
//
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker.AddBroadcast(message, 100);
if (index < 0)
{
    Console.WriteLine("The broadcast couldn't be configured.");
}
else
{
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.");

    try
    {
        // Activate the worker object
        //
        myWorker.Start();
        Console.WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console.WriteLine("Broadcast is working....");
        System.Threading.Thread.Sleep(5000);

        // Update the CAN message being sent and its interval
        //
        message.ID = 0x200;
        message.DLC = 8;
        message.Data = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 };
        if (myWorker.UpdateBroadcast(index, 1000, message))
        {
            Console.WriteLine($"The broadcast object with index '{index}' was successfully updated.");

            // Wait sometime for the message to be sent several times
            //
            Console.WriteLine("Broadcast is working....");
            System.Threading.Thread.Sleep(5000);
        }
        else
        {
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be updated.");
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker.Stop();
        Console.WriteLine("The Worker object was deactivated.");
    }
    catch(Exception ex)
    {
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
    }
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()

' Create the CAN message to broadcast
'
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)

' Add the new broadcast using a CAN message and its interval
'
Dim index As Integer = myWorker.AddBroadcast(message, 100)

If index < 0 Then
    Console.WriteLine("The broadcast couldn't be configured.")
Else
    Console.WriteLine($"The broadcast object with index '{index}' was configured successfully.")

    Try
        ' Activate the worker object
        '
        myWorker.Start()
        Console.WriteLine("The Worker object was activated successfully.")

        ' Wait sometime for the message to be sent several times
        '
        Console.WriteLine("Broadcast is working....")
        Threading.Thread.Sleep(5000)

        ' Update the CAN message being sent and its interval
        '
        message.ID = &H200
        message.DLC = 8
        message.Data = New Byte() {8, 7, 6, 5, 4, 3, 2, 1}
        If myWorker.UpdateBroadcast(index, 1000, message) Then
            Console.WriteLine($"The broadcast object with index '{index}' was successfully updated.")

            ' Wait sometime for the message to be sent several times
            '
            Console.WriteLine("Broadcast is working....")
            Threading.Thread.Sleep(5000)
        Else
            Console.WriteLine($"The broadcast object with index '{index}' couldn't be updated.")
        End If

        ' Deactivate the worker object, when it is no longer needed
        '
        myWorker.[Stop]()
        Console.WriteLine("The Worker object was deactivated.")
    Catch ex As Exception
        Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
    End Try
End If
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();

// Create the CAN message to broadcast
//
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte>{ 1, 2, 3 }, false);

// Add the new broadcast using a CAN message and its interval
//
int index = myWorker->AddBroadcast(message, 100);
if (index < 0)
{
    Console::WriteLine("The broadcast couldn't be configured.");
}
else
{
    Console::WriteLine("The broadcast object with index '{0}' was configured successfully.", index);

    try
    {
        // Activate the worker object
        //
        myWorker->Start(false, false, false);
        Console::WriteLine("The Worker object was activated successfully.");

        // Wait sometime for the message to be sent several times
        //
        Console::WriteLine("Broadcast is working....");
        System::Threading::Thread::Sleep(5000);

        // Update the CAN message being sent and its interval
        //
        message->ID = 0x200;
        message->DLC = 8;
        message->Data = gcnew array<Byte>{ 8, 7, 6, 5, 4, 3, 2, 1 };
        if (myWorker->UpdateBroadcast(index, 1000, message))
        {
            Console::WriteLine("The broadcast object with index '{0}' was successfully updated.", index);

            // Wait sometime for the message to be sent several times
            //
            Console::WriteLine("Broadcast is working....");
            System::Threading::Thread::Sleep(5000);
        }
        else
        {
            Console::WriteLine("The broadcast object with index '{0}' couldn't be updated.", index);
        }

        // Deactivate the worker object, when it is no longer needed
        //
        myWorker->Stop(false, false, false);
        Console::WriteLine("The Worker object was deactivated.");
    }
    catch (Exception^ ex)
    {
        Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
    }
}
See Also

Reference

Worker Class
UpdateBroadcast Overload
Peak.Can.Basic Namespace
AddBroadcast
RemoveBroacast
ClearBroadcasts


Worker Events

The Worker type exposes the following members.

Events
 | Name | Description
Public event | MessageAvailable | Occurs when a message is received, validated and placed in a receive queue.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.MessageAvailable Event

WorkerMessageAvailable Event

Occurs when a message is received, validated and placed in a receive queue.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public event EventHandler<MessageAvailableEventArgs> MessageAvailable
Public Event MessageAvailable As EventHandler(Of MessageAvailableEventArgs)
public:
 event EventHandler<MessageAvailableEventArgs^>^ MessageAvailable {
    void add (EventHandler<MessageAvailableEventArgs^>^ value);
    void remove (EventHandler<MessageAvailableEventArgs^>^ value);
}

Value

EventHandler MessageAvailableEventArgs
Remarks
Important note Important
This event is fired from a background thread. It may be needed to do synchronization operations with the main thread, if visual controls are involved.
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker Fields

The Worker type exposes the following members.

Fields
Name | Description
MaximumBroadcastCount | Indicates the maximum amount of periodic messages that can be handled.
ReceiveQueuesCount | Indicates the amount of receive queues available to use.
Top
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.MaximumBroadcastCount Field

WorkerMaximumBroadcastCount Field

Indicates the maximum amount of periodic messages that can be handled.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MaximumBroadcastCount = 100
Public Const MaximumBroadcastCount As Integer = 100
public:
literal int MaximumBroadcastCount = 100

Field Value

Int32
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Worker.ReceiveQueuesCount Field

WorkerReceiveQueuesCount Field

Indicates the amount of receive queues available to use.

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int ReceiveQueuesCount = 3
Public Const ReceiveQueuesCount As Integer = 3
public:
literal int ReceiveQueuesCount = 3

Field Value

Int32
See Also

Reference

Worker Class
Peak.Can.Basic Namespace


Peak.Can.Basic.BackwardCompatibility Namespace

The namespace Peak.Can.Basic.BackwardCompatibility grants access to the PCAN-Basic library over an interface as defined within the header files PCANBasic.cs / PCANBasic.vb / PCANBasicCLR.h (C++ / CLI).

This namespace is intended to be used only with already existing projects, that have been written using those header files, as a way to keep old code working without the need of rewriting it. For new development projects the namespace Peak.Can.Basic should be used instead.

Classes
 | Class | Description
Public class | PCANBasic | PCAN-Basic API class implementation
Structures
 | Structure | Description
Public structure | TPCANChannelInformation | Describes an existing PCAN Channel.
Public structure | TPCANMsg | Represents a PCAN message.
Public structure | TPCANMsgFD | Defines a CAN message with flexible data rate.
Public structure | TPCANTimestamp | Defines a time-stamp of a CAN message. The time-stamp contains the number of microseconds since the start of Windows.
Enumerations
 | Enumeration | Description
Public enumeration | TPCANBaudrate | Represents a PCAN bit rate register value.
Public enumeration | TPCANDevice | Represents the type of interface and driver a device uses.
Public enumeration | TPCANMessageType | Represents the type of a CAN message.
Public enumeration | TPCANMode | Represents a PCAN filter mode.
Public enumeration | TPCANParameter | Represents a PCAN parameter or a PCAN Value that can be read or set.
Public enumeration | TPCANStatus | Represents a PCAN status/error code.
Public enumeration | TPCANType | Represents the type of PCAN (non plug-and-play) hardware to be initialized.


PCANBasic Class

PCAN-Basic API class implementation
Inheritance Hierarchy
SystemObject
Peak.Can.Basic.BackwardCompatibilityPCANBasic

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static class PCANBasic
Public NotInheritable Class PCANBasic
public ref class PCANBasic abstract sealed

The PCANBasic type exposes the following members.

Methods
Name | Description
FilterMessages | Configures the reception filter.
GetErrorText | Returns a descriptive text for a given TPCANStatus code, in any of the supported languages.
GetStatus | Gets the current BUS status of a PCAN Channel.
GetValue(UInt16, TPCANParameter, TPCANChannelInformation) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, StringBuilder, UInt32) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, UInt32, UInt32) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, UInt64, UInt32) | Retrieves a PCAN Channel value.
Initialize(UInt16, TPCANBaudrate) | Initializes a PCAN Channel.
Initialize(UInt16, TPCANBaudrate, TPCANType, UInt32, UInt16) | Initializes a PCAN Channel.
InitializeFD | Initializes a FD capable PCAN Channel.
LookUpChannel | Finds the handle of a PCAN Channel that matches the given parameters.
Read(UInt16, TPCANMsg) | Reads a CAN message from the receive queue of a PCAN Channel.
Read(UInt16, TPCANMsg, TPCANTimestamp) | Reads a CAN message and its time stamp from the receive queue of a PCAN Channel.
ReadFD(UInt16, TPCANMsgFD) | Reads a CAN message from the receive queue of a FD capable PCAN Channel.
ReadFD(UInt16, TPCANMsgFD, UInt64) | Reads a CAN message and its time stamp from the receive queue of a FD capable PCAN Channel.
Reset | Discards all messages contained in the receive and transmit queues of a PCAN Channel.
SetValue(UInt16, TPCANParameter, String, UInt32) | Configures a feature of a PCAN Channel.
SetValue(UInt16, TPCANParameter, UInt32, UInt32) | Configures a feature of a PCAN Channel.
SetValue(UInt16, TPCANParameter, UInt64, UInt32) | Configures a feature of a PCAN Channel.
Uninitialize | Uninitializes one or all initialized PCAN Channels.
Write | Transmits a CAN message.
WriteFD | Transmits a CAN message using a FD capable PCAN Channel.
Top
Fields
Name | Description
FEATURE_DELAY_CAPABLE | Device supports a delay between sending frames (FPGA based USB devices).
FEATURE_FD_CAPABLE | Device supports flexible data-rate (CAN-FD).
FEATURE_IO_CAPABLE | Device supports I/O functionality for electronic circuits (USB-Chip devices).
LAN_DIRECTION_READ | The PCAN Channel is limited to incoming communication only.
LAN_DIRECTION_READ_WRITE | The PCAN Channel communication is bidirectional.
LAN_DIRECTION_WRITE | The PCAN Channel is limited to outgoing communication only.
LOG_FUNCTION_ALL | Logs all possible information within the PCAN-Basic API functions.
LOG_FUNCTION_DEFAULT | Logs system exceptions / errors.
LOG_FUNCTION_ENTRY | Logs the entries to the PCAN-Basic API functions.
LOG_FUNCTION_LEAVE | Logs the exits from the PCAN-Basic API functions.
LOG_FUNCTION_PARAMETERS | Logs the parameters passed to the PCAN-Basic API functions.
LOG_FUNCTION_READ | Logs the CAN messages received within the CAN_Read function.
LOG_FUNCTION_WRITE | Logs the CAN messages passed to the CAN_Write function.
LOOKUP_CONTROLLER_NUMBER | Searches a PCAN Channel by its 0-based CAN controller index.
LOOKUP_DEVICE_ID | Searches a PCAN Channel by its device identifier.
LOOKUP_DEVICE_TYPE | Searches a PCAN Channel by its device type (see TPCANDevice).
LOOKUP_IP_ADDRESS | Searches a PCAN Channel by its IP address (PCAN_LAN Channels only. See PCAN-LAN Handles).
MAX_LENGTH_HARDWARE_NAME | Represents the maximum length that the name of a device can have (32 characters + terminator).
MAX_LENGTH_VERSION_STRING | Represents the maximum length that a version string can have (255 characters + terminator).
PCAN_BR_CLOCK | Clock frequency in hertz (80000000, 60000000, 40000000, 30000000, 24000000, 20000000)
PCAN_BR_CLOCK_MHZ | Clock frequency in megahertz (80, 60, 40, 30, 24, 20)
PCAN_BR_DATA_BRP | Clock prescaler for high-speed data time quantum
PCAN_BR_DATA_SAMPLE | Secondary sample point delay for high-speed data bit rate in cycles
PCAN_BR_DATA_SJW | Synchronization Jump Width for high-speed data bit rate in time quanta
PCAN_BR_DATA_TSEG1 | TSEG1 segment for fast data bit rate in time quanta
PCAN_BR_DATA_TSEG2 | TSEG2 segment for fast data bit rate in time quanta
PCAN_BR_NOM_BRP | Clock prescaler for nominal time quantum
PCAN_BR_NOM_SAMPLE | Sample point for nominal bit rate
PCAN_BR_NOM_SJW | Synchronization Jump Width for nominal bit rate in time quanta
PCAN_BR_NOM_TSEG1 | TSEG1 segment for nominal bit rate in time quanta
PCAN_BR_NOM_TSEG2 | TSEG2 segment for nominal bit rate in time quanta
PCAN_CHANNEL_AVAILABLE | The PCAN Channel handle is available to be connected (PnP Hardware: it means furthermore that the hardware is plugged-in).
PCAN_CHANNEL_OCCUPIED | The PCAN Channel handle is valid, and is already being used.
PCAN_CHANNEL_PCANVIEW | The PCAN Channel handle is already being used by a PCAN-View application, but is available to connect.
PCAN_CHANNEL_UNAVAILABLE | The PCAN Channel handle is illegal, or its associated hardware is not available.
PCAN_DNGBUS1 | PPCAN-Dongle/LPT interface, channel 1
PCAN_FILTER_CLOSE | The PCAN filter is closed. No messages will be received.
PCAN_FILTER_CUSTOM | The PCAN filter is custom configured. Only registered. messages will be received
PCAN_FILTER_OPEN | The PCAN filter is fully opened. All messages will be received.
PCAN_ISABUS1 | PCAN-ISA interface, channel 1
PCAN_ISABUS2 | PCAN-ISA interface, channel 2
PCAN_ISABUS3 | PCAN-ISA interface, channel 3
PCAN_ISABUS4 | PCAN-ISA interface, channel 4
PCAN_ISABUS5 | PCAN-ISA interface, channel 5
PCAN_ISABUS6 | PCAN-ISA interface, channel 6
PCAN_ISABUS7 | PCAN-ISA interface, channel 7
PCAN_ISABUS8 | PCAN-ISA interface, channel 8
PCAN_LANBUS1 | PCAN-LAN interface, channel 1
PCAN_LANBUS10 | PCAN-LAN interface, channel 10
PCAN_LANBUS11 | PCAN-LAN interface, channel 11
PCAN_LANBUS12 | PCAN-LAN interface, channel 12
PCAN_LANBUS13 | PCAN-LAN interface, channel 13
PCAN_LANBUS14 | PCAN-LAN interface, channel 14
PCAN_LANBUS15 | PCAN-LAN interface, channel 15
PCAN_LANBUS16 | PCAN-LAN interface, channel 16
PCAN_LANBUS2 | PCAN-LAN interface, channel 2
PCAN_LANBUS3 | PCAN-LAN interface, channel 3
PCAN_LANBUS4 | PCAN-LAN interface, channel 4
PCAN_LANBUS5 | PCAN-LAN interface, channel 5
PCAN_LANBUS6 | PCAN-LAN interface, channel 6
PCAN_LANBUS7 | PCAN-LAN interface, channel 7
PCAN_LANBUS8 | PCAN-LAN interface, channel 8
PCAN_LANBUS9 | PCAN-LAN interface, channel 9
PCAN_NONEBUS | Undefined/default value for a PCAN bus
PCAN_PARAMETER_OFF | The PCAN parameter is not set (inactive).
PCAN_PARAMETER_ON | The PCAN parameter is set (active).
PCAN_PCCBUS1 | PCAN-PC Card interface, channel 1
PCAN_PCCBUS2 | PCAN-PC Card interface, channel 2
PCAN_PCIBUS1 | PCAN-PCI interface, channel 1
PCAN_PCIBUS10 | PCAN-PCI interface, channel 10
PCAN_PCIBUS11 | PCAN-PCI interface, channel 11
PCAN_PCIBUS12 | PCAN-PCI interface, channel 12
PCAN_PCIBUS13 | PCAN-PCI interface, channel 13
PCAN_PCIBUS14 | PCAN-PCI interface, channel 14
PCAN_PCIBUS15 | PCAN-PCI interface, channel 15
PCAN_PCIBUS16 | PCAN-PCI interface, channel 16
PCAN_PCIBUS2 | PCAN-PCI interface, channel 2
PCAN_PCIBUS3 | PCAN-PCI interface, channel 3
PCAN_PCIBUS4 | PCAN-PCI interface, channel 4
PCAN_PCIBUS5 | PCAN-PCI interface, channel 5
PCAN_PCIBUS6 | PCAN-PCI interface, channel 6
PCAN_PCIBUS7 | PCAN-PCI interface, channel 7
PCAN_PCIBUS8 | PCAN-PCI interface, channel 8
PCAN_PCIBUS9 | PCAN-PCI interface, channel 9
PCAN_USBBUS1 | PCAN-USB interface, channel 1
PCAN_USBBUS10 | PCAN-USB interface, channel 10
PCAN_USBBUS11 | PCAN-USB interface, channel 11
PCAN_USBBUS12 | PCAN-USB interface, channel 12
PCAN_USBBUS13 | PCAN-USB interface, channel 13
PCAN_USBBUS14 | PCAN-USB interface, channel 14
PCAN_USBBUS15 | PCAN-USB interface, channel 15
PCAN_USBBUS16 | PCAN-USB interface, channel 16
PCAN_USBBUS2 | PCAN-USB interface, channel 2
PCAN_USBBUS3 | PCAN-USB interface, channel 3
PCAN_USBBUS4 | PCAN-USB interface, channel 4
PCAN_USBBUS5 | PCAN-USB interface, channel 5
PCAN_USBBUS6 | PCAN-USB interface, channel 6
PCAN_USBBUS7 | PCAN-USB interface, channel 7
PCAN_USBBUS8 | PCAN-USB interface, channel 8
PCAN_USBBUS9 | PCAN-USB interface, channel 9
SERVICE_STATUS_RUNNING | The service is running.
SERVICE_STATUS_STOPPED | The service is not running.
TRACE_FILE_DATA_LENGTH | Causes using the data length column ('l') instead of the DLC column ('L') in the trace file.
TRACE_FILE_DATE | Includes the date into the name of the trace file.
TRACE_FILE_OVERWRITE | Causes the overwriting of available traces (same name).
TRACE_FILE_SEGMENTED | Traced data is distributed in several files with size PAN_TRACE_SIZE.
TRACE_FILE_SINGLE | A single file is written until it size reaches PAN_TRACE_SIZE.
TRACE_FILE_TIME | Includes the start time into the name of the trace file.
Top
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic Methods

The PCANBasic type exposes the following members.

Methods
Name | Description
FilterMessages | Configures the reception filter.
GetErrorText | Returns a descriptive text for a given TPCANStatus code, in any of the supported languages.
GetStatus | Gets the current BUS status of a PCAN Channel.
GetValue(UInt16, TPCANParameter, TPCANChannelInformation) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, StringBuilder, UInt32) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, UInt32, UInt32) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, UInt64, UInt32) | Retrieves a PCAN Channel value.
Initialize(UInt16, TPCANBaudrate) | Initializes a PCAN Channel.
Initialize(UInt16, TPCANBaudrate, TPCANType, UInt32, UInt16) | Initializes a PCAN Channel.
InitializeFD | Initializes a FD capable PCAN Channel.
LookUpChannel | Finds the handle of a PCAN Channel that matches the given parameters.
Read(UInt16, TPCANMsg) | Reads a CAN message from the receive queue of a PCAN Channel.
Read(UInt16, TPCANMsg, TPCANTimestamp) | Reads a CAN message and its time stamp from the receive queue of a PCAN Channel.
ReadFD(UInt16, TPCANMsgFD) | Reads a CAN message from the receive queue of a FD capable PCAN Channel.
ReadFD(UInt16, TPCANMsgFD, UInt64) | Reads a CAN message and its time stamp from the receive queue of a FD capable PCAN Channel.
Reset | Discards all messages contained in the receive and transmit queues of a PCAN Channel.
SetValue(UInt16, TPCANParameter, String, UInt32) | Configures a feature of a PCAN Channel.
SetValue(UInt16, TPCANParameter, UInt32, UInt32) | Configures a feature of a PCAN Channel.
SetValue(UInt16, TPCANParameter, UInt64, UInt32) | Configures a feature of a PCAN Channel.
Uninitialize | Uninitializes one or all initialized PCAN Channels.
Write | Transmits a CAN message.
WriteFD | Transmits a CAN message using a FD capable PCAN Channel.
Top
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic.FilterMessages Method

PCANBasicFilterMessages Method

Configures the reception filter.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus FilterMessages(
    ushort Channel,
    uint FromID,
    uint ToID,
    TPCANMode Mode
)
Public Shared Function FilterMessages (
    Channel As UShort,
    FromID As UInteger,
    ToID As UInteger,
    Mode As TPCANMode
) As TPCANStatus
public:
static TPCANStatus FilterMessages(
    unsigned short Channel,
    unsigned int FromID,
    unsigned int ToID,
    TPCANMode Mode
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
FromID UInt32
The lowest CAN ID to be received.
ToID UInt32
The highest CAN ID to be received.
Mode TPCANMode
The kind of filter being set.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
Remarks
Important note Important
After a PCAN Channel is initialized, the status of its filter is fully opened.

Based on the current state of the filter, calling this method causes the following behavior:

  • 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].
  • Status is PCAN_FILTER_CLOSE: The filter is set to the given range of IDs passed to this function [FromID, ToID].
  • 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 into account that configuring the message filter causes the CAN controller to enter the reset state. This will affect other applications that communicate with the same PCAN hardware.

Important note Important
  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".
Example

The following example shows the use of FilterMessages(UInt16, UInt32, UInt32, TPCANMode) method on the channel PCAN_USBBUS1 to receive a custom range of IDs. 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 Note
It is assumed that the channel was already initialized.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
UInt32 iBuffer;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized ...

// The message filter is closed first to ensure the reception of the new range of IDs.
//
iBuffer = PCANBasic.PCAN_FILTER_CLOSE;
result = PCANBasic.SetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_MESSAGE_FILTER, ref iBuffer, sizeof(UInt32));

if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
{
    // The message filter is configured to receive the IDs 2,3,4 and 5 on the PCAN-USB, Channel 1
    //
    result = PCANBasic.FilterMessages(PCANBasic.PCAN_USBBUS1, 2, 5, TPCANMode.PCAN_MODE_STANDARD);
    if (result != TPCANStatus.PCAN_ERROR_OK)
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic.GetErrorText(result, 0, strMsg);
        Console.WriteLine(strMsg.ToString());
    }
    else
        Console.WriteLine("Filter successfully configured for IDs 2,3,4 and 5");
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim iBuffer As UInt32

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized ...

'  The message filter is closed first to ensure the reception of the new range of IDs.
'
iBuffer = PCANBasic.PCAN_FILTER_CLOSE
result = PCANBasic.SetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_MESSAGE_FILTER, iBuffer, Convert.ToUInt32(Len(iBuffer)))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    ' The message filter is configured to receive the IDs 2,3,4 and 5 on the PCAN-USB, Channel 1
    '
    result = PCANBasic.FilterMessages(PCANBasic.PCAN_USBBUS1, 2, 5, TPCANMode.PCAN_MODE_STANDARD)
    If result <> TPCANStatus.PCAN_ERROR_OK Then
        ' An error occurred, get a text describing the error and show it
        '
        PCANBasic.GetErrorText(result, 0, strMsg)
        Console.WriteLine(strMsg.ToString)
    Else
        Console.WriteLine("Filter successfully configured for IDs 2,3,4 and 5")
    End If
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
UInt32 iBuffer;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized ...

// The message filter is closed first to ensure the reception of the new range of IDs.
//
iBuffer = PCANBasic::PCAN_FILTER_CLOSE;
result = PCANBasic::SetValue(PCANBasic::PCAN_USBBUS1, TPCANParameter::PCAN_MESSAGE_FILTER, iBuffer, sizeof(iBuffer));
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
{
    // The message filter is configured to receive the IDs 2,3,4 and 5 on the PCAN-USB, Channel 1
    //
    result = PCANBasic::FilterMessages(PCANBasic::PCAN_USBBUS1, 2, 5, TPCANMode::PCAN_MODE_STANDARD);
    if (result != TPCANStatus::PCAN_ERROR_OK)
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic::GetErrorText(result, 0, strMsg);
        Console::WriteLine(strMsg->ToString());
    }
    else
        Console::WriteLine("Filter successfully configured for IDs 2,3,4 and 5");
}
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.GetErrorText Method

PCANBasicGetErrorText Method

Returns a descriptive text for a given TPCANStatus code, in any of the supported languages.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus GetErrorText(
    TPCANStatus Error,
    ushort Language,
    StringBuilder StringBuffer
)
Public Shared Function GetErrorText (
    Error As TPCANStatus,
    Language As UShort,
    StringBuffer As StringBuilder
) As TPCANStatus
public:
static TPCANStatus GetErrorText(
    TPCANStatus Error,
    unsigned short Language,
    StringBuilder^ StringBuffer
)

Parameters

Error TPCANStatus
The error code to translate.
Language UInt16
The ID of the language to use for the output.
StringBuffer StringBuilder
A buffer for the output text with a capacity of at least 256 bytes.
Important note Important
Even when currently only short texts are being returned, a text within this method can have a maximum of 255 characters plus termination. Using small buffers could lead to exceptions like an access violation in future versions of the API.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
Remarks

The "Primary language IDs" are codes used by Windows OS from Microsoft, to identify a human language. Currently, following languages are supported:

Language | Primary Language ID
Neutral (System dependent) | 00h (0)
English | 09h (9)
German | 07h (7)
French | 0Ch (12)
Italian | 10h (16)
Spanish | 0Ah (10)
Example

The following example shows the use of GetErrorText(TPCANStatus, UInt16, StringBuilder) method to get the description of the error code PCAN_ERROR_INITIALIZE. The language used for the text will be the same as used by the operating system (if its language is supported; otherwise English is used).

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;

strMsg = new System.Text.StringBuilder(256);

// Gets the description text for PCAN_ERROR_INITIALIZE using the Neutral language
//
result = PCANBasic.GetErrorText(TPCANStatus.PCAN_ERROR_INITIALIZE, 0, strMsg);
if (result != TPCANStatus.PCAN_ERROR_OK)
    // An error occurred, show a message indicating it
    //
    Console.WriteLine("Error when recovering Error-Code's description");
else
    Console.WriteLine(strMsg.ToString());
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

strMsg = New System.Text.StringBuilder(256)

' Gets the description text for PCAN_ERROR_INITIALIZE using the Neutral language
'
result = PCANBasic.GetErrorText(TPCANStatus.PCAN_ERROR_INITIALIZE, 0, strMsg)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, show a message indicating it
    '
    Console.WriteLine("Error when recovering Error-Code's description")
Else
    Console.WriteLine(strMsg.ToString)
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

strMsg = gcnew System::Text::StringBuilder(256);

// Gets the description text for PCAN_ERROR_INITIALIZE using the Neutral language
//
result = PCANBasic::GetErrorText(TPCANStatus::PCAN_ERROR_INITIALIZE, 0, strMsg);
if (result != TPCANStatus::PCAN_ERROR_OK)
    // An error occurred, show a message indicating it
    //
    Console::WriteLine("Error when recovering Error-Code's description");
else
    Console::WriteLine(strMsg->ToString());
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic.GetStatus Method

PCANBasicGetStatus Method

Gets the current BUS status of a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus GetStatus(
    ushort Channel
)
Public Shared Function GetStatus (
    Channel As UShort
) As TPCANStatus
public:
static TPCANStatus GetStatus(
    unsigned short Channel
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN Channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLHW: Indicates that the hardware represented by the PCAN Channel being used was removed or deactivated.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_BUSLIGHT: Indicates a bus error within the given PCAN Channel. The hardware is in bus-light status.
  • PCAN_ERROR_BUSHEAVY: Indicates a bus error within the given PCAN Channel. The hardware is in bus-heavy status.
  • PCAN_ERROR_BUSPASSIVE: Indicates a bus error within the given PCAN Channel. The hardware is in bus-passive status.
  • PCAN_ERROR_BUSWARNING: Indicates a bus error within the given PCAN Channel. The hardware is in bus-warning status.
  • PCAN_ERROR_BUSOFF: Indicates a bus error within the given PCAN Channel. The hardware is in bus-off status.
  • PCAN_ERROR_OK: Indicates that the status of the given PCAN Channel is OK.
Remarks

When the hardware status is bus-off, an application cannot communicate anymore. Consider using the PCAN_BUSOFF_AUTORESET parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset errors like bus-off, bus-warning and bus-passive:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter PCAN_HARD_RESET_STATUS: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

Example

The following example shows the use of the GetStatus method 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 Note
It is assumed that the channel was already initialized

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized and communication takes place ...
// ... when needed, check the status of the Channel

// The status of the PCI Channel is checked
//
result = PCANBasic.GetStatus(PCANBasic.PCAN_PCIBUS1);
switch (result)
{
    case TPCANStatus.PCAN_ERROR_BUSLIGHT:
        Console.WriteLine("PCAN-PCI (Ch-1): Handling a BUS-LIGHT status...");
        break;
    case TPCANStatus.PCAN_ERROR_BUSHEAVY:
        Console.WriteLine("PCAN-PCI (Ch-1): Handling a BUS-HEAVY status...");
        break;
    case TPCANStatus.PCAN_ERROR_BUSOFF:
        Console.WriteLine("PCAN-PCI (Ch-1): Handling a BUS-OFF status...");
        break;
    case TPCANStatus.PCAN_ERROR_OK:
        Console.WriteLine("PCAN-PCI (Ch-1): Status is OK");
        break;
    default:
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic.GetErrorText(result, 0, strMsg);
        Console.WriteLine(strMsg.ToString());
        break;
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

strMsg = New System.Text.StringBuilder(256)

' ... channel Is initialized And communication takes place ...
' ... when needed, check the status of the Channel

' The status of the PCI Channel is checked
'
result = PCANBasic.GetStatus(PCANBasic.PCAN_PCIBUS1)
Select Case result
    Case TPCANStatus.PCAN_ERROR_BUSLIGHT
        Console.WriteLine("PCAN-PCI (Ch-1): Handling a BUS-LIGHT status...")
    Case TPCANStatus.PCAN_ERROR_BUSHEAVY
        Console.WriteLine("PCAN-PCI (Ch-1): Handling a BUS-HEAVY status...")
    Case TPCANStatus.PCAN_ERROR_BUSOFF
        Console.WriteLine("PCAN-PCI (Ch-1): Handling a BUS-OFF status...")
    Case TPCANStatus.PCAN_ERROR_OK
        Console.WriteLine("PCAN-PCI (Ch-1): Status is OK")
    Case Else
        ' An error occurred, get a text describing the error and show it
        '
        PCANBasic.GetErrorText(result, 0, strMsg)
        Console.WriteLine(strMsg.ToString)
End Select
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized and communication takes place ...
// ... when needed, check the status of the Channel

// The status of the PCI Channel is checked
//
result = PCANBasic::GetStatus(PCANBasic::PCAN_PCIBUS1);
switch (result)
{
case TPCANStatus::PCAN_ERROR_BUSLIGHT:
    Console::WriteLine("PCAN-PCI (Ch-1): Handling a BUS-LIGHT status...");
    break;
case TPCANStatus::PCAN_ERROR_BUSHEAVY:
    Console::WriteLine("PCAN-PCI (Ch-1): Handling a BUS-HEAVY status...");
    break;
case TPCANStatus::PCAN_ERROR_BUSOFF:
    Console::WriteLine("PCAN-PCI (Ch-1): Handling a BUS-OFF status...");
    break;
case TPCANStatus::PCAN_ERROR_OK:
    Console::WriteLine("PCAN-PCI (Ch-1): Status is OK");
    break;
default:
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
    break;
}
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.GetValue Method

PCANBasicGetValue Method

Overload List
Name | Description
GetValue(UInt16, TPCANParameter, TPCANChannelInformation) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, StringBuilder, UInt32) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, UInt32, UInt32) | Retrieves a PCAN Channel value.
GetValue(UInt16, TPCANParameter, UInt64, UInt32) | Retrieves a PCAN Channel value.
Top
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic.GetValue(UInt16, TPCANParameter, TPCANChannelInformation[]) Method

PCANBasicGetValue(UInt16, TPCANParameter, TPCANChannelInformation) Method

Retrieves a PCAN Channel value.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus GetValue(
    ushort Channel,
    TPCANParameter Parameter,
    TPCANChannelInformation[] ChannelsBuffer
)
Public Shared Function GetValue (
    Channel As UShort,
    Parameter As TPCANParameter,
    ChannelsBuffer As TPCANChannelInformation()
) As TPCANStatus
public:
static TPCANStatus GetValue(
    unsigned short Channel,
    TPCANParameter Parameter,
    array<TPCANChannelInformation>^ ChannelsBuffer
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Parameter TPCANParameter
The code of the information to be retrieved.
ChannelsBuffer TPCANChannelInformation
The buffer to return information about the current attached PCAN Channels.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLHW: Indicates that the given PCAN Channel is not available.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_ILLPARAMTYPE: Indicates that the requested information is not available for the given PCAN Channel. Check the value of Parameter; some values are not available for all PCAN-Channels or cannot be read.
Remarks

Use the method GetValue to get information about PCAN environment as parameters like information about the PCAN Channels current attached to the PC. Take in account that not all parameters are supported for all PCAN Channels. The access's type of the parameters can also be different.

For more information about the possible values that can be retrieved, see Parameter Value Definitions

Important note Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
Example

The following example shows the use of GetValue(UInt16, TPCANParameter, TPCANChannelInformation) method 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.

C#
VB
C++
Copy
uint channelsCount;

// The amount of available channels is asked, in order to create the buffer for their information
//
if (PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS_COUNT, out channelsCount, 4) == TPCANStatus.PCAN_ERROR_OK)
{
    Console.WriteLine("Total of {0} channels were found:", channelsCount);
    if (channelsCount > 0)
    {
        // The information of the current available channels is retrieved
        //
        TPCANChannelInformation[] channels = new TPCANChannelInformation[channelsCount];
        if (PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS, channels) == TPCANStatus.PCAN_ERROR_OK)
        {
            for (int i = 0; i < channelsCount; i++)
            {
                Console.WriteLine("{0}) ---------------------------\n", i + 1);
                Console.WriteLine(" Name: {0}", channels[i].device_name);
                Console.WriteLine(" Handle: 0x{0:X}", channels[i].channel_handle);
                Console.WriteLine("Controller: {0}", channels[i].controller_number);
                Console.WriteLine(" Condition: {0}", channels[i].channel_condition);
                Console.WriteLine(" . . . . .");
            }
        }
    }
}
Dim channelsCount As UInt32

' The amount of available channels Is asked, in order to create the buffer for their information
'
If PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS_COUNT, channelsCount, 4) = TPCANStatus.PCAN_ERROR_OK Then
    Console.WriteLine("Total of {0} channels were found:", channelsCount)
    If channelsCount > 0 Then

        ' The information of the current available channels is retrieved
        '
        Dim channels(channelsCount) As TPCANChannelInformation
        If (PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS, channels) = TPCANStatus.PCAN_ERROR_OK) Then
            ' Information about each available channels is shown
            '
            For i As Integer = 0 To channelsCount - 1
                Console.WriteLine("{0}) ---------------------------\n", i + 1)
                Console.WriteLine(" Name: {0}", channels(i).device_name)
                Console.WriteLine(" Handle: 0x{0:X}", channels(i).channel_handle)
                Console.WriteLine("Controller: {0}", channels(i).controller_number)
                Console.WriteLine(" Condition: {0}", channels(i).channel_condition)
                Console.WriteLine(" . . . . .")
            Next
        End If
    End If
End If
UInt32 channelsCount;

// The amount of available channels is asked, in order to create the buffer for their information
//
if (PCANBasic::GetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_ATTACHED_CHANNELS_COUNT, channelsCount, sizeof(channelsCount)) == TPCANStatus::PCAN_ERROR_OK)
{
    Console::WriteLine("Total of {0} channels were found:", channelsCount);
    if (channelsCount > 0)
    {
        // The information of the current available channels is retrieved
        //
        array <TPCANChannelInformation> ^channels = gcnew array<TPCANChannelInformation>(channelsCount);
        if (PCANBasic::GetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_ATTACHED_CHANNELS, channels) == TPCANStatus::PCAN_ERROR_OK)
        {
            for (int i = 0; i < channelsCount; i++)
            {
                Console::WriteLine("{0}) ---------------------------\n", i + 1);
                Console::WriteLine(" Name: {0}", channels[i].device_name);
                Console::WriteLine(" Handle: 0x{0:X}", channels[i].channel_handle);
                Console::WriteLine("Controller: {0}", channels[i].controller_number);
                Console::WriteLine(" Condition: {0}", channels[i].channel_condition);
                Console::WriteLine(" . . . . .");
            }
        }
    }
}
See Also

Reference

PCANBasic Class
GetValue Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Parameter Value Definitions
PCAN Handle Definitions


PCANBasic.GetValue(UInt16, TPCANParameter, StringBuilder, UInt32) Method

PCANBasicGetValue(UInt16, TPCANParameter, StringBuilder, UInt32) Method

Retrieves a PCAN Channel value.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus GetValue(
    ushort Channel,
    TPCANParameter Parameter,
    StringBuilder StringBuffer,
    uint BufferLength
)
Public Shared Function GetValue (
    Channel As UShort,
    Parameter As TPCANParameter,
    StringBuffer As StringBuilder,
    BufferLength As UInteger
) As TPCANStatus
public:
static TPCANStatus GetValue(
    unsigned short Channel,
    TPCANParameter Parameter,
    StringBuilder^ StringBuffer,
    unsigned int BufferLength
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Parameter TPCANParameter
The code of the information to be retrieved.
StringBuffer StringBuilder
The buffer to return the required string value.
BufferLength UInt32
The length in bytes of the given buffer.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLHW: Indicates that the given PCAN Channel is not available.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_ILLPARAMTYPE: Indicates that the requested information is not available for the given PCAN Channel. Check the value of Parameter; some values are not available for all PCAN-Channels or cannot be read.
Remarks

Use the method GetValue to get information about PCAN environment as parameters like the API version. Take in account that not all parameters are supported for all PCAN Channels. The access's type of the parameters can also be different.

For more information about the possible values that can be retrieved, see Parameter Value Definitions

Important note Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
Example

The following example shows the use of GetValue(UInt16, TPCANParameter, StringBuilder, UInt32) method 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.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;

strMsg = new System.Text.StringBuilder(256);

// The version of the PCAN-USB Channel 1 is asked.
//
result = PCANBasic.GetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_CHANNEL_VERSION, strMsg, 256);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
{
    // Show the version message
    //
    Console.WriteLine(strMsg.ToString());
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

strMsg = New System.Text.StringBuilder(256)

' The version of the PCAN-USB Channel 1 is asked.
'
result = PCANBasic.GetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_CHANNEL_VERSION, strMsg, 256)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString())
Else
    ' Show the version message
    '
    Console.WriteLine(strMsg.ToString())
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

strMsg = gcnew System::Text::StringBuilder(256);

// The version of the PCAN-USB Channel 1 is asked.
//
result = PCANBasic::GetValue(PCANBasic::PCAN_USBBUS1, TPCANParameter::PCAN_CHANNEL_VERSION, strMsg, 256);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
{
    // Show the version message
    //
    Console::WriteLine(strMsg->ToString());
}
See Also

Reference

PCANBasic Class
GetValue Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Parameter Value Definitions
PCAN Handle Definitions


PCANBasic.GetValue(UInt16, TPCANParameter, UInt32, UInt32) Method

PCANBasicGetValue(UInt16, TPCANParameter, UInt32, UInt32) Method

Retrieves a PCAN Channel value.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus GetValue(
    ushort Channel,
    TPCANParameter Parameter,
    out uint NumericBuffer,
    uint BufferLength
)
Public Shared Function GetValue (
    Channel As UShort,
    Parameter As TPCANParameter,
    <OutAttribute> ByRef NumericBuffer As UInteger,
    BufferLength As UInteger
) As TPCANStatus
public:
static TPCANStatus GetValue(
    unsigned short Channel,
    TPCANParameter Parameter,
    [OutAttribute] unsigned int% NumericBuffer,
    unsigned int BufferLength
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Parameter TPCANParameter
The code of the information to be retrieved.
NumericBuffer UInt32
The buffer to return the required 32-bit numeric value (see Parameter Value Definitions).
BufferLength UInt32
The length in bytes of the given buffer.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLHW: Indicates that the given PCAN Channel is not available.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_ILLPARAMTYPE: Indicates that the requested information is not available for the given PCAN Channel. Check the value of Parameter; some values are not available for all PCAN-Channels or cannot be read.
Remarks

Use the method GetValue to get information about PCAN environment as parameters like the PCAN Channel device ID. Take in account that not all parameters are supported for all PCAN Channels. The access's type of the parameters can also be different.

For more information about the possible values that can be retrieved, see Parameter Value Definitions

Important note Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
Example

The following example shows the use of GetValue(UInt16, TPCANParameter, UInt32, UInt32) method 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 Note
It is assumed that the channel was already initialized.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
UInt32 iBuffer;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized ...

// The status of the message filter of the PCAN-USB Channel 1 is asked
//
result = PCANBasic.GetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_MESSAGE_FILTER, out iBuffer, sizeof(UInt32));
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
{
    // A text is shown giving information about the current status of the filter
    //
    switch (iBuffer)
    {
        case PCANBasic.PCAN_FILTER_OPEN:
            Console.WriteLine("The message filter for the PCAN-USB, channel 1, is completely opened.");
            break;
        case PCANBasic.PCAN_FILTER_CLOSE:
            Console.WriteLine("The message filter for the PCAN-USB, channel 1, is closed.");
            break;
        case PCANBasic.PCAN_FILTER_CUSTOM:
            Console.WriteLine("The message filter for the PCAN-USB, channel 1, is custom configured.");
            break;
    }
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim iBuffer As UInt32

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized ...

' The status of the message filter of the PCAN-USB Channel 1 is asked
'
result = PCANBasic.GetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_MESSAGE_FILTER, iBuffer, CType(System.Runtime.InteropServices.Marshal.SizeOf(iBuffer), UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString())
Else
    ' A text is shown giving information about the current status of the filter
    '
    Select Case iBuffer
        Case PCANBasic.PCAN_FILTER_OPEN
            Console.WriteLine("The message filter for the PCAN-USB, channel 1, is completely opened.")
        Case PCANBasic.PCAN_FILTER_CLOSE
            Console.WriteLine("The message filter for the PCAN-USB, channel 1, is closed.")
        Case PCANBasic.PCAN_FILTER_CUSTOM
            Console.WriteLine("The message filter for the PCAN-USB, channel 1, is custom configured.")
    End Select
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
UInt32 iBuffer;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized ...

// The status of the message filter of the PCAN-USB Channel 1 is asked
//
result = PCANBasic::GetValue(PCANBasic::PCAN_USBBUS1, TPCANParameter::PCAN_MESSAGE_FILTER, iBuffer, sizeof(iBuffer));
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
{
    // A text is shown giving information about the current status of the filter
    //
    switch (iBuffer)
    {
    case PCANBasic::PCAN_FILTER_OPEN:
        Console::WriteLine("The message filter for the PCAN-USB, channel 1, is completely opened.");
        break;
    case PCANBasic::PCAN_FILTER_CLOSE:
        Console::WriteLine("The message filter for the PCAN-USB, channel 1, is closed.");
        break;
    case PCANBasic::PCAN_FILTER_CUSTOM:
        Console::WriteLine("The message filter for the PCAN-USB, channel 1, is custom configured.");
        break;
    }
}
See Also

Reference

PCANBasic Class
GetValue Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Parameter Value Definitions
PCAN Handle Definitions


PCANBasic.GetValue(UInt16, TPCANParameter, UInt64, UInt32) Method

PCANBasicGetValue(UInt16, TPCANParameter, UInt64, UInt32) Method

Retrieves a PCAN Channel value.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus GetValue(
    ushort Channel,
    TPCANParameter Parameter,
    out ulong NumericBuffer,
    uint BufferLength
)
Public Shared Function GetValue (
    Channel As UShort,
    Parameter As TPCANParameter,
    <OutAttribute> ByRef NumericBuffer As ULong,
    BufferLength As UInteger
) As TPCANStatus
public:
static TPCANStatus GetValue(
    unsigned short Channel,
    TPCANParameter Parameter,
    [OutAttribute] unsigned long long% NumericBuffer,
    unsigned int BufferLength
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Parameter TPCANParameter
The code of the information to be retrieved.
NumericBuffer UInt64
The buffer to return the required 64-bit numeric value (see Parameter Value Definitions).
BufferLength UInt32
The length in bytes of the given buffer.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLHW: Indicates that the given PCAN Channel is not available.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_ILLPARAMTYPE: Indicates that the requested information is not available for the given PCAN Channel. Check the value of Parameter; some values are not available for all PCAN-Channels or cannot be read.
Remarks

Use the method GetValue to get information about PCAN environment as parameters like the Acceptance Filter (Code/Mask). Take in account that not all parameters are supported for all PCAN Channels. The access's type of the parameters can also be different.

For more information about the possible values that can be retrieved, see Parameter Value Definitions

Important note Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
Example

The following example shows the use of GetValue(UInt16, TPCANParameter, UInt64, UInt32) method 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 Note
It is assumed that the channel was already initialized.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
UInt64 i64Buffer;
UInt32 iCode, iMask;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized ...

// The 11-bit acceptance filter of the PCAN-USB Channel 1 is asked
//
result = PCANBasic.GetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_ACCEPTANCE_FILTER_11BIT, out i64Buffer, sizeof(UInt64));
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
{
    // Code and mask are extracted from the 64-bit numeric value
    //
    iCode = Convert.ToUInt32(i64Buffer >> 32);
    iMask = Convert.ToUInt32(i64Buffer & UInt32.MaxValue);

    // A text is shown giving information about the 11-bit mask and code of the acceptance filter
    //
    Console.WriteLine(string.Format("Configured 11-bit acceptance filter: Code: {0:X8} | Mask: {1:X8}", iCode, iMask));
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim i64Buffer As UInt64
Dim iCode As UInt32
Dim iMask As UInt32

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized ...

' The 11-bit acceptance filter of the PCAN-USB Channel 1 is asked
'
result = PCANBasic.GetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_ACCEPTANCE_FILTER_11BIT, i64Buffer, CType(System.Runtime.InteropServices.Marshal.SizeOf(i64Buffer), UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString())
Else
    ' Code and mask are extracted from the 64-bit numeric value
    '
    iCode = Convert.ToUInt32(i64Buffer >> 32)
    iMask = Convert.ToUInt32(i64Buffer And UInt32.MaxValue)

    ' A text is shown giving information about the 11-bit mask and code of the acceptance filter
    '
    Console.WriteLine(String.Format("Configured 11-bit acceptance filter: Code: {0:X8} | Mask: {1:X8}", iCode, iMask))
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
UInt64 i64Buffer;
UInt32 iCode, iMask;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized ...

// The 11-bit acceptance filter of the PCAN-USB Channel 1 is asked
//
result = PCANBasic::GetValue(PCANBasic::PCAN_USBBUS1, TPCANParameter::PCAN_ACCEPTANCE_FILTER_11BIT, i64Buffer, sizeof(i64Buffer));
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
{
    // Code and mask are extracted from the 64-bit numeric value
    //
    iCode = Convert::ToUInt32(i64Buffer >> 32);
    iMask = Convert::ToUInt32(i64Buffer & UInt32::MaxValue);

    // A text is shown giving information about the 11-bit mask and code of the acceptance filter
    //
    Console::WriteLine(String::Format("Configured 11-bit acceptance filter: Code: {0:X8} | Mask: {1:X8}", iCode, iMask));
}
See Also

Reference

PCANBasic Class
GetValue Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Parameter Value Definitions
PCAN Handle Definitions


PCANBasic.Initialize Method

PCANBasicInitialize Method

Overload List
Name | Description
Initialize(UInt16, TPCANBaudrate) | Initializes a PCAN Channel.
Initialize(UInt16, TPCANBaudrate, TPCANType, UInt32, UInt16) | Initializes a PCAN Channel.
Top
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic.Initialize(UInt16, TPCANBaudrate) Method

PCANBasicInitialize(UInt16, TPCANBaudrate) Method

Initializes a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus Initialize(
    ushort Channel,
    TPCANBaudrate Btr0Btr1
)
Public Shared Function Initialize (
    Channel As UShort,
    Btr0Btr1 As TPCANBaudrate
) As TPCANStatus
public:
static TPCANStatus Initialize(
    unsigned short Channel,
    TPCANBaudrate Btr0Btr1
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Btr0Btr1 TPCANBaudrate
The speed for the communication (BTR0BTR1 code).

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_CAUTION: Indicates that the channel has been initialized but at a different bit rate as the given one.
  • PCAN_ERROR_ILLHANDLE: Indicates that the desired PCAN Channel is not valid.
  • PCAN_ERROR_ILLHW: Indicates that the desired PCAN Channel is not available.
  • PCAN_ERROR_ILLOPERATION: Indicates that an action cannot be executed due to the state of the hardware. Possible causes are:
    • The desired PCAN Channel is a LAN Channel, which uses a different bit rate than the specified.
  • PCAN_ERROR_ILLMODE: Indicates that the hardware is working in a different or incompatible mode than requested. Possible causes are:
    • The desired PCAN Channel is being operated in CAN-FD mode.
  • PCAN_ERROR_INITIALIZE: Indicates that the desired PCAN Channel cannot be connected because it is already in use (PCAN-Basic / PCAN-Light environment).
  • PCAN_ERROR_NETINUSE: Indicates that the desired PCAN Channel is being used with a different bit rate (PCAN-View).
  • PCAN_ERROR_HWINUSE: Indicates that the desired PCAN Channel is being used (PcanApi connection).
  • PCAN_ERROR_NODRIVER: The driver needed for connecting the desired PCAN Channel is not loaded.
Remarks
Important note Important
A Channel that is initialized using Initialize must use Read and Write for communication. Calling ReadFD and/or WriteFD will result in a PCAN_ERROR_ILLOPERATION error.
Note Note
For initializing a CAN-FD capable channel for CAN-FD communication use the method InitializeFD instead.
Note Note
For initializing non plug-and-play channels like a PCAN-Dongle or PCAN-ISA card, use the method Initialize(UInt16, TPCANBaudrate, TPCANType, UInt32, UInt16) instead.

As indicated by its name, the Initialize method initiates a PCAN Channel, preparing it for communicate within the CAN bus connected to it. Calls to the other methods will fail if they are used with a Channel handle, different than PCAN_NONEBUS, that has not been initialized yet. Each initialized channel should be released when it is not needed anymore.

Initializing a PCAN Channel means:

  • to reserve the Channel for the calling application/process.
  • to allocate channel resources, like receive and transmit queues.
  • to register/connect the Hardware denoted by the channel handle.
  • to check and adapt the bus speed, if the Channel is already in use. (Only if the Channel was configured to adapt an available bit rate; see: PCAN_BITRATE_ADAPTING parameter).
  • to set the channel in Listen-Only mode. (Only if the channel was configured to work in Listen-Only mode; see: PCAN_LISTEN_ONLY parameter).
  • to configure the filter to catch all messages being transmitted in the bus.
  • to set-up the default values of the different parameters (see method GetValue).
  • to set the Receive Status of the channel. (See: PCAN_RECEIVE_STATUS parameter).

Other than in the PCAN-Light API, the Initialization process will fail if an application tries to initialize a PCAN Channel that has been initialized already within the same process.

Take in consideration that initializing a channel causes a reset of the CAN hardware, when the bus status is other than OK. In this way errors like PCAN_ERROR_BUSOFF, PCAN_ERROR_BUSHEAVY, and PCAN_ERROR_BUSLIGHT, are removed.

PCAN-LAN Channels

A PCAN-LAN channel doesn't allow changing the bit rate using PCAN-Basic. In order to connect a PCAN-LAN Channel it is necessary to know the bit rate of the PCAN-Gateway device that is represented by that channel. If the bit rate is not known, the parameter PCAN_BITRATE_ADAPTING should be used.

Example

The following example shows the initialization and uninitialization processes for a Plug-And-Play channel (channel 2 of a PCAN-PCI hardware). 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.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;

// The Plug & Play Channel (PCAN-PCI) is initialized
//
result = PCANBasic.Initialize(PCANBasic.PCAN_PCIBUS2, TPCANBaudrate.PCAN_BAUD_500K);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    strMsg = new System.Text.StringBuilder(256);
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("PCAN-PCI (Ch-2) was initialized");

// All initialized channels are released
//
PCANBasic.Uninitialize(PCANBasic.PCAN_NONEBUS);
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

' The Plug & Play Channel (PCAN-PCI) is initialized
'
result = PCANBasic.Initialize(PCANBasic.PCAN_PCIBUS2, TPCANBaudrate.PCAN_BAUD_500K)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    strMsg = New System.Text.StringBuilder(256)
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("PCAN-PCI (Ch-2) was initialized")
End If

' All initialized channels are released
'
PCANBasic.Uninitialize(PCANBasic.PCAN_NONEBUS)
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

// The Plug & Play Channel (PCAN-PCI) is initialized
//
result = PCANBasic::Initialize(PCANBasic::PCAN_PCIBUS2, TPCANBaudrate::PCAN_BAUD_500K);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    strMsg = gcnew System::Text::StringBuilder(256);
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("PCAN-PCI (Ch-2) was initialized");

// All initialized channels are released
//
PCANBasic::Uninitialize(PCANBasic::PCAN_NONEBUS);
See Also

Reference

PCANBasic Class
Initialize Overload
Peak.Can.Basic.BackwardCompatibility Namespace
Uninitialize

Other Resources

PCAN Handle Definitions


PCANBasic.Initialize(UInt16, TPCANBaudrate, TPCANType, UInt32, UInt16) Method

PCANBasicInitialize(UInt16, TPCANBaudrate, TPCANType, UInt32, UInt16) Method

Initializes a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus Initialize(
    ushort Channel,
    TPCANBaudrate Btr0Btr1,
    TPCANType HwType,
    uint IOPort,
    ushort Interrupt
)
Public Shared Function Initialize (
    Channel As UShort,
    Btr0Btr1 As TPCANBaudrate,
    HwType As TPCANType,
    IOPort As UInteger,
    Interrupt As UShort
) As TPCANStatus
public:
static TPCANStatus Initialize(
    unsigned short Channel,
    TPCANBaudrate Btr0Btr1,
    TPCANType HwType,
    unsigned int IOPort,
    unsigned short Interrupt
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Btr0Btr1 TPCANBaudrate
The speed for the communication (BTR0BTR1 code).
HwType TPCANType
Non-PnP: The type of hardware and operation mode.
IOPort UInt32
Non-PnP: The I/O address for the parallel port.
Interrupt UInt16
Non-PnP: Interrupt number of the parallel port.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_CAUTION: Indicates that the channel has been initialized but at a different bit rate as the given one.
  • PCAN_ERROR_ILLHANDLE: Indicates that the desired PCAN Channel is not valid.
  • PCAN_ERROR_ILLHW: Indicates that the desired PCAN Channel is not available.
  • PCAN_ERROR_ILLOPERATION: Indicates that an action cannot be executed due to the state of the hardware. Possible causes are:
    • The desired PCAN Channel is a LAN Channel, which uses a different bit rate than the specified.
  • PCAN_ERROR_ILLMODE: Indicates that the hardware is working in a different or incompatible mode than requested. Possible causes are:
    • The desired PCAN Channel is being operated in CAN-FD mode.
  • PCAN_ERROR_REGTEST: Indicates a problem with hardware registration, normally due to wrong values in the parameters 'HwType', 'IOPort' and 'Interrupt'.
  • PCAN_ERROR_INITIALIZE: Indicates that the desired PCAN Channel cannot be connected because it is already in use (PCAN-Basic / PCAN-Light environment).
  • PCAN_ERROR_NETINUSE: Indicates that the desired PCAN Channel is being used with a different bit rate (PCAN-View).
  • PCAN_ERROR_HWINUSE: Indicates that the desired PCAN Channel is being used (PcanApi connection).
  • PCAN_ERROR_NODRIVER: The driver needed for connecting the desired PCAN Channel is not loaded.
Remarks
Important note Important
A Channel that is initialized using Initialize must use Read and Write for communication. Calling ReadFD and/or WriteFD will result in a PCAN_ERROR_ILLOPERATION error.
Important note Important
Non plug-and-play channels are not CAN-FD capable.
Note Note
For initializing plug-and-play channels like a PCAN-USB or PCAN-PCI card, use the method Initialize(UInt16, TPCANBaudrate) instead.

The parameters HwType, Interrupt, and IOPort are only required for the initialization of non plug-and-play channels.

As indicated by its name, the Initialize method initiates a PCAN Channel, preparing it for communicate within the CAN bus connected to it. Calls to the other methods will fail if they are used with a Channel handle, different than PCAN_NONEBUS, that has not been initialized yet. Each initialized channel should be released when it is not needed anymore.

Initializing a PCAN Channel means:

  • to reserve the Channel for the calling application/process.
  • to allocate channel resources, like receive and transmit queues.
  • to register/connect the Hardware denoted by the channel handle.
  • to check and adapt the bus speed, if the Channel is already in use. (Only if the Channel was configured to adapt an available bit rate; see: PCAN_BITRATE_ADAPTING parameter).
  • to set the channel in Listen-Only mode. (Only if the channel was configured to work in Listen-Only mode; see: PCAN_LISTEN_ONLY parameter).
  • to configure the filter to catch all messages being transmitted in the bus.
  • to set-up the default values of the different parameters (see method GetValue).
  • to set the Receive Status of the channel. (See: PCAN_RECEIVE_STATUS parameter).

Other than in the PCAN-Light API, the Initialization process will fail if an application tries to initialize a PCAN Channel that has been initialized already within the same process.

Take in consideration that initializing a channel causes a reset of the CAN hardware, when the bus status is other than OK. In this way errors like PCAN_ERROR_BUSOFF, PCAN_ERROR_BUSHEAVY, and PCAN_ERROR_BUSLIGHT, are removed.

PCAN-LAN Channels

A PCAN-LAN channel doesn't allow changing the bit rate using PCAN-Basic. In order to connect a PCAN-LAN Channel it is necessary to know the bit rate of the PCAN-Gateway device that is represented by that channel. If the bit rate is not known, the parameter PCAN_BITRATE_ADAPTING should be used.

Example

The following example shows the initialization and uninitialization processes for a not Plug-And-Play channel (channel 1 of the PCAN-DNG). 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.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;

// The Not Plug & Play Channel (PCAN-DNG) is initialized
//
result = PCANBasic.Initialize(PCANBasic.PCAN_DNGBUS1, TPCANBaudrate.PCAN_BAUD_500K, TPCANType.PCAN_TYPE_DNG_SJA, 0x378, 7);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    strMsg = new System.Text.StringBuilder(256);
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("PCAN-DNG (Ch-1) was initialized");

// All initialized channels are released
//
PCANBasic.Uninitialize(PCANBasic.PCAN_NONEBUS);
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

' The Not Plug & Play Channel (PCAN-DNG) is initialized
'
result = PCANBasic.Initialize(PCANBasic.PCAN_DNGBUS1, TPCANBaudrate.PCAN_BAUD_500K, TPCANType.PCAN_TYPE_DNG_SJA, &H378, 7)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    strMsg = New System.Text.StringBuilder(256)
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("PCAN-DNG (Ch-1) was initialized")
End If

' All initialized channels are released
'
PCANBasic.Uninitialize(PCANBasic.PCAN_NONEBUS)
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

// The Not Plug & Play Channel (PCAN-DNG) is initialized
//
result = PCANBasic::Initialize(PCANBasic::PCAN_DNGBUS1, TPCANBaudrate::PCAN_BAUD_500K, TPCANType::PCAN_TYPE_DNG_SJA, 0x378, 7);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    strMsg = gcnew System::Text::StringBuilder(256);
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("PCAN-DNG (Ch-1) was initialized");

// All initialized channels are released
//
PCANBasic::Uninitialize(PCANBasic::PCAN_NONEBUS);
See Also

Reference

PCANBasic Class
Initialize Overload
Peak.Can.Basic.BackwardCompatibility Namespace
Uninitialize

Other Resources

PCAN Handle Definitions


PCANBasic.InitializeFD Method

PCANBasicInitializeFD Method

Initializes a FD capable PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus InitializeFD(
    ushort Channel,
    string BitrateFD
)
Public Shared Function InitializeFD (
    Channel As UShort,
    BitrateFD As String
) As TPCANStatus
public:
static TPCANStatus InitializeFD(
    unsigned short Channel,
    String^ BitrateFD
)

Parameters

Channel UInt16
The handle of a FD capable PCAN Channel (see PCAN Handle Definitions).
BitrateFD String
The speed for the communication (see FD Bit rate Parameter Definitions).

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_CAUTION: Indicates that the channel has been initialized but at a different bit rate as the given one.
  • PCAN_ERROR_ILLHANDLE: Indicates that the desired PCAN Channel is not valid.
  • PCAN_ERROR_ILLHW: Indicates that the desired PCAN Channel is not available.
  • PCAN_ERROR_ILLOPERATION: Indicates that an action cannot be executed due to the state of the hardware. Possible causes are:
    • The desired PCAN Channel is not CAN-FD capable and cannot be initialized using this method.
    • The desired PCAN Channel is a LAN Channel, which uses a different bit rate than the specified.
  • PCAN_ERROR_ILLMODE: Indicates that the hardware is working in a different or incompatible mode than requested. Possible causes are:
    • The desired PCAN Channel is being operated in CAN 2.0 A/B mode.
  • PCAN_ERROR_INITIALIZE: Indicates that the desired PCAN Channel cannot be connected because it is already in use (PCAN-Basic / PCAN-Light environment).
  • PCAN_ERROR_NETINUSE: Indicates that the desired PCAN Channel is being used with a different bit rate (PCAN-View).
  • PCAN_ERROR_HWINUSE: Indicates that the desired PCAN Channel is being used (PcanApi connection).
  • PCAN_ERROR_NODRIVER: The driver needed for connecting the desired PCAN Channel is not loaded.
Remarks
Important note Important
A Channel that is initialized using InitializeFD must use ReadFD and WriteFD for communication. Calling Read and/or Write will result in a PCAN_ERROR_ILLOPERATION error.
Note Note
For initializing a channel for CAN communication (no CAN-FD), use the method Initialize instead.

As indicated by its name, the InitializeFD method initiates a PCAN Channel, preparing it for communicate within the CAN bus connected to it. Calls to the other methods will fail if they are used with a Channel handle, different than PCAN_NONEBUS, that has not been initialized yet. Each initialized channel should be released when it is not needed anymore.

Initializing a PCAN Channel means:

  • to reserve the Channel for the calling application/process.
  • to allocate channel resources, like receive and transmit queues.
  • to register/connect the Hardware denoted by the channel handle.
  • to check and adapt the bus speed, if the Channel is already in use. (Only if the Channel was configured to adapt an available bit rate; see: PCAN_BITRATE_ADAPTING parameter).
  • to set the channel in Listen-Only mode. (Only if the channel was configured to work in Listen-Only mode; see: PCAN_LISTEN_ONLY parameter).
  • to configure the filter to catch all messages being transmitted in the bus.
  • to set-up the default values of the different parameters (see method GetValue).
  • to set the Receive Status of the channel. (See: PCAN_RECEIVE_STATUS parameter).

Other than in the PCAN-Light API, the Initialization process will fail if an application tries to initialize a PCAN Channel that has been initialized already within the same process.

Take in consideration that initializing a channel causes a reset of the CAN hardware, when the bus status is other than OK. In this way errors like PCAN_ERROR_BUSOFF, PCAN_ERROR_BUSWARNING, and PCAN_ERROR_BUSPASSIVE, are removed.

PCAN-LAN Channels

A PCAN-LAN channel doesn't allow changing the bit rate using PCAN-Basic. In order to connect a PCAN-LAN Channel it is necessary to know the bit rate of the PCAN-Gateway device that is represented by that channel. If the bit rate is not known, the parameter PCAN_BITRATE_ADAPTING should be used.

Example

The following example shows the initialization and uninitialization processes for a CAN-FD capable channel (channel 1 of a PCAN-USB Pro FD hardware). 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.

C#
VB
C++
Copy
string bitrate;
TPCANStatus result;
System.Text.StringBuilder strMsg;

// Defines a FD Bit rate string with nominal bit rate of 500 kBit/s and data bit rate of 2 MB (SAE J2284-4)
//
bitrate = "f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4";

// The FD capable Channel (PCAN-USB Pro FD) is initialized
//
result = PCANBasic.InitializeFD(PCANBasic.PCAN_USBBUS1, bitrate);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    strMsg = new System.Text.StringBuilder(256);
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("PCAN-USB Pro FD (Ch-1) was initialized");

// All initialized channels are released
//
PCANBasic.Uninitialize(PCANBasic.PCAN_NONEBUS);
Dim bitrate As String
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

' Defines a FD Bit rate string with nominal bit rate of 500 kBit/s and data bit rate of 2 MB (SAE J2284-4)
'
bitrate = "f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4"

' The FD capable Channel (PCAN-USB Pro FD) is initialized
'
result = PCANBasic.InitializeFD(PCANBasic.PCAN_USBBUS1, bitrate)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    strMsg = New System.Text.StringBuilder(256)
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("PCAN-USB Pro FD (Ch-1) was initialized")
End If

' All initialized channels are released
'
PCANBasic.Uninitialize(PCANBasic.PCAN_NONEBUS)
String^ bitrate;
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

// Defines a FD Bit rate string with nominal bit rate of 500 kBit/s and data bit rate of 2 MB (SAE J2284-4)
//
bitrate = "f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4";

// The FD capable Channel (PCAN-USB Pro FD) is initialized
//
result = PCANBasic::InitializeFD(PCANBasic::PCAN_USBBUS1, bitrate);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    strMsg = gcnew System::Text::StringBuilder(256);
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("PCAN-USB Pro FD (Ch-1) was initialized");

// All initialized channels are released
//
PCANBasic::Uninitialize(PCANBasic::PCAN_NONEBUS);
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace
Uninitialize

Other Resources

PCAN Handle Definitions
FD Bit rate Parameter Definitions


PCANBasic.LookUpChannel Method

PCANBasicLookUpChannel Method

Finds the handle of a PCAN Channel that matches the given parameters.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus LookUpChannel(
    string Parameters,
    out ushort FoundChannel
)
Public Shared Function LookUpChannel (
    Parameters As String,
    <OutAttribute> ByRef FoundChannel As UShort
) As TPCANStatus
public:
static TPCANStatus LookUpChannel(
    String^ Parameters,
    [OutAttribute] unsigned short% FoundChannel
)

Parameters

Parameters String
A comma-separated string of search parameters, that is, parameter name/value pairs to be matched within a PCAN Channel.
FoundChannel UInt16
Buffer for returning the PCAN Channel (see PCAN Handle Definitions), when found. It contains the value PCAN_NONEBUS if not found.

Return Value

TPCANStatus

The return value is a TPCANStatus value.PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
Remarks

The Parameters string must contain name/value pairs separated with a '=' character.

Each pair of name/value must be separated with a ',' character.

The current supported parameters and their value ranges are described in Look Up Parameter Definitions

Example

The following example shows the use of SetValue(UInt16, TPCANParameter, String, UInt32) method to get the handle of an USB device with ID 7. 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.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
UInt16 channelHandle;

strMsg = new System.Text.StringBuilder(256);

// Try to find a PCAN-USB device with ID 7
//
result = PCANBasic.LookUpChannel("devicetype=pcan_usb, deviceid=7", out channelHandle);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
{
    if (channelHandle != PCANBasic.PCAN_NONEBUS)
        Console.WriteLine("The channel handle for the PCAN-USB with ID=7 was found");
    else
        Console.WriteLine("A PCAN-USB device with ID=7 is not available");
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim channelHandle As UInt16

strMsg = New System.Text.StringBuilder(256)

' Try to find a PCAN-USB device with ID 7
'
result = PCANBasic.LookUpChannel("devicetype=pcan_usb, deviceid=7", channelHandle)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error And show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    If channelHandle <> PCANBasic.PCAN_NONEBUS Then
        Console.WriteLine("The channel handle for the PCAN-USB with ID=7 was found")
    Else
        Console.WriteLine("A PCAN-USB device with ID=7 is not available")
    End If
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
UInt16 channelHandle;

strMsg = gcnew System::Text::StringBuilder(256);

// Try to find a PCAN-USB device with ID 7
//
result = PCANBasic::LookUpChannel("devicetype=pcan_usb, deviceid=7", channelHandle);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
{
    if (channelHandle != PCANBasic::PCAN_NONEBUS)
        Console::WriteLine("The channel handle for the PCAN-USB with ID=7 was found");
    else
        Console::WriteLine("A PCAN-USB device with ID=7 is not available");
}
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Look Up Parameter Definitions
PCAN Handle Definitions


PCANBasic.Read Method

PCANBasicRead Method

Overload List
Name | Description
Read(UInt16, TPCANMsg) | Reads a CAN message from the receive queue of a PCAN Channel.
Read(UInt16, TPCANMsg, TPCANTimestamp) | Reads a CAN message and its time stamp from the receive queue of a PCAN Channel.
Top
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic.Read(UInt16, TPCANMsg) Method

PCANBasicRead(UInt16, TPCANMsg) Method

Reads a CAN message from the receive queue of a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus Read(
    ushort Channel,
    out TPCANMsg MessageBuffer
)
Public Shared Function Read (
    Channel As UShort,
    <OutAttribute> ByRef MessageBuffer As TPCANMsg
) As TPCANStatus
public:
static TPCANStatus Read(
    unsigned short Channel,
    [OutAttribute] TPCANMsg% MessageBuffer
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
MessageBuffer TPCANMsg
A buffer to store the CAN message.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLOPERATION: Indicates that the PCAN Channel passed to the method was not initialized using the Initialize method.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_BUSLIGHT: Indicates a bus error within the given PCAN Channel. The hardware is in bus-light status.
    Note Note
    MessageBuffer is valid in this case.
  • PCAN_ERROR_BUSHEAVY: Indicates a bus error within the given PCAN Channel. The hardware is in bus-heavy status.
    Note Note
    MessageBuffer is valid in this case.
  • PCAN_ERROR_BUSOFF: Indicates a bus error within the given PCAN Channel. The hardware is in bus-off status.
    Note Note
    MessageBuffer is valid in this case.
  • PCAN_ERROR_QRCVEMPTY: Indicates that the reception queue of the Channel is empty.
  • PCAN_ERROR_ILLDATA: Indicates that the message that has been read is not permitted due to the current settings and has been discarded.
Remarks
Important note Important
The use of Read and ReadFD is mutually exclusive. The PCAN Channel passed to this method must be initialized using the Initialize method. Otherwise the error PCAN_ERROR_ILLOPERATION is returned.
Note Note
If the time when the message was received is required, use the Read(UInt16, TPCANMsg, TPCANTimestamp) method instead.

The Read method returns CAN frames from the reception queue. It is important to call Read repeatedly until the reception queue becomes empty. In case there are no more messages to retrieve, the error PCAN_ERROR_QRCVEMPTY is returned. The error PCAN_ERROR_QRCVEMPTY is also returned if the reception of messages, configurable through the PCAN_RECEIVE_STATUS parameter, is disabled.

The receive queue can contain up to 32768 messages.

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 starts a timer that checks for messages every 50 or 100 milliseconds, calling the Read method in a loop until the error PCAN_ERROR_QRCVEMPTY 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 placed in its reception queue. See Using Events to obtain more information about reading with events.

About bus errors / Status messages

Important note Important
If a status message is read, the return value of the Read method is also the error code.

If a bus-off error occur, an application cannot use the channel to communicate anymore, until the CAN controller is reset. Consider using the PCAN_BUSOFF_AUTORESET parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset errors like bus-off, bus-heavy and bus-light:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter PCAN_HARD_RESET_STATUS: It instructs this method to explicitly perform a hardware reset regardless of whether other 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 flag PCAN_MESSAGE_ERRFRAME is set in the TPCANMsg.MSGTYPE field, the message is an Error Frame.

If the flag PCAN_MESSAGE_STATUS is set in the TPCANMsg.MSGTYPE field, the message is a PCAN Status Frame.

Example

The following example shows the use of Read(UInt16, TPCANMsg) method 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 Note
It is assumed that the channel was already initialized and that the following code is called periodically, e.g. using a timer.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
TPCANMsg msg;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized and communication takes place ...

do
{
    // Check the receive queue for new messages
    //
    result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1, out msg);
    if (result != TPCANStatus.PCAN_ERROR_QRCVEMPTY)
    {
        // Process the received message
        //
        Console.WriteLine("A message was received");
        ProcessMessage(msg);
    }
    else
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic.GetErrorText(result, 0, strMsg);
        Console.WriteLine(strMsg.ToString());
        // Here can be decided if the loop has to be  terminated (eg. the bus
        // status is  bus-off)
        //
        HandleReadError(result);
    }
    // Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    // until the queue is empty
    //
} while ((result & TPCANStatus.PCAN_ERROR_QRCVEMPTY) != TPCANStatus.PCAN_ERROR_QRCVEMPTY);
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim msg As TPCANMsg = Nothing

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized and communication takes place ...

Do
    ' Check the receive queue for new messages
    '
    result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1, msg)
    If result <> TPCANStatus.PCAN_ERROR_QRCVEMPTY Then
        Console.WriteLine("A message was received")
        ProcessMessage(msg)
    Else
        ' An error occurred, get a text describing the error and show it
        '
        PCANBasic.GetErrorText(result, 0, strMsg)
        Console.WriteLine(strMsg.ToString())
        ' Here can be decided if the loop has to be  terminated (eg. the bus
        ' status is  bus-off)
        '
        HandleReadError(result)
    End If
    ' Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    ' until the queue is empty
    '
Loop While ((result And TPCANStatus.PCAN_ERROR_QRCVEMPTY) <> TPCANStatus.PCAN_ERROR_QRCVEMPTY)
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
TPCANMsg msg;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized and communication takes place ...

do
{
    // Check the receive queue for new messages
    //
    result = PCANBasic::Read(PCANBasic::PCAN_USBBUS1, msg);
    if (result != TPCANStatus::PCAN_ERROR_QRCVEMPTY)
    {
        // Process the received message
        //
        Console::WriteLine("A message was received");
        ProcessMessage(msg);
    }
    else
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic::GetErrorText(result, 0, strMsg);
        Console::WriteLine(strMsg->ToString());
        // Here can be decided if the loop has to be  terminated (eg. the bus
        // status is  bus-off)
        //
        HandleReadError(result);
    }
    // Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    // until the queue is empty
    //
} while ((result & TPCANStatus::PCAN_ERROR_QRCVEMPTY) != TPCANStatus::PCAN_ERROR_QRCVEMPTY);
See Also

Reference

PCANBasic Class
Read Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Using Events
Error Frame
PCAN Status Frame
PCAN Handle Definitions


PCANBasic.Read(UInt16, TPCANMsg, TPCANTimestamp) Method

PCANBasicRead(UInt16, TPCANMsg, TPCANTimestamp) Method

Reads a CAN message and its time stamp from the receive queue of a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus Read(
    ushort Channel,
    out TPCANMsg MessageBuffer,
    out TPCANTimestamp TimestampBuffer
)
Public Shared Function Read (
    Channel As UShort,
    <OutAttribute> ByRef MessageBuffer As TPCANMsg,
    <OutAttribute> ByRef TimestampBuffer As TPCANTimestamp
) As TPCANStatus
public:
static TPCANStatus Read(
    unsigned short Channel,
    [OutAttribute] TPCANMsg% MessageBuffer,
    [OutAttribute] TPCANTimestamp% TimestampBuffer
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
MessageBuffer TPCANMsg
A buffer to store the CAN message.
TimestampBuffer TPCANTimestamp
A buffer to store the reception time of the message.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLOPERATION: Indicates that the PCAN Channel passed to the method was not initialized using the Initialize method.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_BUSLIGHT: Indicates a bus error within the given PCAN Channel. The hardware is in bus-light status.
    Note Note
    MessageBuffer and TimestampBuffer are valid in this case.
  • PCAN_ERROR_BUSHEAVY: Indicates a bus error within the given PCAN Channel. The hardware is in bus-heavy status.
    Note Note
    MessageBuffer and TimestampBuffer are valid in this case.
  • PCAN_ERROR_BUSOFF: Indicates a bus error within the given PCAN Channel. The hardware is in bus-off status.
    Note Note
    MessageBuffer and TimestampBuffer are valid in this case.
  • PCAN_ERROR_QRCVEMPTY: Indicates that the reception queue of the Channel is empty.
  • PCAN_ERROR_ILLDATA: Indicates that the message that has been read is not permitted due to the current settings and has been discarded.
Remarks
Important note Important
The use of Read and ReadFD is mutually exclusive. The PCAN Channel passed to this method must be initialized using the Initialize method. Otherwise the error PCAN_ERROR_ILLOPERATION is returned.
Note Note
If the timestamp of the message is not required, use the Read(UInt16, TPCANMsg) method instead.

The Read method returns CAN frames from the reception queue. It is important to call Read repeatedly until the reception queue becomes empty. In case there are no more messages to retrieve, the error PCAN_ERROR_QRCVEMPTY is returned. The error PCAN_ERROR_QRCVEMPTY is also returned if the reception of messages, configurable through the PCAN_RECEIVE_STATUS parameter, is disabled.

The receive queue can contain up to 32768 messages.

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 starts a timer that checks for messages every 50 or 100 milliseconds, calling the Read method in a loop until the error PCAN_ERROR_QRCVEMPTY 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 placed in its reception queue. See Using Events to obtain more information about reading with events.

About bus errors / Status messages

Important note Important
If a status message is read, the return value of the Read method is also the error code.

If a bus-off error occur, an application cannot use the channel to communicate anymore, until the CAN controller is reset. Consider using the PCAN_BUSOFF_AUTORESET parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset errors like bus-off, bus-heavy and bus-light:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter PCAN_HARD_RESET_STATUS: It instructs this method to explicitly perform a hardware reset regardless of whether other 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 flag PCAN_MESSAGE_ERRFRAME is set in the TPCANMsg.MSGTYPE field, the message is an Error Frame.

If the flag PCAN_MESSAGE_STATUS is set in the TPCANMsg.MSGTYPE field, the message is a PCAN Status Frame.

Example

The following example shows the use of Read(UInt16, TPCANMsg, TPCANTimestamp) method 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 Note
It is assumed that the channel was already initialized and that the following code is called periodically, e.g. using a timer.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
TPCANMsg msg;
TPCANTimestamp time;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized and communication takes place ...

do
{
    // Check the reception queue for new frames
    //
    result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1, out msg, out time);
    if (result != TPCANStatus.PCAN_ERROR_QRCVEMPTY)
    {
        // Process the received message
        //
        Console.WriteLine("A message was received");
        ProcessMessage(msg, time);
    }
    else
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic.GetErrorText(result, 0, strMsg);
        Console.WriteLine(strMsg.ToString());
        // Here can be decided if the loop has to be  terminated (eg. the bus
        // status is  bus-off)
        //
        HandleReadError(result);
    }
    // Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    // until the queue is empty
    //
} while ((result & TPCANStatus.PCAN_ERROR_QRCVEMPTY) != TPCANStatus.PCAN_ERROR_QRCVEMPTY);
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim msg As TPCANMsg = Nothing
Dim time As TPCANTimestamp

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized and communication takes place ...

Do
    ' Check the receive queue for new messages
    '
    result = PCANBasic.Read(PCANBasic.PCAN_USBBUS1, msg, time)
    If result <> TPCANStatus.PCAN_ERROR_QRCVEMPTY Then
        Console.WriteLine("A message was received")
        ProcessMessage(msg, time)
    Else
        ' An error occurred, get a text describing the error and show it
        '
        PCANBasic.GetErrorText(result, 0, strMsg)
        Console.WriteLine(strMsg.ToString())
        ' Here can be decided if the loop has to be  terminated (eg. the bus
        ' status is  bus-off)
        '
        HandleReadError(result)
    End If
    ' Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    ' until the queue is empty
    '
Loop While ((result And TPCANStatus.PCAN_ERROR_QRCVEMPTY) <> TPCANStatus.PCAN_ERROR_QRCVEMPTY)
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
TPCANMsg msg;
TPCANTimestamp time;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized and communication takes place ...

do
{
    // Check the receive queue for new messages
    //
    result = PCANBasic::Read(PCANBasic::PCAN_USBBUS1, msg, time);
    if (result != TPCANStatus::PCAN_ERROR_QRCVEMPTY)
    {
        // Process the received message
        //
        Console::WriteLine("A message was received");
        ProcessMessage(msg, time);
    }
    else
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic::GetErrorText(result, 0, strMsg);
        Console::WriteLine(strMsg->ToString());
        // Here can be decided if the loop has to be  terminated (eg. the bus
        // status is  bus-off)
        //
        HandleReadError(result);
    }
    // Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    // until the queue is empty
    //
} while ((result & TPCANStatus::PCAN_ERROR_QRCVEMPTY) != TPCANStatus::PCAN_ERROR_QRCVEMPTY);
See Also

Reference

PCANBasic Class
Read Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Using Events
Error Frame
PCAN Status Frame
PCAN Handle Definitions


PCANBasic.ReadFD Method

PCANBasicReadFD Method

Overload List
Name | Description
ReadFD(UInt16, TPCANMsgFD) | Reads a CAN message from the receive queue of a FD capable PCAN Channel.
ReadFD(UInt16, TPCANMsgFD, UInt64) | Reads a CAN message and its time stamp from the receive queue of a FD capable PCAN Channel.
Top
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic.ReadFD(UInt16, TPCANMsgFD) Method

PCANBasicReadFD(UInt16, TPCANMsgFD) Method

Reads a CAN message from the receive queue of a FD capable PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus ReadFD(
    ushort Channel,
    out TPCANMsgFD MessageBuffer
)
Public Shared Function ReadFD (
    Channel As UShort,
    <OutAttribute> ByRef MessageBuffer As TPCANMsgFD
) As TPCANStatus
public:
static TPCANStatus ReadFD(
    unsigned short Channel,
    [OutAttribute] TPCANMsgFD% MessageBuffer
)

Parameters

Channel UInt16
The handle of a FD capable PCAN Channel (see PCAN Handle Definitions).
MessageBuffer TPCANMsgFD
A buffer to store the CAN message.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLOPERATION: Indicates that the PCAN Channel passed to the method was not initialized using the InitializeFD method.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_BUSWARNING: Indicates a bus error within the given PCAN Channel. The hardware is in bus-warning status.
    Note Note
    MessageBuffer is valid in this case.
  • PCAN_ERROR_BUSPASSIVE: Indicates a bus error within the given PCAN Channel. The hardware is in bus-passive status.
    Note Note
    MessageBuffer is valid in this case.
  • PCAN_ERROR_BUSOFF: Indicates a bus error within the given PCAN Channel. The hardware is in bus-off status.
    Note Note
    MessageBuffer is valid in this case.
  • PCAN_ERROR_QRCVEMPTY: Indicates that the reception queue of the Channel is empty.
  • PCAN_ERROR_ILLDATA: Indicates that the message that has been read is not permitted due to the current settings and has been discarded.
Remarks
Important note Important
The use of Read and ReadFD is mutually exclusive. The PCAN Channel passed to this method must be initialized using the InitializeFD method. Otherwise the error PCAN_ERROR_ILLOPERATION is returned.
Note Note
If the time when the message was received is required, use the ReadFD(UInt16, TPCANMsgFD, UInt64) method instead.

The ReadFD method returns CAN frames from the reception queue. It is important to call ReadFD repeatedly until the reception queue becomes empty. In case there are no more messages to retrieve, the error PCAN_ERROR_QRCVEMPTY is returned. The error PCAN_ERROR_QRCVEMPTY is also returned if the reception of messages, configurable through the PCAN_RECEIVE_STATUS parameter, is disabled.

The receive queue can contain up to 32768 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 starts a timer that checks for messages every 50 or 100 milliseconds, calling the ReadFD method in a loop until the error PCAN_ERROR_QRCVEMPTY 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 placed in its reception queue. See Using Events to obtain more information about reading with events.

About bus errors / Status messages

Important note Important
If a status message is read, the return value of the ReadFD method is also the error code.

If a bus-off error occur, an application cannot use the channel to communicate anymore, until the CAN controller is reset. Consider using the PCAN_BUSOFF_AUTORESET parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset errors like bus-off, bus-warning and bus-passive:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter PCAN_HARD_RESET_STATUS: It instructs this method to explicitly perform a hardware reset regardless of whether other 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, FD, RTR, Error, or Status message. This value should be checked every time a message has been read successfully.

If the flag PCAN_MESSAGE_ERRFRAME is set in the TPCANMsgFD.MSGTYPE field, the message is an Error Frame.

If the flag PCAN_MESSAGE_STATUS is set in the TPCANMsgFD.MSGTYPE field, the message is a PCAN Status Frame.

Example

The following example shows the use of ReadFD(UInt16, TPCANMsgFD) method 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 Note
It is assumed that the channel was already initialized and that the following code is called periodically, e.g. using a timer.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
TPCANMsgFD msg;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized and communication takes place ...

do
{
    // Check the receive queue for new messages
    //
    result = PCANBasic.ReadFD(PCANBasic.PCAN_USBBUS1, out msg);
    if (result != TPCANStatus.PCAN_ERROR_QRCVEMPTY)
    {
        // Process the received message
        //
        Console.WriteLine("A message was received");
        ProcessMessage(msg);
    }
    else
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic.GetErrorText(result, 0, strMsg);
        Console.WriteLine(strMsg.ToString());
        // Here can be decided if the loop has to be  terminated (eg. the bus
        // status is  bus-off)
        //
        HandleReadError(result);
    }
    // Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    // until the queue is empty
    //
} while ((result & TPCANStatus.PCAN_ERROR_QRCVEMPTY) != TPCANStatus.PCAN_ERROR_QRCVEMPTY);
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim msg As TPCANMsgFD = Nothing

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized and communication takes place ...

Do
    ' Check the receive queue for new messages
    '
    result = PCANBasic.ReadFD(PCANBasic.PCAN_USBBUS1, msg)
    If result <> TPCANStatus.PCAN_ERROR_QRCVEMPTY Then
        ' Process the received message
        '
        Console.WriteLine("A message was received")
        ProcessMessage(msg)
    Else
        ' An error occurred, get a text describing the error and show it
        '
        PCANBasic.GetErrorText(result, 0, strMsg)
        Console.WriteLine(strMsg.ToString())
        ' Here can be decided if the loop has to be  terminated (eg. the bus
        ' status is  bus-off)
        '
        HandleReadError(result)
    End If
    ' Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    ' until the queue is empty
    '
Loop While ((result And TPCANStatus.PCAN_ERROR_QRCVEMPTY) <> TPCANStatus.PCAN_ERROR_QRCVEMPTY)
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
TPCANMsgFD msg;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized and communication takes place ...

do
{
    // Check the receive queue for new messages
    //
    result = PCANBasic::ReadFD(PCANBasic::PCAN_USBBUS1, msg);
    if (result != TPCANStatus::PCAN_ERROR_QRCVEMPTY)
    {
        // Process the received message
        //
        Console::WriteLine("A message was received");
        ProcessMessage(msg);
    }
    else
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic::GetErrorText(result, 0, strMsg);
        Console::WriteLine(strMsg->ToString());
        // Here can be decided if the loop has to be  terminated (e.g. the bus
        // status is  bus-off)
        //
        HandleReadError(result);
    }
    // Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    // until the queue is empty
    //
} while ((result & TPCANStatus::PCAN_ERROR_QRCVEMPTY) != TPCANStatus::PCAN_ERROR_QRCVEMPTY);
See Also

Reference

PCANBasic Class
ReadFD Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Using Events
Error Frame
PCAN Status Frame
PCAN Handle Definitions


PCANBasic.ReadFD(UInt16, TPCANMsgFD, UInt64) Method

PCANBasicReadFD(UInt16, TPCANMsgFD, UInt64) Method

Reads a CAN message and its time stamp from the receive queue of a FD capable PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus ReadFD(
    ushort Channel,
    out TPCANMsgFD MessageBuffer,
    out ulong TimestampBuffer
)
Public Shared Function ReadFD (
    Channel As UShort,
    <OutAttribute> ByRef MessageBuffer As TPCANMsgFD,
    <OutAttribute> ByRef TimestampBuffer As ULong
) As TPCANStatus
public:
static TPCANStatus ReadFD(
    unsigned short Channel,
    [OutAttribute] TPCANMsgFD% MessageBuffer,
    [OutAttribute] unsigned long long% TimestampBuffer
)

Parameters

Channel UInt16
The handle of a FD capable PCAN Channel (see PCAN Handle Definitions).
MessageBuffer TPCANMsgFD
A buffer to store the CAN message.
TimestampBuffer UInt64
A buffer to store the reception time of the message.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLOPERATION: Indicates that the PCAN Channel passed to the method was not initialized using the InitializeFD method.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_BUSWARNING: Indicates a bus error within the given PCAN Channel. The hardware is in bus-warning status.
    Note Note
    MessageBuffer and TimestampBuffer are valid in this case.
  • PCAN_ERROR_BUSPASSIVE: Indicates a bus error within the given PCAN Channel. The hardware is in bus-passive status.
    Note Note
    MessageBuffer and TimestampBuffer are valid in this case.
  • PCAN_ERROR_BUSOFF: Indicates a bus error within the given PCAN Channel. The hardware is in bus-off status.
    Note Note
    MessageBuffer and TimestampBuffer are valid in this case.
  • PCAN_ERROR_QRCVEMPTY: Indicates that the reception queue of the Channel is empty.
  • PCAN_ERROR_ILLDATA: Indicates that the message that has been read is not permitted due to the current settings and has been discarded.
Remarks
Important note Important
The use of Read and ReadFD is mutually exclusive. The PCAN Channel passed to this method must be initialized using the InitializeFD method. Otherwise the error PCAN_ERROR_ILLOPERATION is returned.
Note Note
If the timestamp of the message is not required, use the ReadFD(UInt16, TPCANMsgFD) method instead.

The ReadFD method returns CAN frames from the reception queue. It is important to call ReadFD repeatedly until the reception queue becomes empty. In case there are no more messages to retrieve, the error PCAN_ERROR_QRCVEMPTY is returned. The error PCAN_ERROR_QRCVEMPTY is also returned if the reception of messages, configurable through the PCAN_RECEIVE_STATUS parameter, is disabled.

The receive queue can contain up to 32768 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 starts a timer that checks for messages every 50 or 100 milliseconds, calling the ReadFD method in a loop until the error PCAN_ERROR_QRCVEMPTY 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 placed in its reception queue. See Using Events to obtain more information about reading with events.

About bus errors / Status messages

Important note Important
If a status message is read, the return value of the ReadFD method is also the error code.

If a bus-off error occur, an application cannot use the channel to communicate anymore, until the CAN controller is reset. Consider using the PCAN_BUSOFF_AUTORESET parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset errors like bus-off, bus-warning and bus-passive:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter PCAN_HARD_RESET_STATUS: It instructs this method to explicitly perform a hardware reset regardless of whether other 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, FD, RTR, Error, or Status message. This value should be checked every time a message has been read successfully.

If the flag PCAN_MESSAGE_ERRFRAME is set in the TPCANMsgFD.MSGTYPE field, the message is an Error Frame.

If the flag PCAN_MESSAGE_STATUS is set in the TPCANMsgFD.MSGTYPE field, the message is a PCAN Status Frame.

Example

The following example shows the use of ReadFD(UInt16, TPCANMsgFD, UInt64) method 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 Note
It is assumed that the channel was already initialized and that the following code is called periodically, e.g. using a timer.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
TPCANMsgFD msg;
UInt64 time;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized and communication takes place ...

do
{
    // Check the receive queue for new messages
    //
    result = PCANBasic.ReadFD(PCANBasic.PCAN_USBBUS1, out msg, out time);
    if (result != TPCANStatus.PCAN_ERROR_QRCVEMPTY)
    {
        // Process the received message
        //
        Console.WriteLine("A message was received");
        ProcessMessage(msg, time);
    }
    else
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic.GetErrorText(result, 0, strMsg);
        Console.WriteLine(strMsg.ToString());
        // Here can be decided if the loop has to be  terminated (eg. the bus
        // status is  bus-off)
        //
        HandleReadError(result);
    }
    // Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    // until the queue is empty
    //
} while ((result & TPCANStatus.PCAN_ERROR_QRCVEMPTY) != TPCANStatus.PCAN_ERROR_QRCVEMPTY);
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim msg As TPCANMsgFD = Nothing
Dim time As UInt64

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized and communication takes place ...

Do
    ' Check the receive queue for new messages
    '
    result = PCANBasic.ReadFD(PCANBasic.PCAN_USBBUS1, msg, time)
    If result <> TPCANStatus.PCAN_ERROR_QRCVEMPTY Then
        Console.WriteLine("A message was received")
        ProcessMessage(msg, time)
    Else
        ' An error occurred, get a text describing the error and show it
        '
        PCANBasic.GetErrorText(result, 0, strMsg)
        Console.WriteLine(strMsg.ToString())
        ' Here can be decided if the loop has to be  terminated (eg. the bus
        ' status is  bus-off)
        '
        HandleReadError(result)
    End If
    ' Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    ' until the queue is empty
    '
Loop While ((result And TPCANStatus.PCAN_ERROR_QRCVEMPTY) <> TPCANStatus.PCAN_ERROR_QRCVEMPTY)
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
TPCANMsgFD msg;
UInt64 time;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized and communication takes place ...

do
{
    // Check the receive queue for new messages
    //
    result = PCANBasic::ReadFD(PCANBasic::PCAN_USBBUS1, msg, time);
    if (result != TPCANStatus::PCAN_ERROR_QRCVEMPTY)
    {
        // Process the received message
        //
        Console::WriteLine("A message was received");
        ProcessMessage(msg, time);
    }
    else
    {
        // An error occurred, get a text describing the error and show it
        //
        PCANBasic::GetErrorText(result, 0, strMsg);
        Console::WriteLine(strMsg->ToString());
        // Here can be decided if the loop has to be  terminated (eg. the bus
        // status is  bus-off)
        //
        HandleReadError(result);
    }
    // Try to read a message from the receive queue of the PCAN-USB, Channel 1,
    // until the queue is empty
    //
} while ((result & TPCANStatus::PCAN_ERROR_QRCVEMPTY) != TPCANStatus::PCAN_ERROR_QRCVEMPTY);
See Also

Reference

PCANBasic Class
ReadFD Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Using Events
Error Frame
PCAN Status Frame
PCAN Handle Definitions


PCANBasic.Reset Method

PCANBasicReset Method

Discards all messages contained in the receive and transmit queues of a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus Reset(
    ushort Channel
)
Public Shared Function Reset (
    Channel As UShort
) As TPCANStatus
public:
static TPCANStatus Reset(
    unsigned short Channel
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
Remarks

Calling this method ONLY clears the queues of a Channel. A reset of the CAN controller doesn't take place, unless the parameter PCAN_HARD_RESET_STATUS is active.

Normally a reset of the CAN Controller is desired when a bus-off occur. In this case an application cannot use the channel to communicate anymore, until the CAN controller is reset. Consider using the PCAN_BUSOFF_AUTORESET parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset errors like bus-off, bus-heavy and bus-light:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter PCAN_HARD_RESET_STATUS: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

Example

The following example shows the use of the Reset(UInt16) method 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 Note
It is assumed that the channel was already initialized

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized and communication takes place ...
// ... when needed, the queues are cleared ...

// The PCI Channel is reset
//
result = PCANBasic.Reset(PCANBasic.PCAN_PCIBUS1);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("PCAN-PCI (Ch-1) was reset");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized and communication takes place ...
' ... when needed, the queues are cleared ...

' The PCI Channel is reset
'
result = PCANBasic.Reset(PCANBasic.PCAN_PCIBUS1)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("PCAN-PCI (Ch-1) was reset")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized and communication takes place ...
// ... when needed, the queues are cleared ...

// The PCI Channel is reset
//
result = PCANBasic::Reset(PCANBasic::PCAN_PCIBUS1);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("PCAN-PCI (Ch-1) was reset");
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.SetValue Method

PCANBasicSetValue Method

Overload List
Name | Description
SetValue(UInt16, TPCANParameter, String, UInt32) | Configures a feature of a PCAN Channel.
SetValue(UInt16, TPCANParameter, UInt32, UInt32) | Configures a feature of a PCAN Channel.
SetValue(UInt16, TPCANParameter, UInt64, UInt32) | Configures a feature of a PCAN Channel.
Top
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic.SetValue(UInt16, TPCANParameter, String, UInt32) Method

PCANBasicSetValue(UInt16, TPCANParameter, String, UInt32) Method

Configures a feature of a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus SetValue(
    ushort Channel,
    TPCANParameter Parameter,
    string StringBuffer,
    uint BufferLength
)
Public Shared Function SetValue (
    Channel As UShort,
    Parameter As TPCANParameter,
    StringBuffer As String,
    BufferLength As UInteger
) As TPCANStatus
public:
static TPCANStatus SetValue(
    unsigned short Channel,
    TPCANParameter Parameter,
    String^ StringBuffer,
    unsigned int BufferLength
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Parameter TPCANParameter
The code of the value to be set.
StringBuffer String
The buffer containing the string value to be set.
BufferLength UInt32
The length in bytes of the given buffer.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLHW: Indicates that the given PCAN Channel is not available.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_ILLPARAMTYPE: Indicates that the requested information is not available for the given PCAN Channel. Check the value of Parameter; some values are not available for all PCAN-Channels or cannot be read.
  • PCAN_ERROR_ILLOPERATION: An underlying process that is generated by a call to this method with the current parameters, is temporarily not allowed. The configuration in relation to the used Parameter must be checked.
Remarks

Use the method SetValue to change the behavior of a PCAN Channel or to set environment values like writing custom messages into the API log file. Take in account that not all parameters are supported for all PCAN Channels. The access's type of the parameters can also be different.

For more information about the possible values that can be used for parameter configuration, see Parameter Value Definitions

Important note Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
Example

The following example shows the use of SetValue(UInt16, TPCANParameter, String, UInt32) method on the channel PCAN_NONEBUS to set (and activate) the path for the log file of a 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.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
string strBuffer;

strMsg = new System.Text.StringBuilder(256);

// The path for the Log file is set.
// Note that this parameter is set using the
// default Channel value (PCANBasic.PCAN_NONEBUS)
//
strBuffer = "C:\\Users\\Admin\\Desktop";
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_LOCATION, strBuffer, (UInt32)strBuffer.Length);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("Log path was successfully set");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim strBuffer As String

strMsg = New System.Text.StringBuilder(256)

' 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 = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_LOCATION, strBuffer, CType(strBuffer.Length, UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString())
Else
    Console.WriteLine("Log path was successfully set")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
String^ strBuffer;

strMsg = gcnew System::Text::StringBuilder(256);

// 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 = PCANBasic::SetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_LOG_LOCATION, strBuffer, strBuffer->Length);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("Log path was successfully set");
See Also

Reference

PCANBasic Class
SetValue Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Parameter Value Definitions
PCAN Handle Definitions


PCANBasic.SetValue(UInt16, TPCANParameter, UInt32, UInt32) Method

PCANBasicSetValue(UInt16, TPCANParameter, UInt32, UInt32) Method

Configures a feature of a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus SetValue(
    ushort Channel,
    TPCANParameter Parameter,
    ref uint NumericBuffer,
    uint BufferLength
)
Public Shared Function SetValue (
    Channel As UShort,
    Parameter As TPCANParameter,
    ByRef NumericBuffer As UInteger,
    BufferLength As UInteger
) As TPCANStatus
public:
static TPCANStatus SetValue(
    unsigned short Channel,
    TPCANParameter Parameter,
    unsigned int% NumericBuffer,
    unsigned int BufferLength
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Parameter TPCANParameter
The code of the value to be set.
NumericBuffer UInt32
The buffer containing the 32-bit numeric value to be set (see Parameter Value Definitions).
BufferLength UInt32
The length in bytes of the given buffer.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLHW: Indicates that the given PCAN Channel is not available.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_ILLPARAMTYPE: Indicates that the requested information is not available for the given PCAN Channel. Check the value of Parameter; some values are not available for all PCAN-Channels or cannot be read.
  • PCAN_ERROR_ILLOPERATION: An underlying process that is generated by a call to this method with the current parameters, is temporarily not allowed. The configuration in relation to the used Parameter must be checked.
Remarks

Use the method SetValue to change the behavior of a PCAN Channel like its Message 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.

For more information about the possible values that can be used for parameter configuration, see Parameter Value Definitions

Important note Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
Example

The following example shows the use of SetValue(UInt16, TPCANParameter, UInt32, UInt32) method 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 Note
It is assumed that the channel was already initialized.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
UInt32 iBuffer;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized ...

// The message filter is closed
//
iBuffer = PCANBasic.PCAN_FILTER_CLOSE;
result = PCANBasic.SetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_MESSAGE_FILTER, ref iBuffer, sizeof(UInt32));
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("The filter was successfully closed");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim iBuffer As UInt32

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized ...

' The message filter is closed
'
iBuffer = PCANBasic.PCAN_FILTER_CLOSE
result = PCANBasic.SetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_MESSAGE_FILTER, iBuffer, CType(System.Runtime.InteropServices.Marshal.SizeOf(iBuffer), UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("The filter was successfully closed")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
UInt32 iBuffer;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized ...

// The message filter is closed
//
iBuffer = PCANBasic::PCAN_FILTER_CLOSE;
result = PCANBasic::SetValue(PCANBasic::PCAN_USBBUS1, TPCANParameter::PCAN_MESSAGE_FILTER, iBuffer, sizeof(iBuffer));
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("The filter was successfully closed");
See Also

Reference

PCANBasic Class
SetValue Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Parameter Value Definitions
PCAN Handle Definitions


PCANBasic.SetValue(UInt16, TPCANParameter, UInt64, UInt32) Method

PCANBasicSetValue(UInt16, TPCANParameter, UInt64, UInt32) Method

Configures a feature of a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus SetValue(
    ushort Channel,
    TPCANParameter Parameter,
    ref ulong NumericBuffer,
    uint BufferLength
)
Public Shared Function SetValue (
    Channel As UShort,
    Parameter As TPCANParameter,
    ByRef NumericBuffer As ULong,
    BufferLength As UInteger
) As TPCANStatus
public:
static TPCANStatus SetValue(
    unsigned short Channel,
    TPCANParameter Parameter,
    unsigned long long% NumericBuffer,
    unsigned int BufferLength
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Parameter TPCANParameter
The code of the value to be set.
NumericBuffer UInt64
The buffer containing the 64-bit numeric value to be set (see Parameter Value Definitions).
BufferLength UInt32
The length in bytes of the given buffer.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLHW: Indicates that the given PCAN Channel is not available.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_ILLPARAMTYPE: Indicates that the requested information is not available for the given PCAN Channel. Check the value of Parameter; some values are not available for all PCAN-Channels or cannot be read.
  • PCAN_ERROR_ILLOPERATION: An underlying process that is generated by a call to this method with the current parameters, is temporarily not allowed. The configuration in relation to the used Parameter must be checked.
Remarks

Use the method SetValue to change the behavior of a PCAN Channel like its Acceptance Filter (Mask/Code). Take in account that not all parameters are supported for all PCAN Channels. The access's type of the parameters can also be different.

For more information about the possible values that can be used for parameter configuration, see Parameter Value Definitions

Important note Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
Example

The following example shows the use of SetValue(UInt16, TPCANParameter, UInt64, UInt32) method on the channel PCAN_USBBUS1 to set an acceptance filter as a 11-bit 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 Note
It is assumed that the channel was already initialized.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
UInt64 i64Buffer;

strMsg = new System.Text.StringBuilder(256);

// The acceptance code and mask are packed as 64-bit value
//
i64Buffer = 0x100;  // Acceptance code
i64Buffer <<= 32;
i64Buffer |= 0x003; // Acceptance mask
result = PCANBasic.SetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_ACCEPTANCE_FILTER_11BIT, ref i64Buffer, sizeof(UInt64));
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("The 11-bit acceptance filter was configured successfully");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim i64Buffer As UInt64

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized ...

' 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, TPCANParameter.PCAN_ACCEPTANCE_FILTER_11BIT, i64Buffer, CType(System.Runtime.InteropServices.Marshal.SizeOf(i64Buffer), UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("The 11-bit acceptance filter was configured successfully")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
UInt64 i64Buffer;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized ...

// The acceptance code and mask are packed as 64-bit value
//
i64Buffer = 0x100;  // Acceptance code
i64Buffer <<= 32;
i64Buffer |= 0x003; // Acceptance mask
result = PCANBasic::SetValue(PCANBasic::PCAN_USBBUS1, TPCANParameter::PCAN_ACCEPTANCE_FILTER_11BIT, i64Buffer, sizeof(i64Buffer));
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("The 11-bit acceptance filter was configured successfully");
See Also

Reference

PCANBasic Class
SetValue Overload
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Parameter Value Definitions
PCAN Handle Definitions


PCANBasic.Uninitialize Method

PCANBasicUninitialize Method

Uninitializes one or all initialized PCAN Channels.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus Uninitialize(
    ushort Channel
)
Public Shared Function Uninitialize (
    Channel As UShort
) As TPCANStatus
public:
static TPCANStatus Uninitialize(
    unsigned short Channel
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN Channel cannot be uninitialized because it was not found in the list of reserved channels of the calling application.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
Remarks

A PCAN Channel can be released using one of this possibilities:

  • Single-Release: Giving the handle of a PCAN Channel initialized before with the Initialize method. If the given channel cannot be found an error is returned.
  • Multiple-Release: Giving the handle value PCAN_NONEBUS. It instructs the API to uninitialize all channels being used by the calling application. This option does not generate errors if no channel was uninitialized.

Transmit queue on uninitialize: When a connection is terminated, the underlying hardware's transmit-queue will not be immediately discarded. The API will wait some time before terminating, so that the hardware has time to send (or try to send) the unsent messages. When the timer runs out (about 500 milliseconds), the rest of the messages in the queue (if any) are discarded.

Example

The following example shows the initialization and uninitialization (Single-Release) processes for 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 Note
To see an example of Multiple-Release, see the Initialize method.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;

strMsg = new System.Text.StringBuilder(256);

// The Plug & Play Channel (PCAN-PCI) is initialized
//
result = PCANBasic.Initialize(PCANBasic.PCAN_PCIBUS1, TPCANBaudrate.PCAN_BAUD_500K);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("PCAN-PCI (Ch-1) was initialized");

// .... do communication ...

// The PCI Channel is released
//
result = PCANBasic.Uninitialize(PCANBasic.PCAN_PCIBUS1);

if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("PCAN-PCI (Ch-1) was released");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

strMsg = New System.Text.StringBuilder(256)

' The Plug & Play Channel (PCAN-PCI) is initialized
'
result = PCANBasic.Initialize(PCANBasic.PCAN_PCIBUS1, TPCANBaudrate.PCAN_BAUD_500K)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("PCAN-PCI (Ch-1) was initialized")
End If

' .... do communication ...

' The PCI Channel is released
'
result = PCANBasic.Uninitialize(PCANBasic.PCAN_PCIBUS1)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("PCAN-PCI (Ch-1) was released")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

strMsg = gcnew System::Text::StringBuilder(256);

// The Plug & Play Channel (PCAN-PCI) is initialized
//
result = PCANBasic::Initialize(PCANBasic::PCAN_PCIBUS1, TPCANBaudrate::PCAN_BAUD_500K);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("PCAN-PCI (Ch-1) was initialized");

//.... do communication ...

// The PCI Channel is released
//
result = PCANBasic::Uninitialize(PCANBasic::PCAN_PCIBUS1);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("PCAN-PCI (Ch-1) was released");
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace
Initialize
InitializeFD

Other Resources

PCAN Handle Definitions


PCANBasic.Write Method

PCANBasicWrite Method

Transmits a CAN message.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus Write(
    ushort Channel,
    ref TPCANMsg MessageBuffer
)
Public Shared Function Write (
    Channel As UShort,
    ByRef MessageBuffer As TPCANMsg
) As TPCANStatus
public:
static TPCANStatus Write(
    unsigned short Channel,
    TPCANMsg% MessageBuffer
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
MessageBuffer TPCANMsg
A buffer containing the CAN message to be sent.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLOPERATION: Indicates that the PCAN Channel passed to the method was not initialized using the Initialize method.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_BUSOFF: Indicates a bus error within the given PCAN Channel. The hardware is in bus-off status.
  • PCAN_ERROR_QXMTFULL: Indicates that the transmit queue of the Channel is full.
Remarks
Important note Important
The use of Write and WriteFD is mutually exclusive. The PCAN Channel passed to this method must be initialized using the Initialize method. Otherwise the error PCAN_ERROR_ILLOPERATION is returned.

When the hardware status is bus-off, an application cannot communicate anymore. Consider using the PCAN_BUSOFF_AUTORESET parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset errors like bus-off, bus-heavy and bus-light:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter PCAN_HARD_RESET_STATUS: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

Example

The following example shows the use of Write(UInt16, TPCANMsg) method 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 Note
It is assumed that the channel was already initialized.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
TPCANMsg msg;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized ...

// A CAN message is created. The Data field (8 bytes)
// of the message must also be created
//
msg = new TPCANMsg();
msg.DATA = new Byte[8];

// A CAN message is configured
//
msg.ID = 0x100;
msg.MSGTYPE = TPCANMessageType.PCAN_MESSAGE_STANDARD;
msg.LEN = 3;
msg.DATA[0] = 1;
msg.DATA[1] = 2;
msg.DATA[2] = 3;

// The message is sent using the PCAN-USB Channel 1
//
result = PCANBasic.Write(PCANBasic.PCAN_USBBUS1, ref msg);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("Message sent successfully");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim msg As TPCANMsg

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized ...

' A CAN message is created. The Data field (8 bytes)
' of the message must also be created
'
msg = New TPCANMsg
msg.DATA = CType(Array.CreateInstance(GetType(Byte), 8), Byte())

' A CAN message is configured
'
msg.ID = &H100
msg.MSGTYPE = TPCANMessageType.PCAN_MESSAGE_STANDARD
msg.LEN = 3
msg.DATA(0) = 1
msg.DATA(1) = 2
msg.DATA(2) = 3

' The message is sent using the PCAN-USB Channel 1
'
result = PCANBasic.Write(PCANBasic.PCAN_USBBUS1, msg)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("Message sent successfully")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
TPCANMsg^ msg;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized ...

// A CAN message is created. The Data field (8 bytes)
// of the message must also be created
//
msg = gcnew TPCANMsg();
msg->DATA = gcnew array<Byte>(8);

// A CAN message is configured
//
msg->ID = 0x100;
msg->MSGTYPE = TPCANMessageType::PCAN_MESSAGE_STANDARD;
msg->LEN = 3;
msg->DATA[0] = 1;
msg->DATA[1] = 2;
msg->DATA[2] = 3;

// The message is sent using the PCAN-USB Channel 1
//
result = PCANBasic::Write(PCANBasic::PCAN_USBBUS1, *msg);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("Message sent successfully");
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.WriteFD Method

PCANBasicWriteFD Method

Transmits a CAN message using a FD capable PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static TPCANStatus WriteFD(
    ushort Channel,
    ref TPCANMsgFD MessageBuffer
)
Public Shared Function WriteFD (
    Channel As UShort,
    ByRef MessageBuffer As TPCANMsgFD
) As TPCANStatus
public:
static TPCANStatus WriteFD(
    unsigned short Channel,
    TPCANMsgFD% MessageBuffer
)

Parameters

Channel UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
MessageBuffer TPCANMsgFD
A buffer containing the CAN message to be sent.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLOPERATION: Indicates that the PCAN Channel passed to the method was not initialized using the InitializeFD method.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_BUSOFF: Indicates a bus error within the given PCAN Channel. The hardware is in bus-off status.
  • PCAN_ERROR_QXMTFULL: Indicates that the transmit queue of the Channel is full.
Remarks
Important note Important
The use of Write and WriteFD is mutually exclusive. The PCAN Channel passed to this method must be initialized using the InitializeFD method. Otherwise the error PCAN_ERROR_ILLOPERATION is returned.

When the hardware status is bus-off, an application cannot communicate anymore. Consider using the PCAN_BUSOFF_AUTORESET parameter, which instructs the API to automatically reset the CAN controller when a bus-off state is detected.

Another way to reset errors like bus-off, bus-warning and bus-passive:

  • Performing an uninitialize / initialize cycle: This causes a hardware reset, but only when no more clients are connected to that channel.
  • Using the parameter PCAN_HARD_RESET_STATUS: It instructs this method to explicitly perform a hardware reset regardless of whether other clients are connected to that channel.

Example

The following example shows the use of WriteFD(UInt16, TPCANMsgFD) method 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 Note
It is assumed that the channel was already initialized.

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;
TPCANMsgFD msg;

strMsg = new System.Text.StringBuilder(256);

// ... channel is initialized ...

// A CAN message is created. The Data field (64 bytes)
// of the message must also be created
//
msg = new TPCANMsgFD();
msg.DATA = new Byte[64];

// A CAN message is configured
//
msg.ID = 0x100;
msg.MSGTYPE = TPCANMessageType.PCAN_MESSAGE_STANDARD | TPCANMessageType.PCAN_MESSAGE_FD;

// DLC 9 means 12 data bytes
//
msg.DLC = 9;
for (byte i = 0; i < 12; i++)
    msg.DATA[i] = i;

// The message is sent using the PCAN-USB Channel 1
//
result = PCANBasic.WriteFD(PCANBasic.PCAN_USBBUS1, ref msg);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
    Console.WriteLine("Message sent successfully");
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim msg As TPCANMsgFD

strMsg = New System.Text.StringBuilder(256)

' ... channel is initialized ...

' A CAN message is created. The Data field (64 bytes)
' of the message must also be created
'
msg = New TPCANMsgFD
msg.DATA = CType(Array.CreateInstance(GetType(Byte), 64), Byte())

' A CAN message is configured
'
msg.ID = &H100
msg.MSGTYPE = TPCANMessageType.PCAN_MESSAGE_STANDARD Or TPCANMessageType.PCAN_MESSAGE_FD

' DLC 9 means 12 data bytes
'
msg.DLC = 9
For i As Byte = 0 To 11
    msg.DATA(i) = i
Next

' The message is sent using the PCAN-USB Channel 1
'
result = PCANBasic.WriteFD(PCANBasic.PCAN_USBBUS1, msg)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error and show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString)
Else
    Console.WriteLine("Message sent successfully")
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
TPCANMsgFD^ msg;

strMsg = gcnew System::Text::StringBuilder(256);

// ... channel is initialized ...

// A CAN message is created. The Data field (64 bytes)
// of the message must also be created
//
msg = gcnew TPCANMsgFD();
msg->DATA = gcnew array<Byte>(64);

// A CAN message is configured
//
msg->ID = 0x100;
msg->MSGTYPE = TPCANMessageType::PCAN_MESSAGE_STANDARD | TPCANMessageType::PCAN_MESSAGE_FD;

// DLC 9 means 12 data bytes
//
msg->DLC = 9;
for (Byte i = 0; i < 12; i++)
    msg->DATA[i] = i;

// The message is sent using the PCAN-USB Channel 1
//
result = PCANBasic::WriteFD(PCANBasic::PCAN_USBBUS1, *msg);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
else
    Console::WriteLine("Message sent successfully");
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic Fields

The PCANBasic type exposes the following members.

Fields
Name | Description
FEATURE_DELAY_CAPABLE | Device supports a delay between sending frames (FPGA based USB devices).
FEATURE_FD_CAPABLE | Device supports flexible data-rate (CAN-FD).
FEATURE_IO_CAPABLE | Device supports I/O functionality for electronic circuits (USB-Chip devices).
LAN_DIRECTION_READ | The PCAN Channel is limited to incoming communication only.
LAN_DIRECTION_READ_WRITE | The PCAN Channel communication is bidirectional.
LAN_DIRECTION_WRITE | The PCAN Channel is limited to outgoing communication only.
LOG_FUNCTION_ALL | Logs all possible information within the PCAN-Basic API functions.
LOG_FUNCTION_DEFAULT | Logs system exceptions / errors.
LOG_FUNCTION_ENTRY | Logs the entries to the PCAN-Basic API functions.
LOG_FUNCTION_LEAVE | Logs the exits from the PCAN-Basic API functions.
LOG_FUNCTION_PARAMETERS | Logs the parameters passed to the PCAN-Basic API functions.
LOG_FUNCTION_READ | Logs the CAN messages received within the CAN_Read function.
LOG_FUNCTION_WRITE | Logs the CAN messages passed to the CAN_Write function.
LOOKUP_CONTROLLER_NUMBER | Searches a PCAN Channel by its 0-based CAN controller index.
LOOKUP_DEVICE_ID | Searches a PCAN Channel by its device identifier.
LOOKUP_DEVICE_TYPE | Searches a PCAN Channel by its device type (see TPCANDevice).
LOOKUP_IP_ADDRESS | Searches a PCAN Channel by its IP address (PCAN_LAN Channels only. See PCAN-LAN Handles).
MAX_LENGTH_HARDWARE_NAME | Represents the maximum length that the name of a device can have (32 characters + terminator).
MAX_LENGTH_VERSION_STRING | Represents the maximum length that a version string can have (255 characters + terminator).
PCAN_BR_CLOCK | Clock frequency in hertz (80000000, 60000000, 40000000, 30000000, 24000000, 20000000)
PCAN_BR_CLOCK_MHZ | Clock frequency in megahertz (80, 60, 40, 30, 24, 20)
PCAN_BR_DATA_BRP | Clock prescaler for high-speed data time quantum
PCAN_BR_DATA_SAMPLE | Secondary sample point delay for high-speed data bit rate in cycles
PCAN_BR_DATA_SJW | Synchronization Jump Width for high-speed data bit rate in time quanta
PCAN_BR_DATA_TSEG1 | TSEG1 segment for fast data bit rate in time quanta
PCAN_BR_DATA_TSEG2 | TSEG2 segment for fast data bit rate in time quanta
PCAN_BR_NOM_BRP | Clock prescaler for nominal time quantum
PCAN_BR_NOM_SAMPLE | Sample point for nominal bit rate
PCAN_BR_NOM_SJW | Synchronization Jump Width for nominal bit rate in time quanta
PCAN_BR_NOM_TSEG1 | TSEG1 segment for nominal bit rate in time quanta
PCAN_BR_NOM_TSEG2 | TSEG2 segment for nominal bit rate in time quanta
PCAN_CHANNEL_AVAILABLE | The PCAN Channel handle is available to be connected (PnP Hardware: it means furthermore that the hardware is plugged-in).
PCAN_CHANNEL_OCCUPIED | The PCAN Channel handle is valid, and is already being used.
PCAN_CHANNEL_PCANVIEW | The PCAN Channel handle is already being used by a PCAN-View application, but is available to connect.
PCAN_CHANNEL_UNAVAILABLE | The PCAN Channel handle is illegal, or its associated hardware is not available.
PCAN_DNGBUS1 | PPCAN-Dongle/LPT interface, channel 1
PCAN_FILTER_CLOSE | The PCAN filter is closed. No messages will be received.
PCAN_FILTER_CUSTOM | The PCAN filter is custom configured. Only registered. messages will be received
PCAN_FILTER_OPEN | The PCAN filter is fully opened. All messages will be received.
PCAN_ISABUS1 | PCAN-ISA interface, channel 1
PCAN_ISABUS2 | PCAN-ISA interface, channel 2
PCAN_ISABUS3 | PCAN-ISA interface, channel 3
PCAN_ISABUS4 | PCAN-ISA interface, channel 4
PCAN_ISABUS5 | PCAN-ISA interface, channel 5
PCAN_ISABUS6 | PCAN-ISA interface, channel 6
PCAN_ISABUS7 | PCAN-ISA interface, channel 7
PCAN_ISABUS8 | PCAN-ISA interface, channel 8
PCAN_LANBUS1 | PCAN-LAN interface, channel 1
PCAN_LANBUS10 | PCAN-LAN interface, channel 10
PCAN_LANBUS11 | PCAN-LAN interface, channel 11
PCAN_LANBUS12 | PCAN-LAN interface, channel 12
PCAN_LANBUS13 | PCAN-LAN interface, channel 13
PCAN_LANBUS14 | PCAN-LAN interface, channel 14
PCAN_LANBUS15 | PCAN-LAN interface, channel 15
PCAN_LANBUS16 | PCAN-LAN interface, channel 16
PCAN_LANBUS2 | PCAN-LAN interface, channel 2
PCAN_LANBUS3 | PCAN-LAN interface, channel 3
PCAN_LANBUS4 | PCAN-LAN interface, channel 4
PCAN_LANBUS5 | PCAN-LAN interface, channel 5
PCAN_LANBUS6 | PCAN-LAN interface, channel 6
PCAN_LANBUS7 | PCAN-LAN interface, channel 7
PCAN_LANBUS8 | PCAN-LAN interface, channel 8
PCAN_LANBUS9 | PCAN-LAN interface, channel 9
PCAN_NONEBUS | Undefined/default value for a PCAN bus
PCAN_PARAMETER_OFF | The PCAN parameter is not set (inactive).
PCAN_PARAMETER_ON | The PCAN parameter is set (active).
PCAN_PCCBUS1 | PCAN-PC Card interface, channel 1
PCAN_PCCBUS2 | PCAN-PC Card interface, channel 2
PCAN_PCIBUS1 | PCAN-PCI interface, channel 1
PCAN_PCIBUS10 | PCAN-PCI interface, channel 10
PCAN_PCIBUS11 | PCAN-PCI interface, channel 11
PCAN_PCIBUS12 | PCAN-PCI interface, channel 12
PCAN_PCIBUS13 | PCAN-PCI interface, channel 13
PCAN_PCIBUS14 | PCAN-PCI interface, channel 14
PCAN_PCIBUS15 | PCAN-PCI interface, channel 15
PCAN_PCIBUS16 | PCAN-PCI interface, channel 16
PCAN_PCIBUS2 | PCAN-PCI interface, channel 2
PCAN_PCIBUS3 | PCAN-PCI interface, channel 3
PCAN_PCIBUS4 | PCAN-PCI interface, channel 4
PCAN_PCIBUS5 | PCAN-PCI interface, channel 5
PCAN_PCIBUS6 | PCAN-PCI interface, channel 6
PCAN_PCIBUS7 | PCAN-PCI interface, channel 7
PCAN_PCIBUS8 | PCAN-PCI interface, channel 8
PCAN_PCIBUS9 | PCAN-PCI interface, channel 9
PCAN_USBBUS1 | PCAN-USB interface, channel 1
PCAN_USBBUS10 | PCAN-USB interface, channel 10
PCAN_USBBUS11 | PCAN-USB interface, channel 11
PCAN_USBBUS12 | PCAN-USB interface, channel 12
PCAN_USBBUS13 | PCAN-USB interface, channel 13
PCAN_USBBUS14 | PCAN-USB interface, channel 14
PCAN_USBBUS15 | PCAN-USB interface, channel 15
PCAN_USBBUS16 | PCAN-USB interface, channel 16
PCAN_USBBUS2 | PCAN-USB interface, channel 2
PCAN_USBBUS3 | PCAN-USB interface, channel 3
PCAN_USBBUS4 | PCAN-USB interface, channel 4
PCAN_USBBUS5 | PCAN-USB interface, channel 5
PCAN_USBBUS6 | PCAN-USB interface, channel 6
PCAN_USBBUS7 | PCAN-USB interface, channel 7
PCAN_USBBUS8 | PCAN-USB interface, channel 8
PCAN_USBBUS9 | PCAN-USB interface, channel 9
SERVICE_STATUS_RUNNING | The service is running.
SERVICE_STATUS_STOPPED | The service is not running.
TRACE_FILE_DATA_LENGTH | Causes using the data length column ('l') instead of the DLC column ('L') in the trace file.
TRACE_FILE_DATE | Includes the date into the name of the trace file.
TRACE_FILE_OVERWRITE | Causes the overwriting of available traces (same name).
TRACE_FILE_SEGMENTED | Traced data is distributed in several files with size PAN_TRACE_SIZE.
TRACE_FILE_SINGLE | A single file is written until it size reaches PAN_TRACE_SIZE.
TRACE_FILE_TIME | Includes the start time into the name of the trace file.
Top
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace


PCANBasic.FEATURE_DELAY_CAPABLE Field

PCANBasicFEATURE_DELAY_CAPABLE Field

Device supports a delay between sending frames (FPGA based USB devices).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int FEATURE_DELAY_CAPABLE = 2
Public Const FEATURE_DELAY_CAPABLE As Integer = 2
public:
literal int FEATURE_DELAY_CAPABLE = 2

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Feature Values


PCANBasic.FEATURE_FD_CAPABLE Field

PCANBasicFEATURE_FD_CAPABLE Field

Device supports flexible data-rate (CAN-FD).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int FEATURE_FD_CAPABLE = 1
Public Const FEATURE_FD_CAPABLE As Integer = 1
public:
literal int FEATURE_FD_CAPABLE = 1

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Feature Values


PCANBasic.FEATURE_IO_CAPABLE Field

PCANBasicFEATURE_IO_CAPABLE Field

Device supports I/O functionality for electronic circuits (USB-Chip devices).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int FEATURE_IO_CAPABLE = 4
Public Const FEATURE_IO_CAPABLE As Integer = 4
public:
literal int FEATURE_IO_CAPABLE = 4

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Feature Values


PCANBasic.LAN_DIRECTION_READ Field

PCANBasicLAN_DIRECTION_READ Field

The PCAN Channel is limited to incoming communication only.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LAN_DIRECTION_READ = 1
Public Const LAN_DIRECTION_READ As Integer = 1
public:
literal int LAN_DIRECTION_READ = 1

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Channel Direction Values


PCANBasic.LAN_DIRECTION_READ_WRITE Field

PCANBasicLAN_DIRECTION_READ_WRITE Field

The PCAN Channel communication is bidirectional.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LAN_DIRECTION_READ_WRITE = 3
Public Const LAN_DIRECTION_READ_WRITE As Integer = 3
public:
literal int LAN_DIRECTION_READ_WRITE = 3

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Channel Direction Values


PCANBasic.LAN_DIRECTION_WRITE Field

PCANBasicLAN_DIRECTION_WRITE Field

The PCAN Channel is limited to outgoing communication only.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LAN_DIRECTION_WRITE = 2
Public Const LAN_DIRECTION_WRITE As Integer = 2
public:
literal int LAN_DIRECTION_WRITE = 2

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Channel Direction Values


PCANBasic.LOG_FUNCTION_ALL Field

PCANBasicLOG_FUNCTION_ALL Field

Logs all possible information within the PCAN-Basic API functions.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LOG_FUNCTION_ALL = 65535
Public Const LOG_FUNCTION_ALL As Integer = 65535
public:
literal int LOG_FUNCTION_ALL = 65535

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Log Configuration Values


PCANBasic.LOG_FUNCTION_DEFAULT Field

PCANBasicLOG_FUNCTION_DEFAULT Field

Logs system exceptions / errors.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LOG_FUNCTION_DEFAULT = 0
Public Const LOG_FUNCTION_DEFAULT As Integer = 0
public:
literal int LOG_FUNCTION_DEFAULT = 0

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Log Configuration Values


PCANBasic.LOG_FUNCTION_ENTRY Field

PCANBasicLOG_FUNCTION_ENTRY Field

Logs the entries to the PCAN-Basic API functions.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LOG_FUNCTION_ENTRY = 1
Public Const LOG_FUNCTION_ENTRY As Integer = 1
public:
literal int LOG_FUNCTION_ENTRY = 1

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Log Configuration Values


PCANBasic.LOG_FUNCTION_LEAVE Field

PCANBasicLOG_FUNCTION_LEAVE Field

Logs the exits from the PCAN-Basic API functions.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LOG_FUNCTION_LEAVE = 4
Public Const LOG_FUNCTION_LEAVE As Integer = 4
public:
literal int LOG_FUNCTION_LEAVE = 4

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Log Configuration Values


PCANBasic.LOG_FUNCTION_PARAMETERS Field

PCANBasicLOG_FUNCTION_PARAMETERS Field

Logs the parameters passed to the PCAN-Basic API functions.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LOG_FUNCTION_PARAMETERS = 2
Public Const LOG_FUNCTION_PARAMETERS As Integer = 2
public:
literal int LOG_FUNCTION_PARAMETERS = 2

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Log Configuration Values


PCANBasic.LOG_FUNCTION_READ Field

PCANBasicLOG_FUNCTION_READ Field

Logs the CAN messages received within the CAN_Read function.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LOG_FUNCTION_READ = 16
Public Const LOG_FUNCTION_READ As Integer = 16
public:
literal int LOG_FUNCTION_READ = 16

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Log Configuration Values


PCANBasic.LOG_FUNCTION_WRITE Field

PCANBasicLOG_FUNCTION_WRITE Field

Logs the CAN messages passed to the CAN_Write function.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int LOG_FUNCTION_WRITE = 8
Public Const LOG_FUNCTION_WRITE As Integer = 8
public:
literal int LOG_FUNCTION_WRITE = 8

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Log Configuration Values


PCANBasic.LOOKUP_CONTROLLER_NUMBER Field

PCANBasicLOOKUP_CONTROLLER_NUMBER Field

Searches a PCAN Channel by its 0-based CAN controller index.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string LOOKUP_CONTROLLER_NUMBER = "controllernumber"
Public Const LOOKUP_CONTROLLER_NUMBER As String = "controllernumber"
public:
literal String^ LOOKUP_CONTROLLER_NUMBER = "controllernumber"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Look Up Parameter Definitions


PCANBasic.LOOKUP_DEVICE_ID Field

PCANBasicLOOKUP_DEVICE_ID Field

Searches a PCAN Channel by its device identifier.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string LOOKUP_DEVICE_ID = "deviceid"
Public Const LOOKUP_DEVICE_ID As String = "deviceid"
public:
literal String^ LOOKUP_DEVICE_ID = "deviceid"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Look Up Parameter Definitions


PCANBasic.LOOKUP_DEVICE_TYPE Field

PCANBasicLOOKUP_DEVICE_TYPE Field

Searches a PCAN Channel by its device type (see TPCANDevice).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string LOOKUP_DEVICE_TYPE = "devicetype"
Public Const LOOKUP_DEVICE_TYPE As String = "devicetype"
public:
literal String^ LOOKUP_DEVICE_TYPE = "devicetype"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Look Up Parameter Definitions


PCANBasic.LOOKUP_IP_ADDRESS Field

PCANBasicLOOKUP_IP_ADDRESS Field

Searches a PCAN Channel by its IP address (PCAN_LAN Channels only. See PCAN-LAN Handles).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string LOOKUP_IP_ADDRESS = "ipaddress"
Public Const LOOKUP_IP_ADDRESS As String = "ipaddress"
public:
literal String^ LOOKUP_IP_ADDRESS = "ipaddress"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN-LAN Handles
Look Up Parameter Definitions


PCANBasic.MAX_LENGTH_HARDWARE_NAME Field

PCANBasicMAX_LENGTH_HARDWARE_NAME Field

Represents the maximum length that the name of a device can have (32 characters + terminator).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MAX_LENGTH_HARDWARE_NAME = 33
Public Const MAX_LENGTH_HARDWARE_NAME As Integer = 33
public:
literal int MAX_LENGTH_HARDWARE_NAME = 33

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Service Status Values


PCANBasic.MAX_LENGTH_VERSION_STRING Field

PCANBasicMAX_LENGTH_VERSION_STRING Field

Represents the maximum length that a version string can have (255 characters + terminator).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int MAX_LENGTH_VERSION_STRING = 256
Public Const MAX_LENGTH_VERSION_STRING As Integer = 256
public:
literal int MAX_LENGTH_VERSION_STRING = 256

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Service Status Values


PCANBasic.PCAN_BR_CLOCK Field

PCANBasicPCAN_BR_CLOCK Field

Clock frequency in hertz (80000000, 60000000, 40000000, 30000000, 24000000, 20000000)

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_CLOCK = "f_clock"
Public Const PCAN_BR_CLOCK As String = "f_clock"
public:
literal String^ PCAN_BR_CLOCK = "f_clock"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_CLOCK_MHZ Field

PCANBasicPCAN_BR_CLOCK_MHZ Field

Clock frequency in megahertz (80, 60, 40, 30, 24, 20)

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_CLOCK_MHZ = "f_clock_mhz"
Public Const PCAN_BR_CLOCK_MHZ As String = "f_clock_mhz"
public:
literal String^ PCAN_BR_CLOCK_MHZ = "f_clock_mhz"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_DATA_BRP Field

PCANBasicPCAN_BR_DATA_BRP Field

Clock prescaler for high-speed data time quantum

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_DATA_BRP = "data_brp"
Public Const PCAN_BR_DATA_BRP As String = "data_brp"
public:
literal String^ PCAN_BR_DATA_BRP = "data_brp"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_DATA_SAMPLE Field

PCANBasicPCAN_BR_DATA_SAMPLE Field

Secondary sample point delay for high-speed data bit rate in cycles

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_DATA_SAMPLE = "data_ssp_offset"
Public Const PCAN_BR_DATA_SAMPLE As String = "data_ssp_offset"
public:
literal String^ PCAN_BR_DATA_SAMPLE = "data_ssp_offset"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_DATA_SJW Field

PCANBasicPCAN_BR_DATA_SJW Field

Synchronization Jump Width for high-speed data bit rate in time quanta

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_DATA_SJW = "data_sjw"
Public Const PCAN_BR_DATA_SJW As String = "data_sjw"
public:
literal String^ PCAN_BR_DATA_SJW = "data_sjw"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_DATA_TSEG1 Field

PCANBasicPCAN_BR_DATA_TSEG1 Field

TSEG1 segment for fast data bit rate in time quanta

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_DATA_TSEG1 = "data_tseg1"
Public Const PCAN_BR_DATA_TSEG1 As String = "data_tseg1"
public:
literal String^ PCAN_BR_DATA_TSEG1 = "data_tseg1"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_DATA_TSEG2 Field

PCANBasicPCAN_BR_DATA_TSEG2 Field

TSEG2 segment for fast data bit rate in time quanta

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_DATA_TSEG2 = "data_tseg2"
Public Const PCAN_BR_DATA_TSEG2 As String = "data_tseg2"
public:
literal String^ PCAN_BR_DATA_TSEG2 = "data_tseg2"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_NOM_BRP Field

PCANBasicPCAN_BR_NOM_BRP Field

Clock prescaler for nominal time quantum

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_NOM_BRP = "nom_brp"
Public Const PCAN_BR_NOM_BRP As String = "nom_brp"
public:
literal String^ PCAN_BR_NOM_BRP = "nom_brp"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_NOM_SAMPLE Field

PCANBasicPCAN_BR_NOM_SAMPLE Field

Sample point for nominal bit rate

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_NOM_SAMPLE = "nom_sam"
Public Const PCAN_BR_NOM_SAMPLE As String = "nom_sam"
public:
literal String^ PCAN_BR_NOM_SAMPLE = "nom_sam"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_NOM_SJW Field

PCANBasicPCAN_BR_NOM_SJW Field

Synchronization Jump Width for nominal bit rate in time quanta

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_NOM_SJW = "nom_sjw"
Public Const PCAN_BR_NOM_SJW As String = "nom_sjw"
public:
literal String^ PCAN_BR_NOM_SJW = "nom_sjw"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_NOM_TSEG1 Field

PCANBasicPCAN_BR_NOM_TSEG1 Field

TSEG1 segment for nominal bit rate in time quanta

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_NOM_TSEG1 = "nom_tseg1"
Public Const PCAN_BR_NOM_TSEG1 As String = "nom_tseg1"
public:
literal String^ PCAN_BR_NOM_TSEG1 = "nom_tseg1"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_BR_NOM_TSEG2 Field

PCANBasicPCAN_BR_NOM_TSEG2 Field

TSEG2 segment for nominal bit rate in time quanta

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const string PCAN_BR_NOM_TSEG2 = "nom_tseg2"
Public Const PCAN_BR_NOM_TSEG2 As String = "nom_tseg2"
public:
literal String^ PCAN_BR_NOM_TSEG2 = "nom_tseg2"

Field Value

String
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

FD Bit rate Parameter Definitions


PCANBasic.PCAN_CHANNEL_AVAILABLE Field

PCANBasicPCAN_CHANNEL_AVAILABLE Field

The PCAN Channel handle is available to be connected (PnP Hardware: it means furthermore that the hardware is plugged-in).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_CHANNEL_AVAILABLE = 1
Public Const PCAN_CHANNEL_AVAILABLE As Integer = 1
public:
literal int PCAN_CHANNEL_AVAILABLE = 1

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Channel Availability Values


PCANBasic.PCAN_CHANNEL_OCCUPIED Field

PCANBasicPCAN_CHANNEL_OCCUPIED Field

The PCAN Channel handle is valid, and is already being used.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_CHANNEL_OCCUPIED = 2
Public Const PCAN_CHANNEL_OCCUPIED As Integer = 2
public:
literal int PCAN_CHANNEL_OCCUPIED = 2

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Channel Availability Values


PCANBasic.PCAN_CHANNEL_PCANVIEW Field

PCANBasicPCAN_CHANNEL_PCANVIEW Field

The PCAN Channel handle is already being used by a PCAN-View application, but is available to connect.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_CHANNEL_PCANVIEW = 3
Public Const PCAN_CHANNEL_PCANVIEW As Integer = 3
public:
literal int PCAN_CHANNEL_PCANVIEW = 3

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Channel Availability Values


PCANBasic.PCAN_CHANNEL_UNAVAILABLE Field

PCANBasicPCAN_CHANNEL_UNAVAILABLE Field

The PCAN Channel handle is illegal, or its associated hardware is not available.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_CHANNEL_UNAVAILABLE = 0
Public Const PCAN_CHANNEL_UNAVAILABLE As Integer = 0
public:
literal int PCAN_CHANNEL_UNAVAILABLE = 0

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Channel Availability Values


PCANBasic.PCAN_DNGBUS1 Field

PCANBasicPCAN_DNGBUS1 Field

PPCAN-Dongle/LPT interface, channel 1

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_DNGBUS1 = 49
Public Const PCAN_DNGBUS1 As UShort = 49
public:
literal unsigned short PCAN_DNGBUS1 = 49

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_FILTER_CLOSE Field

PCANBasicPCAN_FILTER_CLOSE Field

The PCAN filter is closed. No messages will be received.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_FILTER_CLOSE = 0
Public Const PCAN_FILTER_CLOSE As Integer = 0
public:
literal int PCAN_FILTER_CLOSE = 0

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Filter Values


PCANBasic.PCAN_FILTER_CUSTOM Field

PCANBasicPCAN_FILTER_CUSTOM Field

The PCAN filter is custom configured. Only registered. messages will be received

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_FILTER_CUSTOM = 2
Public Const PCAN_FILTER_CUSTOM As Integer = 2
public:
literal int PCAN_FILTER_CUSTOM = 2

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Filter Values


PCANBasic.PCAN_FILTER_OPEN Field

PCANBasicPCAN_FILTER_OPEN Field

The PCAN filter is fully opened. All messages will be received.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_FILTER_OPEN = 1
Public Const PCAN_FILTER_OPEN As Integer = 1
public:
literal int PCAN_FILTER_OPEN = 1

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Filter Values


PCANBasic.PCAN_ISABUS1 Field

PCANBasicPCAN_ISABUS1 Field

PCAN-ISA interface, channel 1

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_ISABUS1 = 33
Public Const PCAN_ISABUS1 As UShort = 33
public:
literal unsigned short PCAN_ISABUS1 = 33

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_ISABUS2 Field

PCANBasicPCAN_ISABUS2 Field

PCAN-ISA interface, channel 2

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_ISABUS2 = 34
Public Const PCAN_ISABUS2 As UShort = 34
public:
literal unsigned short PCAN_ISABUS2 = 34

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_ISABUS3 Field

PCANBasicPCAN_ISABUS3 Field

PCAN-ISA interface, channel 3

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_ISABUS3 = 35
Public Const PCAN_ISABUS3 As UShort = 35
public:
literal unsigned short PCAN_ISABUS3 = 35

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_ISABUS4 Field

PCANBasicPCAN_ISABUS4 Field

PCAN-ISA interface, channel 4

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_ISABUS4 = 36
Public Const PCAN_ISABUS4 As UShort = 36
public:
literal unsigned short PCAN_ISABUS4 = 36

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_ISABUS5 Field

PCANBasicPCAN_ISABUS5 Field

PCAN-ISA interface, channel 5

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_ISABUS5 = 37
Public Const PCAN_ISABUS5 As UShort = 37
public:
literal unsigned short PCAN_ISABUS5 = 37

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_ISABUS6 Field

PCANBasicPCAN_ISABUS6 Field

PCAN-ISA interface, channel 6

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_ISABUS6 = 38
Public Const PCAN_ISABUS6 As UShort = 38
public:
literal unsigned short PCAN_ISABUS6 = 38

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_ISABUS7 Field

PCANBasicPCAN_ISABUS7 Field

PCAN-ISA interface, channel 7

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_ISABUS7 = 39
Public Const PCAN_ISABUS7 As UShort = 39
public:
literal unsigned short PCAN_ISABUS7 = 39

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_ISABUS8 Field

PCANBasicPCAN_ISABUS8 Field

PCAN-ISA interface, channel 8

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_ISABUS8 = 40
Public Const PCAN_ISABUS8 As UShort = 40
public:
literal unsigned short PCAN_ISABUS8 = 40

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS1 Field

PCANBasicPCAN_LANBUS1 Field

PCAN-LAN interface, channel 1

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS1 = 2049
Public Const PCAN_LANBUS1 As UShort = 2049
public:
literal unsigned short PCAN_LANBUS1 = 2049

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS10 Field

PCANBasicPCAN_LANBUS10 Field

PCAN-LAN interface, channel 10

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS10 = 2058
Public Const PCAN_LANBUS10 As UShort = 2058
public:
literal unsigned short PCAN_LANBUS10 = 2058

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS11 Field

PCANBasicPCAN_LANBUS11 Field

PCAN-LAN interface, channel 11

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS11 = 2059
Public Const PCAN_LANBUS11 As UShort = 2059
public:
literal unsigned short PCAN_LANBUS11 = 2059

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS12 Field

PCANBasicPCAN_LANBUS12 Field

PCAN-LAN interface, channel 12

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS12 = 2060
Public Const PCAN_LANBUS12 As UShort = 2060
public:
literal unsigned short PCAN_LANBUS12 = 2060

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS13 Field

PCANBasicPCAN_LANBUS13 Field

PCAN-LAN interface, channel 13

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS13 = 2061
Public Const PCAN_LANBUS13 As UShort = 2061
public:
literal unsigned short PCAN_LANBUS13 = 2061

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS14 Field

PCANBasicPCAN_LANBUS14 Field

PCAN-LAN interface, channel 14

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS14 = 2062
Public Const PCAN_LANBUS14 As UShort = 2062
public:
literal unsigned short PCAN_LANBUS14 = 2062

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS15 Field

PCANBasicPCAN_LANBUS15 Field

PCAN-LAN interface, channel 15

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS15 = 2063
Public Const PCAN_LANBUS15 As UShort = 2063
public:
literal unsigned short PCAN_LANBUS15 = 2063

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS16 Field

PCANBasicPCAN_LANBUS16 Field

PCAN-LAN interface, channel 16

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS16 = 2064
Public Const PCAN_LANBUS16 As UShort = 2064
public:
literal unsigned short PCAN_LANBUS16 = 2064

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS2 Field

PCANBasicPCAN_LANBUS2 Field

PCAN-LAN interface, channel 2

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS2 = 2050
Public Const PCAN_LANBUS2 As UShort = 2050
public:
literal unsigned short PCAN_LANBUS2 = 2050

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS3 Field

PCANBasicPCAN_LANBUS3 Field

PCAN-LAN interface, channel 3

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS3 = 2051
Public Const PCAN_LANBUS3 As UShort = 2051
public:
literal unsigned short PCAN_LANBUS3 = 2051

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS4 Field

PCANBasicPCAN_LANBUS4 Field

PCAN-LAN interface, channel 4

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS4 = 2052
Public Const PCAN_LANBUS4 As UShort = 2052
public:
literal unsigned short PCAN_LANBUS4 = 2052

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS5 Field

PCANBasicPCAN_LANBUS5 Field

PCAN-LAN interface, channel 5

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS5 = 2053
Public Const PCAN_LANBUS5 As UShort = 2053
public:
literal unsigned short PCAN_LANBUS5 = 2053

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS6 Field

PCANBasicPCAN_LANBUS6 Field

PCAN-LAN interface, channel 6

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS6 = 2054
Public Const PCAN_LANBUS6 As UShort = 2054
public:
literal unsigned short PCAN_LANBUS6 = 2054

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS7 Field

PCANBasicPCAN_LANBUS7 Field

PCAN-LAN interface, channel 7

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS7 = 2055
Public Const PCAN_LANBUS7 As UShort = 2055
public:
literal unsigned short PCAN_LANBUS7 = 2055

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS8 Field

PCANBasicPCAN_LANBUS8 Field

PCAN-LAN interface, channel 8

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS8 = 2056
Public Const PCAN_LANBUS8 As UShort = 2056
public:
literal unsigned short PCAN_LANBUS8 = 2056

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_LANBUS9 Field

PCANBasicPCAN_LANBUS9 Field

PCAN-LAN interface, channel 9

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_LANBUS9 = 2057
Public Const PCAN_LANBUS9 As UShort = 2057
public:
literal unsigned short PCAN_LANBUS9 = 2057

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_NONEBUS Field

PCANBasicPCAN_NONEBUS Field

Undefined/default value for a PCAN bus

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_NONEBUS = 0
Public Const PCAN_NONEBUS As UShort = 0
public:
literal unsigned short PCAN_NONEBUS = 0

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PARAMETER_OFF Field

PCANBasicPCAN_PARAMETER_OFF Field

The PCAN parameter is not set (inactive).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_PARAMETER_OFF = 0
Public Const PCAN_PARAMETER_OFF As Integer = 0
public:
literal int PCAN_PARAMETER_OFF = 0

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Activation Values


PCANBasic.PCAN_PARAMETER_ON Field

PCANBasicPCAN_PARAMETER_ON Field

The PCAN parameter is set (active).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int PCAN_PARAMETER_ON = 1
Public Const PCAN_PARAMETER_ON As Integer = 1
public:
literal int PCAN_PARAMETER_ON = 1

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Activation Values


PCANBasic.PCAN_PCCBUS1 Field

PCANBasicPCAN_PCCBUS1 Field

PCAN-PC Card interface, channel 1

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCCBUS1 = 97
Public Const PCAN_PCCBUS1 As UShort = 97
public:
literal unsigned short PCAN_PCCBUS1 = 97

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCCBUS2 Field

PCANBasicPCAN_PCCBUS2 Field

PCAN-PC Card interface, channel 2

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCCBUS2 = 98
Public Const PCAN_PCCBUS2 As UShort = 98
public:
literal unsigned short PCAN_PCCBUS2 = 98

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS1 Field

PCANBasicPCAN_PCIBUS1 Field

PCAN-PCI interface, channel 1

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS1 = 65
Public Const PCAN_PCIBUS1 As UShort = 65
public:
literal unsigned short PCAN_PCIBUS1 = 65

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS10 Field

PCANBasicPCAN_PCIBUS10 Field

PCAN-PCI interface, channel 10

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS10 = 1034
Public Const PCAN_PCIBUS10 As UShort = 1034
public:
literal unsigned short PCAN_PCIBUS10 = 1034

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS11 Field

PCANBasicPCAN_PCIBUS11 Field

PCAN-PCI interface, channel 11

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS11 = 1035
Public Const PCAN_PCIBUS11 As UShort = 1035
public:
literal unsigned short PCAN_PCIBUS11 = 1035

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS12 Field

PCANBasicPCAN_PCIBUS12 Field

PCAN-PCI interface, channel 12

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS12 = 1036
Public Const PCAN_PCIBUS12 As UShort = 1036
public:
literal unsigned short PCAN_PCIBUS12 = 1036

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS13 Field

PCANBasicPCAN_PCIBUS13 Field

PCAN-PCI interface, channel 13

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS13 = 1037
Public Const PCAN_PCIBUS13 As UShort = 1037
public:
literal unsigned short PCAN_PCIBUS13 = 1037

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS14 Field

PCANBasicPCAN_PCIBUS14 Field

PCAN-PCI interface, channel 14

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS14 = 1038
Public Const PCAN_PCIBUS14 As UShort = 1038
public:
literal unsigned short PCAN_PCIBUS14 = 1038

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS15 Field

PCANBasicPCAN_PCIBUS15 Field

PCAN-PCI interface, channel 15

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS15 = 1039
Public Const PCAN_PCIBUS15 As UShort = 1039
public:
literal unsigned short PCAN_PCIBUS15 = 1039

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS16 Field

PCANBasicPCAN_PCIBUS16 Field

PCAN-PCI interface, channel 16

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS16 = 1040
Public Const PCAN_PCIBUS16 As UShort = 1040
public:
literal unsigned short PCAN_PCIBUS16 = 1040

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS2 Field

PCANBasicPCAN_PCIBUS2 Field

PCAN-PCI interface, channel 2

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS2 = 66
Public Const PCAN_PCIBUS2 As UShort = 66
public:
literal unsigned short PCAN_PCIBUS2 = 66

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS3 Field

PCANBasicPCAN_PCIBUS3 Field

PCAN-PCI interface, channel 3

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS3 = 67
Public Const PCAN_PCIBUS3 As UShort = 67
public:
literal unsigned short PCAN_PCIBUS3 = 67

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS4 Field

PCANBasicPCAN_PCIBUS4 Field

PCAN-PCI interface, channel 4

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS4 = 68
Public Const PCAN_PCIBUS4 As UShort = 68
public:
literal unsigned short PCAN_PCIBUS4 = 68

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS5 Field

PCANBasicPCAN_PCIBUS5 Field

PCAN-PCI interface, channel 5

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS5 = 69
Public Const PCAN_PCIBUS5 As UShort = 69
public:
literal unsigned short PCAN_PCIBUS5 = 69

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS6 Field

PCANBasicPCAN_PCIBUS6 Field

PCAN-PCI interface, channel 6

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS6 = 70
Public Const PCAN_PCIBUS6 As UShort = 70
public:
literal unsigned short PCAN_PCIBUS6 = 70

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS7 Field

PCANBasicPCAN_PCIBUS7 Field

PCAN-PCI interface, channel 7

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS7 = 71
Public Const PCAN_PCIBUS7 As UShort = 71
public:
literal unsigned short PCAN_PCIBUS7 = 71

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS8 Field

PCANBasicPCAN_PCIBUS8 Field

PCAN-PCI interface, channel 8

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS8 = 72
Public Const PCAN_PCIBUS8 As UShort = 72
public:
literal unsigned short PCAN_PCIBUS8 = 72

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_PCIBUS9 Field

PCANBasicPCAN_PCIBUS9 Field

PCAN-PCI interface, channel 9

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_PCIBUS9 = 1033
Public Const PCAN_PCIBUS9 As UShort = 1033
public:
literal unsigned short PCAN_PCIBUS9 = 1033

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS1 Field

PCANBasicPCAN_USBBUS1 Field

PCAN-USB interface, channel 1

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS1 = 81
Public Const PCAN_USBBUS1 As UShort = 81
public:
literal unsigned short PCAN_USBBUS1 = 81

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS10 Field

PCANBasicPCAN_USBBUS10 Field

PCAN-USB interface, channel 10

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS10 = 1290
Public Const PCAN_USBBUS10 As UShort = 1290
public:
literal unsigned short PCAN_USBBUS10 = 1290

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS11 Field

PCANBasicPCAN_USBBUS11 Field

PCAN-USB interface, channel 11

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS11 = 1291
Public Const PCAN_USBBUS11 As UShort = 1291
public:
literal unsigned short PCAN_USBBUS11 = 1291

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS12 Field

PCANBasicPCAN_USBBUS12 Field

PCAN-USB interface, channel 12

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS12 = 1292
Public Const PCAN_USBBUS12 As UShort = 1292
public:
literal unsigned short PCAN_USBBUS12 = 1292

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS13 Field

PCANBasicPCAN_USBBUS13 Field

PCAN-USB interface, channel 13

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS13 = 1293
Public Const PCAN_USBBUS13 As UShort = 1293
public:
literal unsigned short PCAN_USBBUS13 = 1293

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS14 Field

PCANBasicPCAN_USBBUS14 Field

PCAN-USB interface, channel 14

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS14 = 1294
Public Const PCAN_USBBUS14 As UShort = 1294
public:
literal unsigned short PCAN_USBBUS14 = 1294

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS15 Field

PCANBasicPCAN_USBBUS15 Field

PCAN-USB interface, channel 15

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS15 = 1295
Public Const PCAN_USBBUS15 As UShort = 1295
public:
literal unsigned short PCAN_USBBUS15 = 1295

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS16 Field

PCANBasicPCAN_USBBUS16 Field

PCAN-USB interface, channel 16

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS16 = 1296
Public Const PCAN_USBBUS16 As UShort = 1296
public:
literal unsigned short PCAN_USBBUS16 = 1296

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS2 Field

PCANBasicPCAN_USBBUS2 Field

PCAN-USB interface, channel 2

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS2 = 82
Public Const PCAN_USBBUS2 As UShort = 82
public:
literal unsigned short PCAN_USBBUS2 = 82

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS3 Field

PCANBasicPCAN_USBBUS3 Field

PCAN-USB interface, channel 3

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS3 = 83
Public Const PCAN_USBBUS3 As UShort = 83
public:
literal unsigned short PCAN_USBBUS3 = 83

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS4 Field

PCANBasicPCAN_USBBUS4 Field

PCAN-USB interface, channel 4

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS4 = 84
Public Const PCAN_USBBUS4 As UShort = 84
public:
literal unsigned short PCAN_USBBUS4 = 84

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS5 Field

PCANBasicPCAN_USBBUS5 Field

PCAN-USB interface, channel 5

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS5 = 85
Public Const PCAN_USBBUS5 As UShort = 85
public:
literal unsigned short PCAN_USBBUS5 = 85

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS6 Field

PCANBasicPCAN_USBBUS6 Field

PCAN-USB interface, channel 6

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS6 = 86
Public Const PCAN_USBBUS6 As UShort = 86
public:
literal unsigned short PCAN_USBBUS6 = 86

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS7 Field

PCANBasicPCAN_USBBUS7 Field

PCAN-USB interface, channel 7

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS7 = 87
Public Const PCAN_USBBUS7 As UShort = 87
public:
literal unsigned short PCAN_USBBUS7 = 87

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS8 Field

PCANBasicPCAN_USBBUS8 Field

PCAN-USB interface, channel 8

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS8 = 88
Public Const PCAN_USBBUS8 As UShort = 88
public:
literal unsigned short PCAN_USBBUS8 = 88

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.PCAN_USBBUS9 Field

PCANBasicPCAN_USBBUS9 Field

PCAN-USB interface, channel 9

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const ushort PCAN_USBBUS9 = 1289
Public Const PCAN_USBBUS9 As UShort = 1289
public:
literal unsigned short PCAN_USBBUS9 = 1289

Field Value

UInt16
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

PCAN Handle Definitions


PCANBasic.SERVICE_STATUS_RUNNING Field

PCANBasicSERVICE_STATUS_RUNNING Field

The service is running.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int SERVICE_STATUS_RUNNING = 4
Public Const SERVICE_STATUS_RUNNING As Integer = 4
public:
literal int SERVICE_STATUS_RUNNING = 4

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Service Status Values


PCANBasic.SERVICE_STATUS_STOPPED Field

PCANBasicSERVICE_STATUS_STOPPED Field

The service is not running.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int SERVICE_STATUS_STOPPED = 1
Public Const SERVICE_STATUS_STOPPED As Integer = 1
public:
literal int SERVICE_STATUS_STOPPED = 1

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Service Status Values


PCANBasic.TRACE_FILE_DATA_LENGTH Field

PCANBasicTRACE_FILE_DATA_LENGTH Field

Causes using the data length column ('l') instead of the DLC column ('L') in the trace file.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int TRACE_FILE_DATA_LENGTH = 256
Public Const TRACE_FILE_DATA_LENGTH As Integer = 256
public:
literal int TRACE_FILE_DATA_LENGTH = 256

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Trace Configuration Values


PCANBasic.TRACE_FILE_DATE Field

PCANBasicTRACE_FILE_DATE Field

Includes the date into the name of the trace file.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int TRACE_FILE_DATE = 2
Public Const TRACE_FILE_DATE As Integer = 2
public:
literal int TRACE_FILE_DATE = 2

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Trace Configuration Values


PCANBasic.TRACE_FILE_OVERWRITE Field

PCANBasicTRACE_FILE_OVERWRITE Field

Causes the overwriting of available traces (same name).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int TRACE_FILE_OVERWRITE = 128
Public Const TRACE_FILE_OVERWRITE As Integer = 128
public:
literal int TRACE_FILE_OVERWRITE = 128

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Trace Configuration Values


PCANBasic.TRACE_FILE_SEGMENTED Field

PCANBasicTRACE_FILE_SEGMENTED Field

Traced data is distributed in several files with size PAN_TRACE_SIZE.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int TRACE_FILE_SEGMENTED = 1
Public Const TRACE_FILE_SEGMENTED As Integer = 1
public:
literal int TRACE_FILE_SEGMENTED = 1

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Trace Configuration Values


PCANBasic.TRACE_FILE_SINGLE Field

PCANBasicTRACE_FILE_SINGLE Field

A single file is written until it size reaches PAN_TRACE_SIZE.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int TRACE_FILE_SINGLE = 0
Public Const TRACE_FILE_SINGLE As Integer = 0
public:
literal int TRACE_FILE_SINGLE = 0

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Trace Configuration Values


PCANBasic.TRACE_FILE_TIME Field

PCANBasicTRACE_FILE_TIME Field

Includes the start time into the name of the trace file.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public const int TRACE_FILE_TIME = 4
Public Const TRACE_FILE_TIME As Integer = 4
public:
literal int TRACE_FILE_TIME = 4

Field Value

Int32
See Also

Reference

PCANBasic Class
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Group of Trace Configuration Values


TPCANBaudrate Enumeration

Represents a PCAN bit rate register value.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum TPCANBaudrate
Public Enumeration TPCANBaudrate
public enum class TPCANBaudrate
Members
Member name | Value | Description
PCAN_BAUD_1M | 20 | 1 MBit/s.
PCAN_BAUD_800K | 22 | 800 KBit/s.
PCAN_BAUD_500K | 28 | 500 kBit/s.
PCAN_BAUD_250K | 284 | 250 kBit/s.
PCAN_BAUD_125K | 796 | 125 kBit/s.
PCAN_BAUD_47K | 5,140 | 47,619 KBit/s.
PCAN_BAUD_100K | 17,199 | 100 kBit/s.
PCAN_BAUD_50K | 18,223 | 50 kBit/s.
PCAN_BAUD_20K | 21,295 | 20 kBit/s.
PCAN_BAUD_10K | 26,415 | 10 kBit/s.
PCAN_BAUD_5K | 32,639 | 5 kBit/s.
PCAN_BAUD_83K | 34,091 | 83,333 KBit/s.
PCAN_BAUD_33K | 35,631 | 33,333 KBit/s.
PCAN_BAUD_95K | 49,998 | 95,238 KBit/s.
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace
Initialize


TPCANChannelInformation Structure

Describes an existing PCAN Channel.
Inheritance Hierarchy
SystemObject
SystemValueType
Peak.Can.Basic.BackwardCompatibilityTPCANChannelInformation

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public struct TPCANChannelInformation
Public Structure TPCANChannelInformation
public value class TPCANChannelInformation

The TPCANChannelInformation type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType)
Top
Fields
 | Name | Description
Public field | channel_condition | The availability status of a PCAN Channel.
Public field | channel_handle | The handle of the PCAN Channel.
Public field | controller_number | The index (0-based) of the CAN controller represented by a PCAN Channel.
Public field | device_features | The special features of which a PCAN channel is capable (see FEATURE_*).
Public field | device_id | The identifier number associated to a PCAN Chanel.
Public field | device_name | The name of the PCAN Device represented by a PCAN Channel.
Public field | device_type | The kind of PCAN device represented by a PCAN Channel.
Top
Remarks
The members of this structure are sequentially byte aligned.
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace


TPCANChannelInformation Methods

The TPCANChannelInformation type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType)
Top
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANChannelInformation Fields

The TPCANChannelInformation type exposes the following members.

Fields
 | Name | Description
Public field | channel_condition | The availability status of a PCAN Channel.
Public field | channel_handle | The handle of the PCAN Channel.
Public field | controller_number | The index (0-based) of the CAN controller represented by a PCAN Channel.
Public field | device_features | The special features of which a PCAN channel is capable (see FEATURE_*).
Public field | device_id | The identifier number associated to a PCAN Chanel.
Public field | device_name | The name of the PCAN Device represented by a PCAN Channel.
Public field | device_type | The kind of PCAN device represented by a PCAN Channel.
Top
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANChannelInformation.channel_condition Field

TPCANChannelInformationchannel_condition Field

The availability status of a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint channel_condition
Public channel_condition As UInteger
public:
unsigned int channel_condition

Field Value

UInt32
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace

Other Resources

Parameter Value Definitions


TPCANChannelInformation.channel_handle Field

TPCANChannelInformationchannel_handle Field

The handle of the PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public ushort channel_handle
Public channel_handle As UShort
public:
unsigned short channel_handle

Field Value

UInt16
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANChannelInformation.controller_number Field

TPCANChannelInformationcontroller_number Field

The index (0-based) of the CAN controller represented by a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public byte controller_number
Public controller_number As Byte
public:
unsigned char controller_number

Field Value

Byte
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANChannelInformation.device_features Field

TPCANChannelInformationdevice_features Field

The special features of which a PCAN channel is capable (see FEATURE_*).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint device_features
Public device_features As UInteger
public:
unsigned int device_features

Field Value

UInt32
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANChannelInformation.device_id Field

TPCANChannelInformationdevice_id Field

The identifier number associated to a PCAN Chanel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint device_id
Public device_id As UInteger
public:
unsigned int device_id

Field Value

UInt32
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANChannelInformation.device_name Field

TPCANChannelInformationdevice_name Field

The name of the PCAN Device represented by a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public string device_name
Public device_name As String
public:
String^ device_name

Field Value

String
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANChannelInformation.device_type Field

TPCANChannelInformationdevice_type Field

The kind of PCAN device represented by a PCAN Channel.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public TPCANDevice device_type
Public device_type As TPCANDevice
public:
TPCANDevice device_type

Field Value

TPCANDevice
See Also

Reference

TPCANChannelInformation Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANDevice Enumeration

Represents the type of interface and driver a device uses.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum TPCANDevice
Public Enumeration TPCANDevice
public enum class TPCANDevice
Members
Member name | Value | Description
PCAN_NONE | 0 | Undefined, unknown or not selected PCAN device value.
PCAN_PEAKCAN 1 PCAN non plug-and-play devices.
Important note Important
This PCAN device is not supported.
PCAN_ISA | 2 | PCAN-ISA, PCAN-PC/104 devices.
PCAN_DNG | 3 | PCAN-Dongle.
PCAN_PCI | 4 | PCAN-PCI, PCAN-cPCI, PCAN-miniPCI, PCAN-PC/104-Plus, PCAN-PCI Express, PCAN-PCIe FD, PCAN-PCI FD, PCAN-Chip PCIe.
PCAN_USB | 5 | PCAN-USB, PCAN-USB Pro, PCAN-USB FD, PCAN-USB Pro FD, PCAN-Chip USB.
PCAN_PCC | 6 | PCAN-PC Card.
PCAN_VIRTUAL 7 PCAN Virtual hardware.
Important note Important
This PCAN device is not supported.
PCAN_LAN | 8 | PCAN-Gateway, and PCAN-Gateway FD PCAN devices.
Remarks
The PCAN_PEAKCAN and PCAN_VIRTUAL are not supported by the PCAN-Basic API.
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMessageType Enumeration

Represents the type of a CAN message.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
[FlagsAttribute]
public enum TPCANMessageType
<FlagsAttribute>
Public Enumeration TPCANMessageType
[FlagsAttribute]
public enum class TPCANMessageType
Members
Member name | Value | Description
PCAN_MESSAGE_STANDARD | 0 | The PCAN message is a CAN Standard Frame (11-bit identifier).
PCAN_MESSAGE_RTR | 1 | The PCAN message is a CAN Remote-Transfer-Request Frame.
PCAN_MESSAGE_EXTENDED | 2 | The PCAN message is a CAN Extended Frame (29-bit identifier).
PCAN_MESSAGE_FD | 4 | The PCAN message represents a FD frame in terms of CiA specifications.
PCAN_MESSAGE_BRS | 8 | The PCAN message represents a FD bit rate switch (CAN data at a higher bit rate).
PCAN_MESSAGE_ESI | 16 | The PCAN message represents a FD error state indicator(CAN FD transmitter was error active).
PCAN_MESSAGE_ECHO | 32 | The PCAN message represents an echo CAN Frame ( self-received message).
PCAN_MESSAGE_ERRFRAME | 64 | The PCAN message represents an error frame. See Error Frames for more information.
PCAN_MESSAGE_STATUS | 128 | The PCAN message represents a PCAN status frame. See Status Frames for more information.
Remarks

Several message types can be combined (bit mask value).

Important note Important
Messages with type PCAN_MESSAGE_FD, PCAN_MESSAGE_BRS, PCAN_MESSAGE_ESI, or a combination of them, can only be sent/received using the WriteFD and ReadFD methods.
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace
InitializeFD
ReadFD
WriteFD

Other Resources

Error Frames


TPCANMode Enumeration

Represents a PCAN filter mode.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum TPCANMode
Public Enumeration TPCANMode
public enum class TPCANMode
Members
Member name | Value | Description
PCAN_MODE_STANDARD | 0 | Mode is Standard (11-bit identifier).
PCAN_MODE_EXTENDED | 2 | Mode is Extended (29-bit identifier).
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace
FilterMessages


TPCANMsg Structure

Represents a PCAN message.
Inheritance Hierarchy
SystemObject
SystemValueType
Peak.Can.Basic.BackwardCompatibilityTPCANMsg

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public struct TPCANMsg
Public Structure TPCANMsg
public value class TPCANMsg

The TPCANMsg type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType)
Top
Fields
Name | Description
Public field DATA The data associated to the CAN message (DATA[0]..DATA[7]).
Important note Important
This array must be explicitly created, for instance:
C#
VB
C++
Copy
TPCANMsg msg = new TPCANMsg() { DATA = new byte[8] };
Dim msg As New TPCANMsg() With {.DATA = New Byte(7) {}}
TPCANMsg^ msg = gcnew TPCANMsg();
msg->DATA = gcnew array<Byte>(8);
before a variable of this type can be used in any API function.
Public field | ID | A 11/29-bit CAN message identifier.
Public field | LEN | The Data Length Code of the message (0..8).
Public field | MSGTYPE | The kind of CAN frame represented by this value.
Top
Remarks
The members of this structure are sequentially byte aligned.
Important note Important

The TPCANMsg structure is intended for reading and writing standard CAN messages on PCAN Channels initialized for standard CAN 2.0 A/B communication, this is, using the Initialize method for initialization and the methods Read and Write for data transmission.

For CAN communication using flexible data rate, the TPCANMsgFD structure is to be used.

See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace
Initialize
Read
Write


TPCANMsg Methods

The TPCANMsg type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType)
Top
See Also

Reference

TPCANMsg Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsg Fields

The TPCANMsg type exposes the following members.

Fields
Name | Description
Public field DATA The data associated to the CAN message (DATA[0]..DATA[7]).
Important note Important
This array must be explicitly created, for instance:
C#
VB
C++
Copy
TPCANMsg msg = new TPCANMsg() { DATA = new byte[8] };
Dim msg As New TPCANMsg() With {.DATA = New Byte(7) {}}
TPCANMsg^ msg = gcnew TPCANMsg();
msg->DATA = gcnew array<Byte>(8);
before a variable of this type can be used in any API function.
Public field | ID | A 11/29-bit CAN message identifier.
Public field | LEN | The Data Length Code of the message (0..8).
Public field | MSGTYPE | The kind of CAN frame represented by this value.
Top
See Also

Reference

TPCANMsg Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsg.DATA Field

TPCANMsgDATA Field

The data associated to the CAN message (DATA[0]..DATA[7]).
Important note Important
This array must be explicitly created, for instance:
C#
VB
C++
Copy
TPCANMsg msg = new TPCANMsg() { DATA = new byte[8] };
Dim msg As New TPCANMsg() With {.DATA = New Byte(7) {}}
TPCANMsg^ msg = gcnew TPCANMsg();
msg->DATA = gcnew array<Byte>(8);
before a variable of this type can be used in any API function.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public byte[] DATA
Public DATA As Byte()
public:
array<unsigned char>^ DATA

Field Value

Byte
See Also

Reference

TPCANMsg Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsg.ID Field

TPCANMsgID Field

A 11/29-bit CAN message identifier.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint ID
Public ID As UInteger
public:
unsigned int ID

Field Value

UInt32
See Also

Reference

TPCANMsg Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsg.LEN Field

TPCANMsgLEN Field

The Data Length Code of the message (0..8).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public byte LEN
Public LEN As Byte
public:
unsigned char LEN

Field Value

Byte
See Also

Reference

TPCANMsg Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsg.MSGTYPE Field

TPCANMsgMSGTYPE Field

The kind of CAN frame represented by this value.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public TPCANMessageType MSGTYPE
Public MSGTYPE As TPCANMessageType
public:
TPCANMessageType MSGTYPE

Field Value

TPCANMessageType
See Also

Reference

TPCANMsg Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsgFD Structure

Defines a CAN message with flexible data rate.
Inheritance Hierarchy
SystemObject
SystemValueType
Peak.Can.Basic.BackwardCompatibilityTPCANMsgFD

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public struct TPCANMsgFD
Public Structure TPCANMsgFD
public value class TPCANMsgFD

The TPCANMsgFD type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType)
Top
Fields
Name | Description
Public field DATA The data associated to the CAN message (DATA[0]..DATA[63]).
Important note Important
This array must be explicitly created, for instance:
C#
VB
C++
Copy
TPCANMsgFD msgFd = new TPCANMsgFD() { DATA = new byte[64] };
Dim msgFd As New TPCANMsgFD() With {.DATA = New Byte(63) {}}
TPCANMsgFD^ msgFd = gcnew TPCANMsgFD();
msgFd->DATA = gcnew array<Byte>(64);
before a variable of this type can be used in any API function.
Public field | DLC | The Data Length Code of the message (0..15).
Public field | ID | A 11/29-bit CAN message identifier.
Public field | MSGTYPE | The kind of CAN frame represented by this value.
Top
Remarks

The members of this structure are sequentially byte aligned.

Longer Data field with CAN FD messages:

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
Important note Important

The TPCANMsgFD structure is intended for reading and writing standard CAN messages as well as CAN messages with flexible data rate on PCAN Channels initialized for standard CAN-FD communication, this is, using the InitializeFD method for initialization and the methods ReadFD and WriteFD for data transmission.

For CAN communication using only the standard CAN 2.0 A/B, the TPCANMsg structure is to be used.

See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace
InitializeFD
ReadFD
WriteFD


TPCANMsgFD Methods

The TPCANMsgFD type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType)
Top
See Also

Reference

TPCANMsgFD Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsgFD Fields

The TPCANMsgFD type exposes the following members.

Fields
Name | Description
Public field DATA The data associated to the CAN message (DATA[0]..DATA[63]).
Important note Important
This array must be explicitly created, for instance:
C#
VB
C++
Copy
TPCANMsgFD msgFd = new TPCANMsgFD() { DATA = new byte[64] };
Dim msgFd As New TPCANMsgFD() With {.DATA = New Byte(63) {}}
TPCANMsgFD^ msgFd = gcnew TPCANMsgFD();
msgFd->DATA = gcnew array<Byte>(64);
before a variable of this type can be used in any API function.
Public field | DLC | The Data Length Code of the message (0..15).
Public field | ID | A 11/29-bit CAN message identifier.
Public field | MSGTYPE | The kind of CAN frame represented by this value.
Top
See Also

Reference

TPCANMsgFD Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsgFD.DATA Field

TPCANMsgFDDATA Field

The data associated to the CAN message (DATA[0]..DATA[63]).
Important note Important
This array must be explicitly created, for instance:
C#
VB
C++
Copy
TPCANMsgFD msgFd = new TPCANMsgFD() { DATA = new byte[64] };
Dim msgFd As New TPCANMsgFD() With {.DATA = New Byte(63) {}}
TPCANMsgFD^ msgFd = gcnew TPCANMsgFD();
msgFd->DATA = gcnew array<Byte>(64);
before a variable of this type can be used in any API function.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public byte[] DATA
Public DATA As Byte()
public:
array<unsigned char>^ DATA

Field Value

Byte
See Also

Reference

TPCANMsgFD Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsgFD.DLC Field

TPCANMsgFDDLC Field

The Data Length Code of the message (0..15).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public byte DLC
Public DLC As Byte
public:
unsigned char DLC

Field Value

Byte
See Also

Reference

TPCANMsgFD Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsgFD.ID Field

TPCANMsgFDID Field

A 11/29-bit CAN message identifier.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint ID
Public ID As UInteger
public:
unsigned int ID

Field Value

UInt32
See Also

Reference

TPCANMsgFD Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANMsgFD.MSGTYPE Field

TPCANMsgFDMSGTYPE Field

The kind of CAN frame represented by this value.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public TPCANMessageType MSGTYPE
Public MSGTYPE As TPCANMessageType
public:
TPCANMessageType MSGTYPE

Field Value

TPCANMessageType
See Also

Reference

TPCANMsgFD Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANParameter Enumeration

Represents a PCAN parameter or a PCAN Value that can be read or set.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum TPCANParameter
Public Enumeration TPCANParameter
public enum class TPCANParameter
Members
Member name | Value | Description
PCAN_DEVICE_ID | 1 | Device identifier parameter.
PCAN_DEVICE_NUMBER | 1 | Obsolete. DEPRECATED parameter. Use PCAN_DEVICE_ID instead.
PCAN_5VOLTS_POWER | 2 | PCAN "5-volt power" parameter.
PCAN_RECEIVE_EVENT | 3 | PCAN receive event handler parameter.
PCAN_MESSAGE_FILTER | 4 | PCAN message filter parameter.
PCAN_API_VERSION | 5 | PCAN-Basic API version parameter.
PCAN_CHANNEL_VERSION | 6 | PCAN device channel version parameter.
PCAN_BUSOFF_AUTORESET | 7 | PCAN "reset on bus-off" parameter.
PCAN_LISTEN_ONLY | 8 | PCAN "listen-only" parameter.
PCAN_LOG_LOCATION | 9 | Directory path for log files.
PCAN_LOG_STATUS | 10 | Debug-Log activation status.
PCAN_LOG_CONFIGURE | 11 | Configuration of the debugged information (LOG_FUNCTION_***).
PCAN_LOG_TEXT | 12 | Custom insertion of text into the log file.
PCAN_CHANNEL_CONDITION | 13 | Availability status of a PCAN Channel.
PCAN_HARDWARE_NAME | 14 | PCAN "hardware name" parameter.
PCAN_RECEIVE_STATUS | 15 | "Receive Status" parameter for incoming messages.
PCAN_CONTROLLER_NUMBER | 16 | Zero-based index of a CAN-Controller in a PCAN device.
PCAN_TRACE_LOCATION | 17 | Directory path for PCAN trace files.
PCAN_TRACE_STATUS | 18 | PCAN tracing activation status.
PCAN_TRACE_SIZE | 19 | Configuration of the maximum file size of a PCAN trace.
PCAN_TRACE_CONFIGURE | 20 | Configuration of the trace file storing modes (TRACE_FILE_***).
PCAN_CHANNEL_IDENTIFYING | 21 | Physical identification of an USB based PCAN Channel.
PCAN_CHANNEL_FEATURES | 22 | Capabilities of a PCAN device (FEATURE_***).
PCAN_BITRATE_ADAPTING | 23 | Attachment to an existing connection with unknown/different bit rate.
PCAN_BITRATE_INFO | 24 | Current bit rate as BTR0BTR1 value (standard CAN 2.0 A/B).
PCAN_BITRATE_INFO_FD | 25 | Current bit rate as FD String value (CAN-FD).
PCAN_BUSSPEED_NOMINAL | 26 | Current CAN nominal speed in bits/second.
PCAN_BUSSPEED_DATA | 27 | Current CAN data speed in bits/second.
PCAN_IP_ADDRESS | 28 | Remote address as a IPv4 formated string.
PCAN_LAN_SERVICE_STATUS | 29 | Running status of the Virtual PCAN-Gateway Service.
PCAN_ALLOW_STATUS_FRAMES | 30 | "Receive Status" parameter for Status frames.
PCAN_ALLOW_RTR_FRAMES | 31 | "Receive Status" parameter for RTR frames.
PCAN_ALLOW_ERROR_FRAMES | 32 | "Receive Status" parameter for Error frames.
PCAN_INTERFRAME_DELAY | 33 | Delay, in microseconds, between sending frames.
PCAN_ACCEPTANCE_FILTER_11BIT | 34 | Acceptance filter over code and mask for 11-bit CAN IDs.
PCAN_ACCEPTANCE_FILTER_29BIT | 35 | Acceptance filter over code and mask for 29-bit CAN IDs.
PCAN_IO_DIGITAL_CONFIGURATION | 36 | Activation of digital pins as outputs.
PCAN_IO_DIGITAL_VALUE | 37 | Multiple setting of digital pin values.
PCAN_IO_DIGITAL_SET | 38 | Selective setting of digital pin values to "high".
PCAN_IO_DIGITAL_CLEAR | 39 | Selective setting of digital pin values to "low".
PCAN_IO_ANALOG_VALUE | 40 | Value reading of a single analog pin.
PCAN_FIRMWARE_VERSION | 41 | Firmware version of a PCAN device.
PCAN_ATTACHED_CHANNELS_COUNT | 42 | Amount of PCAN channels attached to a system.
PCAN_ATTACHED_CHANNELS | 43 | Information about PCAN channels attached to a system.
PCAN_ALLOW_ECHO_FRAMES | 44 | "Receive Status" parameter for Echo frames.
PCAN_DEVICE_PART_NUMBER | 45 | PEAK's device part number (IPEH number).
PCAN_HARD_RESET_STATUS | 46 | Activation status of hard reset processing via PCANBasic.Reset calls.
PCAN_LAN_CHANNEL_DIRECTION | 47 | Communication direction of a PCAN Channel representing a PCAN-LAN interface.
Remarks

With some exceptions, a channel must first be initialized before their parameters can be read or set.

Important note Important
For more information about each parameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace
GetValue
SetValue


TPCANStatus Enumeration

Represents a PCAN status/error code.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
[FlagsAttribute]
public enum TPCANStatus
<FlagsAttribute>
Public Enumeration TPCANStatus
[FlagsAttribute]
public enum class TPCANStatus
Members
Member name | Value | Description
PCAN_ERROR_OK | 0 | No error. Success.
PCAN_ERROR_XMTFULL | 1 | The transmit buffer in CAN controller is full.
PCAN_ERROR_OVERRUN | 2 | The CAN controller was read too late.
PCAN_ERROR_BUSLIGHT | 4 | Bus error: an error counter reached the 'light' limit.
PCAN_ERROR_BUSHEAVY | 8 | Bus error: an error counter reached the 'heavy' limit.
PCAN_ERROR_BUSWARNING | 8 | Bus error: an error counter reached the 'warning' limit.
PCAN_ERROR_BUSOFF | 16 | Bus error: the CAN controller is in bus-off state.
PCAN_ERROR_QRCVEMPTY | 32 | The reception queue is empty.
PCAN_ERROR_QOVERRUN | 64 | The reception queue was read too late.
PCAN_ERROR_QXMTFULL | 128 | The transmission queue is full.
PCAN_ERROR_REGTEST | 256 | The test of the CAN controller hardware registers failed (no hardware found).
PCAN_ERROR_NODRIVER | 512 | The driver of the used PCAN device is not loaded.
PCAN_ERROR_HWINUSE | 1,024 | The PCAN-Hardware has already a PCAN-Net attached.
PCAN_ERROR_NETINUSE | 2,048 | A PCAN-Net has already a PCAN-Client attached.
PCAN_ERROR_ILLHW | 5,120 | The handle of the PCAN-Hardware is invalid.
PCAN_ERROR_ILLNET | 6,144 | The handle of the PCAN-Net is invalid.
PCAN_ERROR_ILLCLIENT | 7,168 | The handle of the PCAN-Client is invalid.
PCAN_ERROR_ILLHANDLE | 7,168 | Mask for all handle errors.
PCAN_ERROR_RESOURCE | 8,192 | An internal resource (FIFO, Client, timeout) cannot be created.
PCAN_ERROR_ILLPARAMTYPE | 16,384 | Unknown parameter.
PCAN_ERROR_ILLPARAMVAL | 32,768 | Invalid parameter value.
PCAN_ERROR_UNKNOWN | 65,536 | Unknown error.
PCAN_ERROR_ILLDATA | 131,072 | An action, function, or data is invalid within the current context.
PCAN_ERROR_BUSPASSIVE | 262,144 | Bus error: the CAN controller is error passive.
PCAN_ERROR_ANYBUSERR | 262,172 | Mask for all bus errors.
PCAN_ERROR_ILLMODE | 524,288 | The device driver object state is wrong for the attempted operation.
PCAN_ERROR_CAUTION | 33,554,432 | An operation was successfully carried out, however, irregularities were registered.
PCAN_ERROR_INITIALIZE | 67,108,864 | The PCAN Channel is not (or could not be) initialized.
PCAN_ERROR_ILLOPERATION | 134,217,728 | An invalid operation was registered.
Remarks
The TPCANStatus values 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.
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace


TPCANTimestamp Structure

Defines a time-stamp of a CAN message. The time-stamp contains the number of microseconds since the start of Windows.
Inheritance Hierarchy
SystemObject
SystemValueType
Peak.Can.Basic.BackwardCompatibilityTPCANTimestamp

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public struct TPCANTimestamp
Public Structure TPCANTimestamp
public value class TPCANTimestamp

The TPCANTimestamp type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType)
Top
Fields
 | Name | Description
Public field | micros | Represents the microseconds part of the timestamp (0..999).
Public field | millis | Represents the base-value of the timestamp, in milliseconds (0.. 2^32-1).
Public field | millis_overflow | Represents the roll-around value of millis.
Top
Remarks
Important note Important

The TPCANTimestamp structure is intended only for retrieving the reception time of standard CAN messages of PCAN Channels initialized for standard CAN 2.0 A/B communication, this is, using the Initialize method for initialization and the Read(UInt16, TPCANMsg, TPCANTimestamp) method for data reading.

The members of this structure are sequentially byte aligned.

Calculation of total of microseconds : micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow

See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace
Initialize
Read(UInt16, TPCANMsg, TPCANTimestamp)


TPCANTimestamp Methods

The TPCANTimestamp type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType)
Public method | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Public method | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType)
Top
See Also

Reference

TPCANTimestamp Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANTimestamp Fields

The TPCANTimestamp type exposes the following members.

Fields
 | Name | Description
Public field | micros | Represents the microseconds part of the timestamp (0..999).
Public field | millis | Represents the base-value of the timestamp, in milliseconds (0.. 2^32-1).
Public field | millis_overflow | Represents the roll-around value of millis.
Top
See Also

Reference

TPCANTimestamp Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANTimestamp.micros Field

TPCANTimestampmicros Field

Represents the microseconds part of the timestamp (0..999).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public ushort micros
Public micros As UShort
public:
unsigned short micros

Field Value

UInt16
See Also

Reference

TPCANTimestamp Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANTimestamp.millis Field

TPCANTimestampmillis Field

Represents the base-value of the timestamp, in milliseconds (0.. 2^32-1).

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public uint millis
Public millis As UInteger
public:
unsigned int millis

Field Value

UInt32
See Also

Reference

TPCANTimestamp Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANTimestamp.millis_overflow Field

TPCANTimestampmillis_overflow Field

Represents the roll-around value of millis.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public ushort millis_overflow
Public millis_overflow As UShort
public:
unsigned short millis_overflow

Field Value

UInt16
See Also

Reference

TPCANTimestamp Structure
Peak.Can.Basic.BackwardCompatibility Namespace


TPCANType Enumeration

Represents the type of PCAN (non plug-and-play) hardware to be initialized.

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum TPCANType
Public Enumeration TPCANType
public enum class TPCANType
Members
Member name | Value | Description
PCAN_TYPE_ISA | 1 | PCAN-ISA 82C200.
PCAN_TYPE_DNG | 2 | PCAN-Dongle 82C200.
PCAN_TYPE_DNG_EPP | 3 | PCAN-Dongle EPP 82C200.
PCAN_TYPE_ISA_PHYTEC | 4 | PHYTEC ISA.
PCAN_TYPE_DNG_SJA | 5 | PCAN-Dongle SJA1000.
PCAN_TYPE_DNG_SJA_EPP | 6 | PCAN-Dongle EPP SJA1000.
PCAN_TYPE_ISA_SJA | 9 | PCAN-ISA SJA1000.
Remarks
These values are only required when non plug-and-play PCAN Channels are used. These are to be initialized by using the Initialize(UInt16, TPCANBaudrate, TPCANType, UInt32, UInt16) method.
See Also

Reference

Peak.Can.Basic.BackwardCompatibility Namespace
Initialize(UInt16, TPCANBaudrate, TPCANType, UInt32, UInt16)


Peak.Classes.Time Namespace

The namespace Peak.Classes.Time contains different classes and data types intended for handling time related operations.
Classes
 | Class | Description
Public class | PerformanceTimer | The PerformanceTimer class allows an application to schedule periodic time events.
Public class | SystemTimestamp | Provides access to high-resolution system timestamps.
Enumerations
 | Enumeration | Description
Public enumeration | TimeResolution | Representation of time values.


PerformanceTimer Class

The PerformanceTimer class allows an application to schedule periodic time events.
Inheritance Hierarchy
SystemObject
Peak.Classes.TimePerformanceTimer

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public class PerformanceTimer
Public Class PerformanceTimer
public ref class PerformanceTimer

The PerformanceTimer type exposes the following members.

Constructors
 | Name | Description
Public method | PerformanceTimer | Initializes a new instance of the PerformanceTimer class.
Top
Properties
 | Name | Description
Public property | Accuracy | Retrieves the accuracy of the timer, in milliseconds.
Public property | Enabled | Get or set whether the PerformanceTimer is running.
Public property | Interval | Get or set the time interval, in milliseconds, for the time events.
Public property | SupportsHighResolution | Indicates if the timer uses a high resolution performance counter.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
Events
 | Name | Description
Public event | Elapsed | Occurs each time the number of milliseconds specified by Interval expires.
Top
See Also

Reference

Peak.Classes.Time Namespace


PerformanceTimer Constructor

Initializes a new instance of the PerformanceTimer class.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public PerformanceTimer(
    int interval = 20
)
Public Sub New (
    Optional interval As Integer = 20
)
public:
PerformanceTimer(
    int interval = 20
)

Parameters

interval Int32 (Optional)
Interval, expressed in milliseconds, at which to raise the Elapsed event.
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


PerformanceTimer Properties

The PerformanceTimer type exposes the following members.

Properties
 | Name | Description
Public property | Accuracy | Retrieves the accuracy of the timer, in milliseconds.
Public property | Enabled | Get or set whether the PerformanceTimer is running.
Public property | Interval | Get or set the time interval, in milliseconds, for the time events.
Public property | SupportsHighResolution | Indicates if the timer uses a high resolution performance counter.
Top
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


PerformanceTimer.Accuracy Property

PerformanceTimerAccuracy Property

Retrieves the accuracy of the timer, in milliseconds.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int Accuracy { get; }
Public ReadOnly Property Accuracy As Integer
    Get
public:
property int Accuracy {
    int get ();
}

Property Value

Int32
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


PerformanceTimer.Enabled Property

PerformanceTimerEnabled Property

Get or set whether the PerformanceTimer is running.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool Enabled { get; set; }
Public Property Enabled As Boolean
    Get
    Set
public:
property bool Enabled {
    bool get ();
    void set (bool value);
}

Property Value

Boolean
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


PerformanceTimer.Interval Property

PerformanceTimerInterval Property

Get or set the time interval, in milliseconds, for the time events.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public int Interval { get; set; }
Public Property Interval As Integer
    Get
    Set
public:
property int Interval {
    int get ();
    void set (int value);
}

Property Value

Int32
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


PerformanceTimer.SupportsHighResolution Property

PerformanceTimerSupportsHighResolution Property

Indicates if the timer uses a high resolution performance counter.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public bool SupportsHighResolution { get; }
Public ReadOnly Property SupportsHighResolution As Boolean
    Get
public:
property bool SupportsHighResolution {
    bool get ();
}

Property Value

Boolean
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


PerformanceTimer Methods

The PerformanceTimer type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


PerformanceTimer Events

The PerformanceTimer type exposes the following members.

Events
 | Name | Description
Public event | Elapsed | Occurs each time the number of milliseconds specified by Interval expires.
Top
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


PerformanceTimer.Elapsed Event

PerformanceTimerElapsed Event

Occurs each time the number of milliseconds specified by Interval expires.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public event EventHandler Elapsed
Public Event Elapsed As EventHandler
public:
 event EventHandler^ Elapsed {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}

Value

EventHandler
Remarks
Important note Important
This event is fired from a background thread. It may be needed to do synchronization operations with the main thread, if visual controls are involved.
See Also

Reference

PerformanceTimer Class
Peak.Classes.Time Namespace


SystemTimestamp Class

Provides access to high-resolution system timestamps.
Inheritance Hierarchy
SystemObject
Peak.Classes.TimeSystemTimestamp

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public class SystemTimestamp
Public Class SystemTimestamp
public ref class SystemTimestamp

The SystemTimestamp type exposes the following members.

Constructors
 | Name | Description
Public method | SystemTimestamp | Create an instance of HighResolutionTimestamp to get timestamps in a preferred resolution.
Top
Properties
 | Name | Description
 | Accuracy | Retrieves the time in nanoseconds, in which one tick is generated within the underlying time system.
 | ElapsedMicroseconds | Retrieves the amount of elapsed microseconds within the underlying timer.
 | ElapsedMilliseconds | Retrieves the amount of elapsed milliseconds within the underlying timer.
 | ElapsedNanoseconds | Retrieves the amount of elapsed nanoseconds within the underlying timer.
 | ElapsedSeconds | Retrieves the amount of elapsed seconds within the underlying timer.
Public property | Now | Retrieves the current number of ticks of the underlying time system, expressed in the time resolution defined by Resolution.
Public property | Resolution | Time resolution in which the Timestamp is retrieved.
Top
Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

Peak.Classes.Time Namespace


SystemTimestamp Constructor

Create an instance of HighResolutionTimestamp to get timestamps in a preferred resolution.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public SystemTimestamp(
    TimeResolution resolution = TimeResolution.Microseconds
)
Public Sub New (
    Optional resolution As TimeResolution = TimeResolution.Microseconds
)
public:
SystemTimestamp(
    TimeResolution resolution = TimeResolution::Microseconds
)

Parameters

resolution TimeResolution (Optional)
The time resolution wanted to be used for timestamps retrieved by this object
Remarks
The default time resolution used is microseconds.
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp Properties

The SystemTimestamp type exposes the following members.

Properties
 | Name | Description
 | Accuracy | Retrieves the time in nanoseconds, in which one tick is generated within the underlying time system.
 | ElapsedMicroseconds | Retrieves the amount of elapsed microseconds within the underlying timer.
 | ElapsedMilliseconds | Retrieves the amount of elapsed milliseconds within the underlying timer.
 | ElapsedNanoseconds | Retrieves the amount of elapsed nanoseconds within the underlying timer.
 | ElapsedSeconds | Retrieves the amount of elapsed seconds within the underlying timer.
Public property | Now | Retrieves the current number of ticks of the underlying time system, expressed in the time resolution defined by Resolution.
Public property | Resolution | Time resolution in which the Timestamp is retrieved.
Top
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp.Accuracy Property

SystemTimestampAccuracy Property

Retrieves the time in nanoseconds, in which one tick is generated within the underlying time system.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static long Accuracy { get; }
Public Shared ReadOnly Property Accuracy As Long
    Get
public:
static property long long Accuracy {
    long long get ();
}

Property Value

Int64
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp.ElapsedMicroseconds Property

SystemTimestampElapsedMicroseconds Property

Retrieves the amount of elapsed microseconds within the underlying timer.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static long ElapsedMicroseconds { get; }
Public Shared ReadOnly Property ElapsedMicroseconds As Long
    Get
public:
static property long long ElapsedMicroseconds {
    long long get ();
}

Property Value

Int64
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp.ElapsedMilliseconds Property

SystemTimestampElapsedMilliseconds Property

Retrieves the amount of elapsed milliseconds within the underlying timer.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static long ElapsedMilliseconds { get; }
Public Shared ReadOnly Property ElapsedMilliseconds As Long
    Get
public:
static property long long ElapsedMilliseconds {
    long long get ();
}

Property Value

Int64
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp.ElapsedNanoseconds Property

SystemTimestampElapsedNanoseconds Property

Retrieves the amount of elapsed nanoseconds within the underlying timer.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static long ElapsedNanoseconds { get; }
Public Shared ReadOnly Property ElapsedNanoseconds As Long
    Get
public:
static property long long ElapsedNanoseconds {
    long long get ();
}

Property Value

Int64
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp.ElapsedSeconds Property

SystemTimestampElapsedSeconds Property

Retrieves the amount of elapsed seconds within the underlying timer.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public static long ElapsedSeconds { get; }
Public Shared ReadOnly Property ElapsedSeconds As Long
    Get
public:
static property long long ElapsedSeconds {
    long long get ();
}

Property Value

Int64
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp.Now Property

SystemTimestampNow Property

Retrieves the current number of ticks of the underlying time system, expressed in the time resolution defined by Resolution.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public long Now { get; }
Public ReadOnly Property Now As Long
    Get
public:
property long long Now {
    long long get ();
}

Property Value

Int64
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp.Resolution Property

SystemTimestampResolution Property

Time resolution in which the Timestamp is retrieved.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public TimeResolution Resolution { get; set; }
Public Property Resolution As TimeResolution
    Get
    Set
public:
property TimeResolution Resolution {
    TimeResolution get ();
    void set (TimeResolution value);
}

Property Value

TimeResolution
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


SystemTimestamp Methods

The SystemTimestamp type exposes the following members.

Methods
 | Name | Description
Public method | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object)
Protected method | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object)
Public method | GetHashCode | Serves as the default hash function. (Inherited from Object)
Public method | GetType | Gets the Type of the current instance. (Inherited from Object)
Protected method | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object)
Public method | ToString | Returns a string that represents the current object. (Inherited from Object)
Top
See Also

Reference

SystemTimestamp Class
Peak.Classes.Time Namespace


TimeResolution Enumeration

Representation of time values.

Namespace: Peak.Classes.Time
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
Syntax
C#
VB
C++
Copy
public enum TimeResolution
Public Enumeration TimeResolution
public enum class TimeResolution
Members
Member name | Value | Description
Nanoseconds | 0 | Represents a time value in nanoseconds.
Microseconds | 1 | Represents a time value in microseconds.
Milliseconds | 2 | Represents a time value in milliseconds.
Seconds | 3 | Represents a time value in seconds.
See Also

Reference

Peak.Classes.Time Namespace


Additional Information

PCAN is the platform for PCAN-Basic. The following topics provide an overview of PCAN and fundamental practice with the APIs from PEAK-System.

In this chapter
Topics | Description
Parameter Classification and Usage | This section contains detailed information about the usage of all PcanParameter values supported by the Api class.
Backward Compatible Definitions | This section contains definitions for the backward compatibility PCANBasic class.
Error Frames | This section contains information about CAN Error frames.
Status Frames | This section contains information about PCAN Status frames.
Log File Generation | This section contains information about logging debug data within PCAN-Basic.
PCAN Fundamentals | This section contains an introduction to PCAN.
PCAN-API | This section compares the PCAN-Basic and CanApi4 interfaces, with a function description of CanApi4.
See Also

Other Resources

Welcome to the PCAN-Basic.NET Package Documentation


Parameter Classification and Usage

Different features of the PCAN-Basic API can be retrieved and configured using the methods GetValue / SetValue.

In order to delimit the purpose of the different parameters, they are arranged in 7 groups:

  1. Hardware Identification

  2. Informational Purposes

  3. Influencing Behavior

  4. Data Reading and Flow Control

  5. Logging and Debugging

  6. CAN Data Recording (Tracing)

  7. Electronic Circuits (I/O pins)

With some exceptions, a channel must first be initialized before their parameters can be read or set. Parameters that can be set without first having a Channel initialized are further grouped as:

  • Preset Parameters

See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Additional Information


Hardware Identification Parameters

The first identification of a hardware takes place when selecting a PCAN Channel. The name of a Channel handle gives information about the interface of the hardware.

The name above tells the API the PCAN hardware to connect to, which kind of bus it uses (USB), and that it is the first (01) hardware registered in a system. PCAN-Basic allows connecting following interfaces:

  • USB: Universal Serial Bus. Up to 16 channels.

  • PCI: Peripheral Component Interconnect (including ExpressCard hardware). Up to 16 channels.

  • LAN: Virtual PCAN-Gateway connections. Up to 16 channels.

Note that the way of how hardware is registered in a system depends on its controller driver and on the system itself. When several devices of the same kind are installed on a system (USB for example), by default it is not guaranteed that connecting to PCAN_USBBUS1 after a system restart will still connect to the same hardware.

Therefore, parameters are used to help on the detection of the right hardware.

The following parameters are used to identify the physical hardware to connect, for example when several devices are available for connection:

Parameters
Parameter | Description
ChannelCondition | Availability status of a PCAN Channel.
DeviceId | Device identifier parameter.
HardwareName | PCAN "hardware name" parameter.
ControllerNumber | Zero-based index of a CAN-Controller in a PCAN device.
ChannelIdentifying | Physical identification of an USB based PCAN Channel.
IpAddress | Remote address as a IPv4 formated string.
AttachedChannelsInformation | Information about PCAN channels attached to a system.
DevicePartNumber | PEAK's device part number (IPEH number).
See Also

Reference

PcanParameter

Other Resources

Parameter Classification and Usage


ChannelCondition

This parameter is used to identify the state of use of a PCAN Channel by returning a flag value. For example, a connection is only possible when a PCAN Channel is available, which means:

  • It is valid: The PCAN Channel is one of the listed in the section "Supported By" below.

  • It is present: The hardware associated to a PCAN Channel is attached to the PC, recognized and registered by the device driver.

  • It is connectible: The PCAN Channel is not yet initialized, or it is currently connected by a PCAN-View application.

This parameter is useful when the availability status of a channel registered in a system at a given time must be known.

Availability

Available since PCAN-Basic version 1.0.0. Nevertheless, usability improved significantly since version 1.0.4, due to bug fixes.

The behavior of this parameter was modified with the version 4.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be retrieved. It cannot be modified.

Possible Values

The information about the condition of a Channel is returned as a numeric value, that matches the type ChannelCondition.

Important note Important

The retrieved value must be converted to the ChannelCondition type. Example (C#): ChannelCondition condition = (ChannelCondition)uintBuffer;

Default Value

Does not apply.

Initialization Status

Get: Not relevant, since this parameter is used to ask the status of a PCAN Channel.

Example

The following code shows how to ask the condition of 4 PCI Channels:

C#
VB
C++
Copy
PcanChannel[] channelsToCheck = { PcanChannel.Pci01, PcanChannel.Pci02, PcanChannel.Pci03, PcanChannel.Pci04 };
uint buffer;

for (int i = 0; i < 4; i++)
{
    if (Api.GetValue(channelsToCheck[i], PcanParameter.ChannelCondition, out buffer) == PcanStatus.OK)
    {
        ChannelCondition condition = (ChannelCondition)buffer;
        if ((condition & ChannelCondition.ChannelAvailable) == ChannelCondition.ChannelAvailable)
            Console.WriteLine($"The Channel {channelsToCheck[i]} is available.");
        else
            Console.WriteLine($"The Channel {channelsToCheck[i]} is NOT available.");
    }
}
Dim channelsToCheck As PcanChannel() = {PcanChannel.Pci01, PcanChannel.Pci02, PcanChannel.Pci03, PcanChannel.Pci04}
Dim buffer As UInteger

For i = 0 To 3
    If Api.GetValue(channelsToCheck(i), PcanParameter.ChannelCondition, buffer) = PcanStatus.OK Then
        Dim condition As ChannelCondition = CType(buffer, ChannelCondition)
        If (condition And ChannelCondition.ChannelAvailable) = ChannelCondition.ChannelAvailable Then
            Console.WriteLine($"The Channel {channelsToCheck(i)} is available.")
        Else
            Console.WriteLine($"The Channel {channelsToCheck(i)} is NOT available.")
        End If
    End If
Next
array<PcanChannel>^ channelsToCheck = { PcanChannel::Pci01, PcanChannel::Pci02, PcanChannel::Pci03, PcanChannel::Pci04 };
UInt32 buffer;

for (int i = 0; i < 4; i++)
{
    if (Api::GetValue(channelsToCheck[i], PcanParameter::ChannelCondition, buffer) == PcanStatus::OK)
    {
        ChannelCondition condition = (ChannelCondition)buffer;
        if ((condition & ChannelCondition::ChannelAvailable) == ChannelCondition::ChannelAvailable)
            Console::WriteLine("The Channel {0} is available.", channelsToCheck[i]);
        else
            Console::WriteLine("The Channel {0} is NOT available.", channelsToCheck[i]);
    }
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Hardware Identification Parameters
Parameter Classification and Usage


ChannelIdentifying

This parameter is used to physically identify an USB-based PCAN Channel being used. The identification is done using the status LED of the USB devices.

Note Note

  • The activation of this identification procedure doesn’t affect any communication that can occur on the device while it is being identified.

  • The identification of only one channel can be activated at a time. To activate the identification procedure on another channel, the previous one must first be deactivated.

At the moment PEAK-System offers USB devices of three different generations:

  • First Generation: PCAN-USB, PCAN-Hub.

  • Second Generation: PCAN-USB Pro, PCAN-USB2.

  • Third Generation: PCAN-USB Classic, PCAN-USB FD, PCAN-USB Pro FD.

According with the hardware used, the blinking of the LED is different in color and blink rate:

  • First Generation: Blink color is RED, and the blink rate is about 300 milliseconds.

  • Second Generation: Blink color is ORANGE, and the blink rate is about 250 milliseconds.

  • Third Generation: Blink color is ORANGE, and the blink rate is about 250 milliseconds.

This parameter is useful when an application can connect to several USB devices and it is not clear which (physical) Channel must be used. It is also useful to physically determine which Channel is being used by an application in a determined time.

Availability

Available since PCAN-Basic version 1.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter represents a procedure that can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of this identification procedure is Off. After switching it On, the LED of an USB device stays blinking until it is expressly turned off.

Initialization Status

Get: This parameter can be used on both, initialized and uninitialized PCAN Channels.

Set: This parameter can be used on both, initialized and uninitialized PCAN Channels.

Example

The following code shows how to physically identify a USB Channel:

C#
VB
C++
Copy
PcanChannel[] channelsToIdentify = { PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03 };

for (int i = 0; i < 3; i++)
{
    if (Api.SetValue(channelsToIdentify[i], PcanParameter.ChannelIdentifying, ParameterValue.Activation.On) == PcanStatus.OK)
    {
        Console.Write($"The channel {channelsToIdentify[i]} is now blinking . . . ");
        Console.WriteLine("Press any Key to continue . . .");
        Console.ReadKey();
        if(Api.SetValue(channelsToIdentify[i], PcanParameter.ChannelIdentifying, ParameterValue.Activation.Off) != PcanStatus.OK)
            Console.WriteLine("Error trying to deactivate the identification process.");
    }
    else
        Console.WriteLine($"Error trying to activate the identification process on Channel {channelsToIdentify[i]}.");
}
Dim channelsToIdentify As PcanChannel() = {PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03}

For i = 0 To 2
    If Api.SetValue(channelsToIdentify(i), PcanParameter.ChannelIdentifying, ParameterValue.Activation.[On]) = PcanStatus.OK Then
        Console.Write($"The channel {channelsToIdentify(i)} is now blinking . . . ")
        Console.WriteLine("Press any Key to continue . . .")
        Console.ReadKey()
        If Api.SetValue(channelsToIdentify(i), PcanParameter.ChannelIdentifying, ParameterValue.Activation.Off) <> PcanStatus.OK Then
            Console.WriteLine("Error trying to deactivate the identification process.")
        Else
            Console.WriteLine($"Error trying to activate the identification process on Channel {channelsToIdentify(i)}.")
        End If
    End If
Next
    array<PcanChannel>^ channelsToIdentify = { PcanChannel::Usb01, PcanChannel::Usb02, PcanChannel::Usb03 };

for (int i = 0; i < 3; i++)
{
    if (Api::SetValue(channelsToIdentify[i], PcanParameter::ChannelIdentifying, ParameterValue::Activation::On) == PcanStatus::OK)
    {
        Console::Write("The channel {0} is now blinking . . . ", channelsToIdentify[i]);
        Console::WriteLine("Press any Key to continue . . .");
        Console::ReadKey();
        if (Api::SetValue(channelsToIdentify[i], PcanParameter::ChannelIdentifying, ParameterValue::Activation::Off) != PcanStatus::OK)
            Console::WriteLine("Error trying to deactivate the identification process.");
    }
    else
        Console::WriteLine("Error trying to activate the identification process on Channel {0}.", channelsToIdentify[i]);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Hardware Identification Parameters
Parameter Classification and Usage


DeviceId

This parameter is used to distinguish between 2 or more devices of the same kind connected to a computer simultaneously. A device identifier is a persistent value stored in the flash memory of each device, i.e., the value is not lost after disconnecting the hardware.

Important note Important

Several devices can have the same identifier. It is up to the user to guarantee that those being used are configured with different identifiers, so that a differentiation through this value can work.

This parameter can be used when it is needed to differentiate between PCAN-USB devices connected to the same system at a given time.

Availability

It is available since PCAN-Basic version 1.0.0.

It can be retrieved without initialization since PCAN-Basic version 4.4.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Important note Important

PCAN-PCI: Only FPGA based devices. Requires a device driver version equal to or greater than 4.2.0.

PCAN-LAN: Only devices with a firmware version equal to or greater than 2.8.2. Requires a device driver version equal to or greater than 4.2.0.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

According with the firmware version of the PCAN-USB device, this value can have a resolution of a byte (range [0...MaxValue]), or a double-word (range [0...MaxValue]).

Default Value

If this parameter was never set before, the value is the maximum value possible for the used resolution which is 255 (FFh), or 429496729 (FFFFFFFFh).

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Set: It can be set on initialized PCAN Channels only.

Example

The following code shows how to distinguish USB Channels using their device IDs:

C#
VB
C++
Copy
PcanChannel[] channelsToCheck = { PcanChannel.Usb01, PcanChannel.Usb02 };
uint deviceId;
PcanChannel readChannel, writeChannel;

readChannel = writeChannel = PcanChannel.None;

for (int i = 0; i < 2; i++)
{
    if (Api.GetValue(channelsToCheck[i], PcanParameter.DeviceId, out deviceId) == PcanStatus.OK)
    {
        if (deviceId == 1)
        {
            writeChannel = channelsToCheck[i];
            Console.WriteLine("The channel for writing (handle 0x{0:X}) was found.", channelsToCheck[i]);
        }
        if (deviceId == 2)
        {
            readChannel = channelsToCheck[i];
            Console.WriteLine("The channel for reading (handle 0x{0:X}) was found.", channelsToCheck[i]);
        }
    }
}

if ((readChannel != PcanChannel.None) && (writeChannel != PcanChannel.None))
{
    Console.WriteLine("Both channels were found. Starting to work . . .");
    // Do work . . .
}
else
    Console.WriteLine("Error! Not all needed channels were found. Terminating . . .");
Dim channelsToIdentify As PcanChannel() = {PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03}

For i = 0 To 2
    If Api.SetValue(channelsToIdentify(i), PcanParameter.ChannelIdentifying, ParameterValue.Activation.[On]) = PcanStatus.OK Then
        Console.Write($"The channel {channelsToIdentify(i)} is now blinking . . . ")
        Console.WriteLine("Press any Key to continue . . .")
        Console.ReadKey()
        If Api.SetValue(channelsToIdentify(i), PcanParameter.ChannelIdentifying, ParameterValue.Activation.Off) <> PcanStatus.OK Then
            Console.WriteLine("Error trying to deactivate the identification process.")
        Else
            Console.WriteLine($"Error trying to activate the identification process on Channel {channelsToIdentify(i)}.")
        End If
    End If
Next
    array<PcanChannel>^ channelsToIdentify = { PcanChannel::Usb01, PcanChannel::Usb02, PcanChannel::Usb03 };

for (int i = 0; i < 3; i++)
{
    if (Api::SetValue(channelsToIdentify[i], PcanParameter::ChannelIdentifying, ParameterValue::Activation::On) == PcanStatus::OK)
    {
        Console::Write("The channel {0} is now blinking . . . ", channelsToIdentify[i]);
        Console::WriteLine("Press any Key to continue . . .");
        Console::ReadKey();
        if (Api::SetValue(channelsToIdentify[i], PcanParameter::ChannelIdentifying, ParameterValue::Activation::Off) != PcanStatus::OK)
            Console::WriteLine("Error trying to deactivate the identification process.");
    }
    else
        Console::WriteLine("Error trying to activate the identification process on Channel {0}.", channelsToIdentify[i]);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Hardware Identification Parameters
Parameter Classification and Usage


HardwareName

This parameter is used to retrieve a description text from the hardware represented by a PCAN Channel. This text allows the recognition of device’s models that use the same interface, for example, USB. A normal PCAN USB adapter would return “PCAN-USB” while the new dual CAN/LIN FD adapter would return “PCAN-USB Pro FD”.

This parameter can be used when it is needed to differentiate between several hardware models using the same interface (e.g., PCAN-PCI, PCAN-ExpressCard).

Availability

Available since PCAN-Basic version 1.0.6.

It can be read without initialization since PCAN-Basic version 4.4.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

The value is a null-terminated string which contains the name of the hardware specified by the given PCAN Channel. This string has a maximum length of MaxHardwareNameLength, null-termination character included.

According with the hardware model represented by the current PCAN-Channel, the following texts can be returned:

Hardware Name Value | Interface | hardware Description
PCAN-PCI | PCAN-PCI | CAN interface for PCI.
PCAN-PCI Express | PCAN-PCI | CAN interface for PCI Express.
PCAN-PCI Express FD | PCAN-PCI | CAN and CAN FD interface for PCI Express.
PCAN-cPCI | PCAN-PCI | CAN interface for CompactPCI.
PCAN-MiniPCI | PCAN-PCI | CAN interface for Mini PCI.
PCAN-miniPCIe | PCAN-PCI | CAN interface for PCI Express Mini (PCIe).
PCAN-miniPCIe FD | PCAN-PCI | CAN and CAN FD interface for PCI Express Mini (PCIe).
PCAN-M.2 | PCAN-PCI | CAN and CAN FD interface for M.2 (PCIe).
PCAN-Chip PCIe FD | PCAN-PCI | Chip solutions for the CAN FD connection to PCI Express.
PCAN-PCI/104-Plus | PCAN-PCI | CAN interface for PC/104-Plus.
PCAN-PCI/104-Plus Quad | PCAN-PCI | Four-Channel CAN interface for PC/104-Plus.
PCAN-PCI/104-Express | PCAN-PCI | CAN interface for PCI/104-Express.
PCAN-PC/104-Express FD | PCAN-PCI | CAN and CAN FD interface for PCI/104-Express.
PCAN-ExpressCard | PCAN-PCI | PCAN-ExpressCard.
PCAN-ExpressCard 34 | PCAN-PCI | PCAN-ExpressCard 34.
PCAN-USB | PCAN-USB | .
PCAN-USB FD | PCAN-USB | PCAN-USB FD adapter.
PCAN-USB Pro | PCAN-USB | PCAN-USB Pro dual CAN/LIN.
PCAN-USB Pro FD | PCAN-USB | PCAN-USB Pro FD dual CAN/LIN.
PCAN-USB Hub | PCAN-USB | All-in-one USB adapter for communication through USB, CAN and RS-232.
PCAN-USB X6 | PCAN-USB | 6-Channel CAN and CAN FD interface for high-speed USB 2.0.
PCAN-Chip USB | PCAN-USB | Stamp module for the implementation of CAN FD to USB connections.
PCAN-Ethernet Gateway DR | PCAN-LAN | PCAN-Gateway wired for mounting on a DIN rail.
PCAN-Wireless Gateway DR | PCAN-LAN | PCAN-Gateway wireless for mounting on a DIN rail.
PCAN-Wireless Gateway | PCAN-LAN | PCAN-Gateway wireless with D-Sub connector.
PCAN-Wireless Automotive Gateway | PCAN-LAN | PCAN-Gateway wireless with automotive connector.
Default Value

Does not apply.

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Example

The following code shows how to retrieve the name from USB hardware:

C#
VB
C++
Copy
PcanChannel[] channelsToCheck = { PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03 };
string name;

for (int i = 0; i < 3; i++)
    if (Api.GetValue(channelsToCheck[i], PcanParameter.HardwareName, out name) == PcanStatus.OK)
        Console.WriteLine($"Channel {channelsToCheck[i]} associated hardware: {name}");
Dim channelsToCheck As PcanChannel() = {PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03}
Dim name As String = Nothing

For i = 0 To 2
    If Api.GetValue(channelsToCheck(i), PcanParameter.HardwareName, name) = PcanStatus.OK Then
        Console.WriteLine($"Channel {channelsToCheck(i)} associated hardware: {name}")
    End If
Next
array<PcanChannel>^ channelsToCheck = { PcanChannel::Usb01, PcanChannel::Usb02, PcanChannel::Usb03 };
String^ name;

for (int i = 0; i < 3; i++)
    if (Api::GetValue(channelsToCheck[i], PcanParameter::HardwareName, name) == PcanStatus::OK)
        Console::WriteLine("Channel {0} associated hardware: {1}", channelsToCheck[i], name);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Hardware Identification Parameters
Parameter Classification and Usage


ControllerNumber

This parameter is used to identify the physical CAN channel index of a multichannel CAN hardware (PCAN-PCI, PCAN-USB Pro, PCAN-LAN, etc.). This index is zero-based, so that the first channel on a device is 0, the second 1, and so on.

This parameter can be used to determine which physical channel of a multichannel PCAN device has to be connected.

Availability

Available since PCAN-Basic version 1.2.0.

It can be read without initialization since PCAN-Basic version 4.4.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

A number in the range [0…n-1], where n is the number of physical channels on the device being used. The correspondence between an index number and the CAN channel description on the hardware etiquette is:

Channel Index | Channel Label
0 | CAN 1
1 | CAN 2
n-1 | CAN n
Default Value

Does not apply.

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Set: It can be set on initialized PCAN Channels only.

Example

The following code shows how to retrieve the controller number of a USB Channel:

C#
VB
C++
Copy
PcanChannel[] channelsToCheck = { PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03, PcanChannel.Usb04 };
uint controllerNumber;

for (int i = 0; i < 4; i++)
{
    if (Api.GetValue(channelsToCheck[i], PcanParameter.ControllerNumber, out controllerNumber) == PcanStatus.OK)
    {
        Console.WriteLine($"{channelsToCheck[i]} physical channel index: {controllerNumber}");
    }
}
Dim channelsToCheck As PcanChannel() = {PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03, PcanChannel.Usb04}
Dim controllerNumber As UInteger

For i = 0 To 3
    If Api.GetValue(channelsToCheck(i), PcanParameter.ControllerNumber, controllerNumber) = PcanStatus.OK Then
        Console.WriteLine($"{channelsToCheck(i)} physical channel index: {controllerNumber}")
    End If
Next
array<PcanChannel>^ channelsToCheck = { PcanChannel::Usb01, PcanChannel::Usb02, PcanChannel::Usb03, PcanChannel::Usb04 };
UInt32 controllerNumber;

for (int i = 0; i < 4; i++)
{
    if (Api::GetValue(channelsToCheck[i], PcanParameter::ControllerNumber, controllerNumber) == PcanStatus::OK)
    {
        Console::WriteLine("{0} physical channel index: {1}", channelsToCheck[i], controllerNumber);
    }
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Hardware Identification Parameters
Parameter Classification and Usage


IpAddress

This parameter applies only to hardware of type PcanLan. It is used to distinguish between 2 or more hardware of this kind connected to a computer simultaneously. An IP address represents the configured network address on a PCAN-Gateway device, i.e., the address used to communicate with a PCAN-Gateway device through the network (LAN/WAN).

The IP address identifies a device effectively because it is not allowed to have the same IP address twice within a network, at the same time (address conflict).

This parameter can be used when it is needed to differentiate between PCAN-Gateway devices connected to the same system at a given time, or just to get more information about a remote PCAN-Gateway device through its IP address.

Availability

Available since PCAN-Basic version 4.0.0.

It can be read without initialization since version 4.6.1.

Supported By

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

Since the format used for the IP address is IPv4, possible values are string representing 4 number sections separated by ‘.’, which are in the range [0…255]. Example of an IP address is: “192.168.0.1”.

Default Value

Does not apply.

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Example

The following code shows how to retrieve the IP address of a LAN Channel. The BitrateAdapting parameter is used to facilitate the connection to any available PCAN-LAN Channel:

C#
VB
C++
Copy
PcanChannel[] channelsToCheck = { PcanChannel.Lan01, PcanChannel.Lan02, PcanChannel.Lan03};
string ipAddress;

for (int i = 0; i < 3; i++)
{
    if (Api.SetValue(channelsToCheck[i], PcanParameter.BitrateAdapting, ParameterValue.Activation.On) == PcanStatus.OK)
    {
        PcanStatus result = Api.Initialize(channelsToCheck[i], Bitrate.Pcan500);
        if ((result == PcanStatus.OK) || (result == PcanStatus.Caution))
        {
            if (Api.GetValue(channelsToCheck[i], PcanParameter.IpAddress, out ipAddress) == PcanStatus.OK)
            {
                Console.WriteLine($"Associated IP address of {channelsToCheck[i]}: {ipAddress}");
            }
            Api.Uninitialize(channelsToCheck[i]);
        }
        else
            Console.WriteLine($"Error while trying to initialize the Channel {channelsToCheck[i]}");
    }
    else
        Console.WriteLine($"Error while trying to activate the parameter BitrateAdapting for the {channelsToCheck[i]}");
}
Dim channelsToCheck As PcanChannel() = {PcanChannel.Lan01, PcanChannel.Lan02, PcanChannel.Lan03}
Dim ipAddress As String = Nothing

For i = 0 To 2
    If Api.SetValue(channelsToCheck(i), PcanParameter.BitrateAdapting, ParameterValue.Activation.On) = PcanStatus.OK Then
        Dim result As PcanStatus = Api.Initialize(channelsToCheck(i), Bitrate.Pcan500)
        If result = PcanStatus.OK OrElse result = PcanStatus.Caution Then
            If Api.GetValue(channelsToCheck(i), PcanParameter.IpAddress, ipAddress) = PcanStatus.OK Then
                Console.WriteLine($"Associated IP address of {channelsToCheck(i)}: {ipAddress}")
            End If
            Api.Uninitialize(channelsToCheck(i))
        Else
            Console.WriteLine($"Error while trying to initialize the Channel {channelsToCheck(i)}")
        End If
    Else
        Console.WriteLine($"Error while trying to activate the parameter BitrateAdapting for the {channelsToCheck(i)}")
    End If
Next
array<PcanChannel>^ channelsToCheck = { PcanChannel::Lan01, PcanChannel::Lan02, PcanChannel::Lan03 };
String^ ipAddress;

for (int i = 0; i < 3; i++)
{
    if (Api::SetValue(channelsToCheck[i], PcanParameter::BitrateAdapting, ParameterValue::Activation::On) == PcanStatus::OK)
    {
        PcanStatus result = Api::Initialize(channelsToCheck[i], Bitrate::Pcan500);
        if ((result == PcanStatus::OK) || (result == PcanStatus::Caution))
        {
            if (Api::GetValue(channelsToCheck[i], PcanParameter::IpAddress, ipAddress) == PcanStatus::OK)
            {
                Console::WriteLine("Associated IP address of {0}: {1}", channelsToCheck[i], ipAddress);
            }
            Api::Uninitialize(channelsToCheck[i]);
        }
        else
            Console::WriteLine("Error while trying to initialize the Channel {0}", channelsToCheck[i]);
    }
    else
        Console::WriteLine("Error while trying to activate the parameter BitrateAdapting for the {0}", channelsToCheck[i]);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Hardware Identification Parameters
Parameter Classification and Usage


AttachedChannelsInformation

This parameter is used to get information about all PCAN Channels attached to a system in a single call. It is closely tied to another parameter, AttachedChannelsCount, which returns the number of existing channels. This information is needed for building the buffer that must be passed to the GetValue, method, to retrieve the information about the available Channels.

This parameter can be used to enumerate all existing PCAN Channels in a PC at a given time.

Tip Tip

The Api class offers a method as a shortcut for using these two parameters, GetAttachedChannels. Use this method instead for simplicity.

Availability

It is available since PCAN-Basic version 4.4.0.

Supported By

  • None Channel: Information about available Channels is not tied to any Channel, i.e. no specific Channel can be used for this query.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

An array of PcanChannelInformation elements.

Default Value

Does not apply.

Initialization Status

Get: Not relevant since this parameter is not Channel dependent.

Example

The following code shows how to get information about all currently attached PCAN Channels:

C#
VB
C++
Copy
uint channelsCount;

if (Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsCount, out channelsCount) == PcanStatus.OK)
{
    Console.WriteLine($"Total of {channelsCount} channels were found:");
    if (channelsCount > 0)
    {
        PcanChannelInformation[] channels = new PcanChannelInformation[channelsCount];
        if (Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsInformation, channels) == PcanStatus.OK)
        {
            for (int i = 0; i < channelsCount; i++)
            {
                Console.WriteLine("{0}) ---------------------------\n", i + 1);
                Console.WriteLine(" Name: {0}", channels[i].DeviceName);
                Console.WriteLine(" Handle: 0x{0:X}", channels[i].ChannelHandle);
                Console.WriteLine(" Controller: {0}", channels[i].ControllerNumber);
                Console.WriteLine(" Condition: {0}", channels[i].ChannelCondition);
                Console.WriteLine(" . . . . .");
            }
        }
    }
}
Dim channelsCount As UInteger

If Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsCount, channelsCount) = PcanStatus.OK Then
    Console.WriteLine($"Total of {channelsCount} channels were found:")
    If channelsCount > 0 Then
        Dim channels = New PcanChannelInformation(channelsCount - 1) {}
        If Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsInformation, channels) = PcanStatus.OK Then
            For i As Integer = 0 To channelsCount - 1
                Console.WriteLine("{0}) ---------------------------" & vbLf, i + 1)
                Console.WriteLine(" Name: {0}", channels(i).DeviceName)
                Console.WriteLine(" Handle: 0x{0:X}", channels(i).ChannelHandle)
                Console.WriteLine(" Controller: {0}", channels(i).ControllerNumber)
                Console.WriteLine(" Condition: {0}", channels(i).ChannelCondition)
                Console.WriteLine(" . . . . .")
            Next
        End If
    End If
End If
UInt32 channelsCount;

if (Api::GetValue(PcanChannel::None, PcanParameter::AttachedChannelsCount, channelsCount) == PcanStatus::OK)
{
    Console::WriteLine("Total of {0} channels were found:", channelsCount);
    if (channelsCount > 0)
    {
        array<PcanChannelInformation^>^ channels = gcnew array<PcanChannelInformation^>(channelsCount);
        if (Api::GetValue(PcanChannel::None, PcanParameter::AttachedChannelsInformation, channels) == PcanStatus::OK)
        {
            for (int i = 0; i < channelsCount; i++)
            {
                Console::WriteLine("{0}) ---------------------------\n", i + 1);
                Console::WriteLine(" Name: {0}", channels[i]->DeviceName);
                Console::WriteLine(" Handle: 0x{0:X}", channels[i]->ChannelHandle);
                Console::WriteLine(" Controller: {0}", channels[i]->ControllerNumber);
                Console::WriteLine(" Condition: {0}", channels[i]->ChannelCondition);
                Console::WriteLine(" . . . . .");
            }
        }
    }
}
See Also

Reference

GetAttachedChannels
GetValue
SetValue
PcanParameter

Other Resources

Hardware Identification Parameters
Parameter Classification and Usage


DevicePartNumber

This parameter is used to get the part number (IPEH-number) associated with a PCAN device. This is a text that allows the recognition and differentiation of device models using the same interface, for example USB. A PCAN-USB FD adapter would return "IPEH-004022" while a classic PCAN-USB would return "IPEH-002021/002022”.

This parameter can be used when it is wanted to differentiate between several hardware models using the same interface.

Availability

It is available since PCAN-Basic version 4.6.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

The part number is represented as a string of the form "IPEH-xxxxxx”, where xxxxxx represents a six-digit number. If a device has several revisions so, that it is represented by more than one IPEH number, then all numbers are contained in the same text, separated by a "/" character. For example, a classic PCAN-USB reports the value IPEH-002021/002022. The returned value is a null-terminated string with a length of minimum 12 bytes.

Default Value

Does not apply.

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Example

The following code shows how to retrieve the part number of a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;
string partNumber;

if (Api.GetValue(channelUsed, PcanParameter.DevicePartNumber, out partNumber) == PcanStatus.OK)
    Console.WriteLine($"Part number of {channelUsed}: {partNumber}");
else
    Console.WriteLine("Error! Could not retrieve the part number of the device.");
Dim channelUsed As PcanChannel = PcanChannel.Usb01
Dim partNumber As String = Nothing

If Api.GetValue(channelUsed, PcanParameter.DevicePartNumber, partNumber) = PcanStatus.OK Then
    Console.WriteLine($"Part number of {channelUsed}: {partNumber}")
Else
    Console.WriteLine("Error! Could not retrieve the part number of the device.")
End If
PcanChannel channelUsed = PcanChannel::Usb01;
String^ partNumber;

if (Api::GetValue(channelUsed, PcanParameter::DevicePartNumber, partNumber) == PcanStatus::OK)
    Console::WriteLine("Part number of {0}: {1}", channelUsed, partNumber);
else
    Console::WriteLine("Error! Could not retrieve the part number of the device.");
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Hardware Identification Parameters
Parameter Classification and Usage


Informative Parameters

These parameters are intended to give information about the status of the different components of the API, that is, about the API itself, as well as about the Hardware (device firmware and driver version). Depending on the current state of these components, features may or may not be available.

To be sure that a PCAN-Basic software works properly with a specific hardware, it is a good idea to check version parameters at the beginning (after connection). In this way, it can be ensured that the software will work for end users as it was working at development time.

Note that when dependences between a PcanParameter and the API and/or driver/firmware Version appear, they will be notified and remarked in the documentation of the API.

Parameters
Parameter | Description
ApiVersion | PCAN-Basic API version parameter.
ChannelVersion | PCAN device channel version parameter.
ChannelFeatures | Capabilities of a PCAN device (PcanDeviceFeatures).
BitrateInformation | Current bit rate as BTR0BTR1 value (classic CAN 2.0 A/B).
BitrateFdInformation | Current bit rate as FD String value (CAN FD).
BusSpeedNominal | Current CAN nominal speed in bits/second.
BusSpeedData | Current CAN data speed in bits/second.
VirtualPcanGatewayStatus | Running status of the Virtual PCAN-Gateway service (ServiceStatus).
FirmwareVersion | Firmware version of a PCAN device.
AttachedChannelsCount | Amount of PCAN channels attached to a system.
LanChannelDirection | Communication flow of a PCAN-LAN based channel (LanDirection).
See Also

Reference

PcanParameter

Other Resources

Parameter Classification and Usage


ApiVersion

This parameter is used to retrieve the version of this API implementation. It can be used to determine whether or not a feature is available, or simply as an informational output in an application.

Availability

Available since PCAN-Basic version 1.0.0.

Supported By

  • Any Channel: Due to the API structure, a Channel value is needed to get a the value of a PcanParameter, when using the GetValue. But since the API version doesn’t depend on a specific Channel, any defined PcanChannel value can be used, including None.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

The API version value is represented as a string of the form “a.b.c.d”, where:

  • a: represents the major version number.

  • b: represents the minor version number.

  • c: represents the release version number.

  • d: represents the build number.

All four values have a maximum size of 16 bits that allows a value of 65535 per each. The returned value is a null-terminated string with a maximum length of 24 bytes.

Default Value

Does not apply.

Initialization Status

Get: Not relevant since this parameter is not channel dependent.

Example

The following code shows how to retrieve the API version:

C#
VB
C++
Copy
string apiVersion;

if (Api.GetValue(PcanChannel.None, PcanParameter.ApiVersion, out apiVersion) == PcanStatus.OK)
    Console.WriteLine($"The PCAN-Basic version used is: {apiVersion}");
Dim apiVersion As String = Nothing

If Api.GetValue(PcanChannel.None, PcanParameter.ApiVersion, apiVersion) = PcanStatus.OK Then
    Console.WriteLine($"The PCAN-Basic version used is: {apiVersion}")
End If
String^ apiVersion;

if (Api::GetValue(PcanChannel::None, PcanParameter::ApiVersion, apiVersion) == PcanStatus::OK)
    Console::WriteLine("The PCAN-Basic version used is: {0}", apiVersion);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


ChannelVersion

This parameter is used to retrieve information about the underlying device driver, as well as to obtain copyright information. It can be used as informational output about the installed device driver in an application.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

The information about driver version and copyright is represented as a multi-line string (4 lines), offering the following information in each line:

  • Line 1: Device driver name and driver version.

  • Line 2: Architecture implemented on the driver and targeted platform.

  • Line 3: Year of copyright.

  • Line 4: Company name and city where its head office is located.

Note Note

This format is available beginning with the device driver version 3.x. The returned value is a null terminated string with a maximum length of 256 bytes (null-termination included).

Default Value

Does not apply.

Initialization Status

Get: This parameter can be used on both, initialized and uninitialized PCAN Channels.

Example

The following code shows how to retrieve version information related to a USB Channel:

C#
VB
C++
Copy
string channelVersion;
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.GetValue(channelUsed, PcanParameter.ChannelVersion, out channelVersion) == PcanStatus.OK)
{
    Console.WriteLine($"{channelUsed} associated information:");
    Console.WriteLine(channelVersion);
}
else
    Console.WriteLine($"It was not possible to get information about the channel {channelUsed}");
Dim channelVersion As String = Nothing
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.GetValue(channelUsed, PcanParameter.ChannelVersion, channelVersion) = PcanStatus.OK Then
    Console.WriteLine($"{channelUsed} associated information:")
    Console.WriteLine(channelVersion)
Else
    Console.WriteLine($"It was not possible to get information about the channel {channelUsed}")
End If
String^ channelVersion;
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::GetValue(channelUsed, PcanParameter::ChannelVersion, channelVersion) == PcanStatus::OK)
{
    Console::WriteLine("{0} associated information:", channelUsed);
    Console::WriteLine(channelVersion);
}
else
    Console::WriteLine("It was not possible to get information about the channel {0}", channelUsed);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


ChannelFeatures

This parameter is used to retrieve information about the special properties of a device. It can be used to allow enabling/disabling features in an application according to the capabilities of a device.

Availability

It is available since PCAN-BAsic version 4.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

The information about special features is returned as a numeric “flag” value, that matches the type PcanDeviceFeatures.

Important note Important

The retrieved value must be converted to the PcanDeviceFeatures type. Example (C#): PcanDeviceFeatures features = (PcanDeviceFeatures)uintBuffer;

Default Value

Does not apply.

Initialization Status

Get: This parameter can be used on both, initialized and uninitialized PCAN-Channels.

Example

The following code shows how to retrieve the capabilities of several USB Channels:

C#
VB
C++
Copy
uint features;
PcanChannel[] channelsToCheck = { PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03, PcanChannel.Usb04 };

Console.WriteLine("CAN-FD capable channels:");
for (int i = 0; i < 4; i++)
    if (Api.GetValue(channelsToCheck[i], PcanParameter.ChannelFeatures, out features) == PcanStatus.OK)
        Console.WriteLine($"Channel {channelsToCheck[i]}: {(PcanDeviceFeatures)features}");
Dim features As UInteger
Dim channelsToCheck As PcanChannel() = {PcanChannel.Usb01, PcanChannel.Usb02, PcanChannel.Usb03, PcanChannel.Usb04}

Console.WriteLine("CAN-FD capable channels:")
For i = 0 To 3
    If Api.GetValue(channelsToCheck(i), PcanParameter.ChannelFeatures, features) = PcanStatus.OK Then
        Console.WriteLine($"Channel {channelsToCheck(i)}: {CType(features, PcanDeviceFeatures)}")
    End If
Next
UInt32 features;
array<PcanChannel>^ channelsToCheck = { PcanChannel::Usb01, PcanChannel::Usb02, PcanChannel::Usb03, PcanChannel::Usb04 };

Console::WriteLine("CAN-FD capable channels:");
for (int i = 0; i < 4; i++)
    if (Api::GetValue(channelsToCheck[i], PcanParameter::ChannelFeatures, features) == PcanStatus::OK)
        Console::WriteLine("Channel {0}: {1}", channelsToCheck[i], (PcanDeviceFeatures)features);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


BitrateInformation

This parameter is used to obtain information about the bit rate of a Channel, that was initialized to work with classic CAN communication.

Availability

It is available since PCAN-Basic version 4.0.0.

It can be read without initialization since PCAN-Basic version 4.4.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

This value has a resolution of Word (range [0... MaxValue]), which represents bit rate registers (BTR0/BTR1), for a CAN controller SJA1000. It matches the type Bitrate.

Important note Important

The retrieved value can be converted to the Bitrate type. Example (C#): Bitrate bitrate = (Bitrate)uintBuffer;

Default Value

Does not apply.

Initialization Status

Get: It can be read on initialized or uninitialized PCAN-Channels.

Example

The following code shows how to retrieve classic CAN bit rate information from a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed= PcanChannel.Usb01;
uint bitrate;

if (Api.GetValue(channelUsed, PcanParameter.BitrateInformation, out bitrate) == PcanStatus.OK)
    Console.WriteLine($"The channel {channelUsed} uses following bit rate: 0x{bitrate:X} ({(Bitrate)bitrate})");
Dim channelUsed As PcanChannel = PcanChannel.Usb01
Dim bitrate As UInteger

If Api.GetValue(channelUsed, PcanParameter.BitrateInformation, bitrate) = PcanStatus.OK Then
    Console.WriteLine($"The channel {channelUsed} uses following bit rate: 0x{bitrate:X} ({CType(bitrate, Bitrate)})")
End If
PcanChannel channelUsed = PcanChannel:: Usb01;
UInt32 bitrate;

if (Api::GetValue(channelUsed, PcanParameter::BitrateInformation, bitrate) == PcanStatus::OK)
    Console::WriteLine("The channel {0} uses following bit rate: 0x{1:X} ({2})", channelUsed, bitrate, (Bitrate)bitrate);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


BitrateFdInformation

This parameter is used to obtain information about the bit rate of a Channel, that was initialized to work with CAN FD communication.

Availability

It is available since PCAN-Basic version 4.0.0.

It can be read without initialization since PCAN-Basic version 4.4.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

Possible values are strings representing the nominal and data bit rate used by a CAN FD capable hardware.

Important note Important

The retrieved value can be converted to the BitrateFD type. Example (C#): BitrateFD bitrate = stringBuffer;

Default Value

Does not apply.

Initialization Status

Get: It can be read on initialized or uninitialized PCAN-Channels.

Example

The following code shows how to retrieve CAN FD bit rate information from a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;
string buffer;

if (Api.GetValue(channelUsed, PcanParameter.BitrateFdInformation, out buffer) == PcanStatus.OK)
{
    BitrateFD bitrateFD = (BitrateFD)buffer;
    Console.WriteLine($"The channel {channelUsed} uses following bit rate:");
    Console.WriteLine($"  Frequency: {bitrateFD.Frequency}");
    Console.WriteLine($"  Nominal: {bitrateFD.Nominal}");
    Console.WriteLine($"  Data: {bitrateFD.Data}");
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01
Dim buffer As String = Nothing

If Api.GetValue(channelUsed, PcanParameter.BitrateFdInformation, buffer) = PcanStatus.OK Then
    Dim bitrateFD As BitrateFD = CType(buffer, BitrateFD)
    Console.WriteLine($"The channel {channelUsed} uses following bit rate:")
    Console.WriteLine($"  Frequency: {bitrateFD.Frequency}")
    Console.WriteLine($"  Nominal: {bitrateFD.Nominal}")
    Console.WriteLine($"  Data: {bitrateFD.Data}")
End If
PcanChannel channelUsed = PcanChannel::Usb01;
String^ buffer;

if (Api::GetValue(channelUsed, PcanParameter::BitrateFdInformation, buffer) == PcanStatus::OK)
{
    BitrateFD^ bitrateFD = (BitrateFD^)buffer;
    Console::WriteLine("The channel {0} uses following bit rate:", channelUsed);
    Console::WriteLine("  Frequency: {0}", bitrateFD->Frequency);
    Console::WriteLine("  Nominal: {0}", bitrateFD->Nominal);
    Console::WriteLine("  Data: {0}", bitrateFD->Data);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


BusSpeedNominal

This parameter is used to retrieve information about the currently used nominal CAN Bus speed, in bits per second. It can be used to display a friendly bit rate value in an application that can be easily and quickly understood by any user.

Availability

It is available since PCAN-Basic version 4.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

This value has a resolution of Double-Word (range [0... MaxValue]).

Default Value

Does not apply.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to retrieve the friendly nominal bit rate value from an USB Channel:

C#
VB
C++
Copy
uint bitrate;
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, (BitrateFD)BitrateFD.BitrateSaeJ2284_4) == PcanStatus.OK)
{
    if (Api.GetValue(channelUsed, PcanParameter.BusSpeedNominal, out bitrate) == PcanStatus.OK)
        Console.WriteLine($"Nominal bit rate of channel {channelUsed} is {bitrate / 1000.0} kBit/s");
    else
        Console.WriteLine($"Error retrieving Bus Speed on channel {channelUsed}");
    Api.Uninitialize(channelUsed);
}
Dim bitrate As UInteger
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, CType(BitrateFD.BitrateSaeJ2284_4, BitrateFD)) = PcanStatus.OK Then
    If Api.GetValue(channelUsed, PcanParameter.BusSpeedNominal, bitrate) = PcanStatus.OK Then
        Console.WriteLine($"Nominal bit rate of channel {channelUsed} is {bitrate / 1000.0} kBit/s")
    Else
        Console.WriteLine($"Error retrieving Bus Speed on channel {channelUsed}")
    End If
    Api.Uninitialize(channelUsed)
End If
UInt32 bitrate;
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, (BitrateFD^)BitrateFD::BitrateSaeJ2284_4) == PcanStatus::OK)
{
    if (Api::GetValue(channelUsed, PcanParameter::BusSpeedNominal, bitrate) == PcanStatus::OK)
        Console::WriteLine("Nominal bit rate of channel {0} is {1} kBit/s", channelUsed, bitrate / 1000.0);
    else
        Console::WriteLine("Error retrieving Bus Speed on channel {0}", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


BusSpeedData

This parameter is used to retrieve information about the currently used CAN bus speed for the data phase (bit rate switch), in bits per second. It can be used to display a friendly bit rate value in an application that can be easily and quickly understood by any user.

Availability

It is available since PCAN-Basic version 4.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

This value has a resolution of Double-Word (range [0... MaxValue]).

Default Value

Does not apply.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to retrieve the friendly data bit rate value from a USB Channel:

C#
VB
C++
Copy
uint bitrate;
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, (BitrateFD)BitrateFD.BitrateSaeJ2284_4) == PcanStatus.OK)
{
    if (Api.GetValue(channelUsed, PcanParameter.BusSpeedData, out bitrate) == PcanStatus.OK)
        Console.WriteLine($"Data bit rate of channel {channelUsed} is {bitrate / 1000000.0} MB/s");
    else
        Console.WriteLine($"Error retrieving Bus Speed on channel {channelUsed}");
    Api.Uninitialize(channelUsed);
}
Dim bitrate As UInteger
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, CType(BitrateFD.BitrateSaeJ2284_4, BitrateFD)) = PcanStatus.OK Then
    If Api.GetValue(channelUsed, PcanParameter.BusSpeedData, bitrate) = PcanStatus.OK Then
        Console.WriteLine($"Data bit rate of channel {channelUsed} is {bitrate / 1000000.0} MB/s")
    Else
        Console.WriteLine($"Error retrieving Bus Speed on channel {channelUsed}")
    End If
    Api.Uninitialize(channelUsed)
End If
UInt32 bitrate;
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, (BitrateFD^)BitrateFD::BitrateSaeJ2284_4) == PcanStatus::OK)
{
    if (Api::GetValue(channelUsed, PcanParameter::BusSpeedData, bitrate) == PcanStatus::OK)
        Console::WriteLine("Data bit rate of channel {0} is {1} MB/s", channelUsed, bitrate / 1000000.0);
    else
        Console::WriteLine("Error retrieving Bus Speed on channel {0}", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


VirtualPcanGatewayStatus

This parameter is used to obtain the running status of the System service that is part of the Virtual PCAN-Gateway solution. This service works together with the device driver PCAN-LAN. Both make the interaction with PCAN-LAN hardware possible (PCAN-Gateway Ethernet/Wireless) by using the PCAN environment under Windows.

This parameter can be used to ensure that the Virtual PCAN-Gateway communication is working.

Caution note Caution

The Virtual PCAN-Gateway product is available only for Windows systems. It is not supported under Linux.

Availability

It is available since PCAN-Basic version 4.1.0.

Supported By

  • None: The status of the service is not tied to any Channel connection, i.e. no specific Channel can be used for this query.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

The information about a service status is returned as a numeric “flag” value, that matches the type ServiceStatus.

Important: The retrieved value must be converted to the ServiceStatus type. Example (C#): ServiceStatus status = (ServiceStatus)uintBuffer;

Default Value

Does not apply.

Initialization Status

Get: Not relevant since this parameter is not Channel dependent.

Example

The following code shows how to retrieve the status of the Virtual PCAN-Gateway service:

C#
VB
C++
Copy
uint serviceState;

if(Api.GetValue(PcanChannel.None, PcanParameter.VirtualPcanGatewayStatus, out serviceState) == PcanStatus.OK)
{
    ServiceStatus status = (ServiceStatus)serviceState;
    Console.WriteLine($"PCAN-LAN service status: {status}");
}
else
    Console.WriteLine("Error retrieving the status of the Virtual PCAN-Gateway service.");
Dim serviceState As UInteger

If Api.GetValue(PcanChannel.None, PcanParameter.VirtualPcanGatewayStatus, serviceState) = PcanStatus.OK Then
    Dim status As ServiceStatus = CType(serviceState, ServiceStatus)
    Console.WriteLine($"PCAN-LAN service status: {status}")
Else
    Console.WriteLine("Error retrieving the status of the Virtual PCAN-Gateway service.")
End If
UInt32 serviceState;

if (Api::GetValue(PcanChannel::None, PcanParameter::VirtualPcanGatewayStatus, serviceState) == PcanStatus::OK)
{
    ServiceStatus status = (ServiceStatus)serviceState;
    Console::WriteLine("PCAN-LAN service status: {0}", status);
}
else
    Console::WriteLine("Error retrieving the status of the Virtual PCAN-Gateway service.");
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


FirmwareVersion

This parameter is used to get the firmware version of the device associated with a PCAN Channel. It can be used to determine if a device is up to date, or simply as informational output in an application.

Availability

It is available since PCAN-Basic version 4.4.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

The firmware version value is represented as a string of the form “a.b.c”, where:

  • a: represents the major version number.

  • b: represents the minor version number.

  • c: represents the release version number.

All three values have a maximum size of 16 bits that allows a value of 65535 per each. The returned value is a null-terminated string with a maximum length of 18 bytes.

Default Value

Does not apply.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to retrieve the firmware version of a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    string firmware;
    if (Api.GetValue(channelUsed, PcanParameter.FirmwareVersion, out firmware) == PcanStatus.OK)
        Console.WriteLine($"Firmware version of {channelUsed}: {firmware}");
    else
        Console.WriteLine($"Error retrieving the firmware version on channel {channelUsed}");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim firmware As String = Nothing
    If Api.GetValue(channelUsed, PcanParameter.FirmwareVersion, firmware) = PcanStatus.OK Then
        Console.WriteLine($"Firmware version of {channelUsed}: {firmware}")
    Else
        Console.WriteLine($"Error retrieving the firmware version on channel {channelUsed}")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    String^ firmware;
    if (Api::GetValue(channelUsed, PcanParameter::FirmwareVersion, firmware) == PcanStatus::OK)
        Console::WriteLine("Firmware version of {0}: {1}", channelUsed, firmware);
    else
        Console::WriteLine("Error retrieving the firmware version on channel {0}", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


AttachedChannelsCount

This parameter is used to get information about the amount of PCAN Channels attached to a system in a single call. It is closely tied to another parameter, AttachedChannelsInformation, which returns an array containing further information about the Channels.

The information retrieved with this parameter is needed for building a buffer to use with the GetValue method, to retrieve further information about the available Channels.

Tip Tip

The Api class offers a method as a shortcut for using these two parameters, GetAttachedChannels. Use this method instead for simplicity.

Availability

It is available since version 4.4.0.

Supported By

  • None Channel: The number of available Channels is not tied to any Channel, i.e. no specific Channel can be used for this query.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

A number in the range [0…n], where n is the sum of the maximum supported Channels per device. At the time of writing this documentation a maximum of 48 Channels can be handled simultaneously: 16 PCAN-PCI, 16 PCAN-USB, and 16 PCAN-LAN devices.

Default Value

Does not apply.

Initialization Status

Get: Not relevant since this parameter does not depend on a specific Channel.

Example

The following code shows how to get the amount of Channels attached to this PC:

C#
VB
C++
Copy
uint channelsCount;

if (Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsCount, out channelsCount) == PcanStatus.OK)
    Console.WriteLine($"There are currently {channelsCount} channels attached to this PC.");
Dim channelsCount As UInteger

If Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsCount, channelsCount) = PcanStatus.OK Then
    Console.WriteLine($"There are currently {channelsCount} channels attached to this PC.")
End If
UInt32 channelsCount;

if (Api::GetValue(PcanChannel::None, PcanParameter::AttachedChannelsCount, channelsCount) == PcanStatus::OK)
    Console::WriteLine("There are currently {0} channels attached to this PC.", channelsCount);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


LanChannelDirection

This parameter is used to get the communication flow currently supported by a PCAN-LAN device associated with a PCAN Channel.

Since the logical connection of PCAN-LAN device is done using routes, it is possible to configure channels to don’t transport data in a bidirectional way, like usual CAN devices.

Caution note Caution

The Virtual PCAN-Gateway product is available only for Windows systems. It is not supported under Linux.

Availability

It is available since version 4.9.0.

Supported By

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

The information about the direction of the communication within a PCAN-LAN channel is returned as a numeric “flag” value, that matches the type LanDirection.

Important: The retrieved value must be converted to the LanDirection type. Example (C#): LanDirection direction = (LanDirection)uintBuffer;

Default Value

Does not apply.

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Example

The following code shows how to retrieve the direction of the communication for a PCAN-LAN device:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Lan01;

PcanStatus stsResult = Api.GetValue(channelUsed, PcanParameter.LanChannelDirection, out uint iChannelDirection);
if (stsResult == PcanStatus.OK)
{
    if (((LanDirection)iChannelDirection & LanDirection.Write) == LanDirection.Write)
        Console.WriteLine("The channel can forward messages to the PCAN-LAN device.");
    else
        Console.WriteLine("The channel CANNOT forward messages to the PCAN-LAN device.");
}
else
    Console.WriteLine("Error! Could not get the direction information for channel 0x{0:X}.", channelUsed);
Dim channelUsed As PcanChannel = PcanChannel.Lan01
Dim iChannelDirection As UInt32

Dim stsResult As PcanStatus = Api.GetValue(channelUsed, PcanParameter.LanChannelDirection, iChannelDirection)
If (stsResult = PcanStatus.OK) Then
    If ((iChannelDirection And LanDirection.Write) = LanDirection.Write) Then
        Console.WriteLine("The channel can forward messages to the PCAN-LAN device.")
    Else
        Console.WriteLine("The channel CANNOT forward messages to the PCAN-LAN device.")
    End If

Else
    Console.WriteLine("Error! Could not get the direction information for channel 0x{0:X}.", channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Lan01;
UInt32 iChannelDirection;

PcanStatus stsResult = Api::GetValue(channelUsed, PcanParameter::LanChannelDirection, iChannelDirection);
if (stsResult == PcanStatus::OK)
{
    if (((LanDirection)iChannelDirection & LanDirection::Write) == LanDirection::Write)
        Console::WriteLine("The channel can forward messages to the PCAN-LAN device.");
    else
        Console::WriteLine("The channel CANNOT forward messages to the PCAN-LAN device.");
}
else
    Console::WriteLine("Error! Could not get the direction information for channel 0x{0:X}.", channelUsed);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Informative Parameters
Parameter Classification and Usage


Special Behaviors Parameters

These parameters are intended to activate some features, that cause a device to react or work in an exceptional way.

Note Note

Not all features are supported by all kind of devices.

Parameters
Parameter | Description
Power5Volts | PCAN "5-volt power" parameter.
BusOffAutoReset | PCAN "reset on bus-off" parameter.
ListenOnly | PCAN "listen-only" parameter.
BitrateAdapting | Attachment to an existing connection with unknown/different bit rate.
InterframeDelay | Delay, in microseconds, between sending frames.
HardResetStatus | Activation status of hard reset processing.
See Also

Reference

PcanParameter

Other Resources

Parameter Classification and Usage


Power5Volts

This parameter is used for switching the external 5V on the D-Sub connector of a device. This is useful when connecting external bus converter modules to a card (AU5790 / TJA1054)), so that it is also supplied with power.

Availability

Available since PCAN-Basic version 1.0.0.

It can be read without initialization since PCAN-Basic version 4.4.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

    Caution note Caution

    Not all USB devices support this parameter.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter represents an extra voltage that can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of this extra voltage is Off. After switching it On, the extra 5V stays on the D-Sub until it is expressly deactivated, or the device is reinitialized (unplugged and plugged in again, or PC reboot).

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Set: It can be set on initialized PCAN Channels only.

Example

The following code shows how to activate the extra 5V power of a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.Power5Volts, ParameterValue.Activation.On) == PcanStatus.OK)
        Console.WriteLine($"5V power of {channelUsed} successfully activated.");
    else
        Console.WriteLine($"Error configuring 5V power on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.Power5Volts, ParameterValue.Activation.On) = PcanStatus.OK Then
        Console.WriteLine($"5V power of {channelUsed} successfully activated.")
    Else
        Console.WriteLine($"Error configuring 5V power on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::Power5Volts, ParameterValue::Activation::On) == PcanStatus::OK)
        Console::WriteLine("5V power of {0} successfully activated.", channelUsed);
    else
        Console::WriteLine("Error configuring 5V power on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Special Behaviors Parameters
Parameter Classification and Usage


BusOffAutoReset

This parameter instructs the PCAN driver to automatically reset the CAN controller of a PCAN Channel when a bus-off state is detected. It can be used to avoid resetting a device manually, after it has reached a bus-off state, for instance, when an application should work unattended, and it is known that bus-off error may occur.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of the automatic bus-off reset is Off. After switching it On, the automatic reset stays active until it is expressly deactivated, or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to activate the automatic bus-off reset of a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.BusOffAutoReset, ParameterValue.Activation.On) == PcanStatus.OK)
        Console.WriteLine($"The automatic bus-off reset mechanism has been activated successfully for {channelUsed}.");
    else
        Console.WriteLine($"Error configuring the automatic reset on bus-off on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.BusOffAutoReset, ParameterValue.Activation.On) = PcanStatus.OK Then
        Console.WriteLine($"The automatic bus-off reset mechanism has been activated successfully for {channelUsed}.")
    Else
        Console.WriteLine($"Error configuring the automatic reset on bus-off on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::BusOffAutoReset, ParameterValue::Activation::On) == PcanStatus::OK)
        Console::WriteLine("The automatic bus-off reset mechanism has been activated successfully for {0}.", channelUsed);
    else
        Console::WriteLine("Error configuring the automatic reset on bus-off on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Special Behaviors Parameters
Parameter Classification and Usage


ListenOnly

This parameter allows the user to set the hardware represented by a PCAN Channel in listen-only mode. When this mode is active, the CAN controller doesn't take part on active events (e.g., transmitting CAN messages) but remains in a passive mode (CAN monitor), in which it can analyze the traffic on the CAN bus. See also Philips Data Sheet SJA1000 Stand-alone CAN-controller.

This is a so called “preset parameter", which means that it can be configured before a PCAN Channel is initialized. This allow the activation or deactivation of a parameter as fast as possible, avoiding in this way problems that can appear with sensitive operations.

This parameter is useful, if an application wants to passively inspect the data being transferred within a CAN network, without causing any disturbance to it.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Important note Important

On PCAN-LAN Channels, the listen-only mode cannot be configured over this parameter. It can only be changed directly on the device, by using its configuration interface.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of the listen-only mode is Off. After switching it On, the listen-only mode stays active until it is expressly deactivated, or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: This parameter can be used in initialized or uninitialized Channels.

Set: This parameter can be used in initialized or uninitialized Channels.

Example

The following code shows how to enable the listen-only mode in a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.SetValue(channelUsed, PcanParameter.ListenOnly, ParameterValue.Activation.On) == PcanStatus.OK)
    Console.WriteLine($"The listen-only mode has been activated successfully for {channelUsed}.");
else
    Console.WriteLine($"Error configuring the listen-only mode on channel {channelUsed}.");
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.SetValue(channelUsed, PcanParameter.ListenOnly, ParameterValue.Activation.On) = PcanStatus.OK Then
    Console.WriteLine($"The listen-only mode has been activated successfully for {channelUsed}.")
Else
    Console.WriteLine($"Error configuring the listen-only mode on channel {channelUsed}.")
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::SetValue(channelUsed, PcanParameter::ListenOnly, ParameterValue::Activation::On) == PcanStatus::OK)
    Console::WriteLine("The listen-only mode has been activated successfully for {0}.", channelUsed);
else
    Console::WriteLine("Error configuring the listen-only mode on channel {0}.", channelUsed);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Preset Parameters
Special Behaviors Parameters
Parameter Classification and Usage
Philips Data Sheet SJA1000 Stand-alone CAN-controller


BitrateAdapting

This parameter allows the user to connect to an active PCAN Channel when the bit rate used is unknown. When this mode is set, PCAN-Basic will try first to use the bit rate given as parameter in the initialization process; if the Channel has a different bit rate configured, then the new connection will use the configured bit rate and the initialization function will return a warning value, indicating that the used bit rate differs from the given one.

This is a so called “preset-only parameter", which means that it can only be set on not yet initialized Channels.

This parameter is useful, when an application wants to connect to a Channel, without knowing its bit rate.

Availability

It is available since PCAN-Basic version 4.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Important note Important

This parameter can only be configured on uninitialized Channels.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of the bit rate adapting mode is Off. This parameter has effect only at initialization time. It cannot be set after activating a Channel. The parameter returns to its default value after calling the Initialize method.

Initialization Status

Get: This parameter can be used on initialized or uninitialized Channels.

Set: This parameter can be used only on uninitialized Channels.

Example

The following code shows how to configure the bit rate adapting mode on a LAN Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Lan01;

if (Api.SetValue(channelUsed, PcanParameter.BitrateAdapting, ParameterValue.Activation.On) == PcanStatus.OK)
    Console.WriteLine($"The bit rate adapting mode has been activated successfully for {channelUsed}.");
else
    Console.WriteLine($"Error configuring the bit rate adapting mode on channel {channelUsed}.");
Dim channelUsed As PcanChannel = PcanChannel.Lan01

If Api.SetValue(channelUsed, PcanParameter.BitrateAdapting, ParameterValue.Activation.On) = PcanStatus.OK Then
    Console.WriteLine($"The bit rate adapting mode has been activated successfully for {channelUsed}.")
Else
    Console.WriteLine($"Error configuring the bit rate adapting mode on channel {channelUsed}.")
End If
PcanChannel channelUsed = PcanChannel::Lan01;

if (Api::SetValue(channelUsed, PcanParameter::BitrateAdapting, ParameterValue::Activation::On) == PcanStatus::OK)
    Console::WriteLine("The bit rate adapting mode has been activated successfully for {0}.", channelUsed);
else
    Console::WriteLine("Error configuring the bit rate adapting mode on channel {0}.", channelUsed);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Preset Parameters
Special Behaviors Parameters
Parameter Classification and Usage


InterframeDelay

This parameter allows the configuration of a delay, with microsecond resolution, between CAN frames being sent within a PCAN Channel. Other applications working with the same PCAN-Hardware (for instance, a PCAN-View) are not influenced when configuring this delay.

This parameter can be used by applications that want to increase the separation time of consecutive transmitted CAN frames.

Important note Important

This feature is only supported by FPGA based devices with a firmware version equal to or greater than 2.4.0.

Availability

It is available since PCAN-Basic version 4.2.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This is a numeric value in the range of [0...1023]) microseconds. If the value to be set is bigger than the resolution supported by the firmware, then the value is truncated.

Default Value

The default value of the delay is 0, which means that this feature is deactivated. After configuring a value bigger than 0, the delay will be used until it is expressly deactivated (set to 0), or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to set a 20 microseconds delay between CAN frames within a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    uint delay = 20;
    if (Api.SetValue(channelUsed, PcanParameter.InterframeDelay, delay) == PcanStatus.OK)
        Console.WriteLine($"A delay of {delay} microseconds between frames was configured for {channelUsed}.");
    else
        Console.WriteLine($"Error configuring a delay on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim delay As UInteger = 20
    If Api.SetValue(channelUsed, PcanParameter.InterframeDelay, delay) = PcanStatus.OK Then
        Console.WriteLine($"A delay of {delay} microseconds between frames was configured for {channelUsed}.")
    Else
        Console.WriteLine($"Error configuring a delay on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt32 delay = 0;
    if (Api::SetValue(channelUsed, PcanParameter::InterframeDelay, delay) == PcanStatus::OK)
        Console::WriteLine("A delay of {0} microseconds between frames was configured for {1}.", delay, channelUsed);
    else
        Console::WriteLine("Error configuring a delay on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Special Behaviors Parameters
Parameter Classification and Usage


HardResetStatus

This parameter allows changing the behavior of the method Reset. Normally, calling this method causes the receive and send message queues for a PCAN Channel to be emptied. The hardware being represented by the Channel is not reset. Activating this parameter, allows Reset to additionally perform a hardware reset after discarding the messages from the Channel’s queues.

Important note Important

Performing a hardware reset causes the CAN controller to go bus off for a while. This can disturb the CAN communication for a short time, generating error frames by other nodes, and avoiding sending/receiving messages.

Availability

Available since PCAN-Basic version 4.8.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of the hard reset feature is Off. After switching it On, the hard reset will be performed by each call of Reset and stays active until it is expressly deactivated, or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to activate the hard reset feature on a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.HardResetStatus, ParameterValue.Activation.On) == PcanStatus.OK)
        Console.WriteLine($"The hard reset feature was successfully activated for {channelUsed}.");
    else
        Console.WriteLine($"Error enabling the hard reset feature for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.HardResetStatus, ParameterValue.Activation.On) = PcanStatus.OK Then
        Console.WriteLine($"The hard reset feature was successfully activated for {channelUsed}.")
    Else
        Console.WriteLine($"Error enabling the hard reset feature for {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::HardResetStatus, ParameterValue::Activation::On) == PcanStatus::OK)
        Console::WriteLine("The hard reset feature was successfully activated for {0}.", channelUsed);
    else
        Console::WriteLine("Error enabling the hard reset feature for {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Special Behaviors Parameters
Parameter Classification and Usage


Data Reading and Flow Control Parameters

These parameters are intended to control what data is received over a PCAN Channel, how it is received, and how an application checks for incoming data. According to the amount of information that is transmitted within a CAN network, it will be reasonable to limit the data that an application accepts to facilitate working with it.

Receiving a large amount of data and having only to process a portion of it can lead to unnecessary memory usage and CPU load, slowing down the system. In the same way, the reaction time to read the incoming data is also the key to successful processing of the incoming information.

Parameters
Parameter | Description
ReceiveEvent | PCAN receive event handler parameter.
MessageFilter | PCAN message filter parameter.
ReceiveStatus | "Receive Status" parameter for incoming messages.
AllowStatusFrames | "Receive Status" parameter for Status frames.
AllowRtrFrames | "Receive Status" parameter for RTR frames.
AllowErrorFrames | "Receive Status" parameter for Error frames.
AllowEchoFrames | "Receive Status" parameter for Echo frames.
AcceptanceFilter11Bit | Acceptance filter over code and mask for 11-bit CAN IDs.
AcceptanceFilter29Bit | Acceptance filter over code and mask for 29-bit CAN IDs.
See Also

Reference

PcanParameter

Other Resources

Parameter Classification and Usage


ReceiveEvent

This parameter passes a thread synchronization event handle to the underlying API. This event is fired (its state is set to “signaled”) when CAN data is placed into the receive queue of a PCAN Channel.

Events are typically used when an application separates tasks into different threads. A thread, which waits for an event to occur, does not affect the normal execution of an application.

Note Note

The event is fired when its state is “unsignaled” and data is received and placed in the Channel's receive queue. After an application is notified about new data, it must read the receive queue until it is empty, and finally reset the event (if using a manual reset event).

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

Windows: This parameter is read/write. It can be configured and retrieved.

Linux: This parameter can only be read. It cannot be modified.

Important note Important

Attempting to set this parameter on Linux results in an error. Due to differences between the two platforms, the event object for use under Linux must be created and configured at initialization time by the API. To use ReceiveEvent under Linux, the event handle must simply be retrieved by calling GetValue with this parameter.

Possible Values

This parameter can be enabled/disabled by using numeric value in the range of [0...MaxValue]), that represents a pointer to a synchronization object.

Status | Value
Enabled | A 32-bit unsigned integer value representing an EventWaitHandle (AutoResetEvent or ManualResetEvent).
Disabled | The value 0.
Default Value

Windows: The default state is disabled (0).

Linux: The handle to a valid synchronization object.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set:

  • Windows: The PCAN Channel must be initialized before using this parameter.

  • Linux: This value is read-only.

Example

The following code shows how to configure a receive event for a USB Channel on Windows and Linux systems:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;
System.Threading.EventWaitHandle receiveEvent = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset);

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
    {

        if(Api.SetValue(channelUsed, PcanParameter.ReceiveEvent, (uint)receiveEvent.SafeWaitHandle.DangerousGetHandle().ToInt32()) == PcanStatus.OK)
        {
            Console.WriteLine($"A receive event was configured for {channelUsed}.");
        }
        else
        {
            Console.WriteLine($"Error configuring a receive event on channel {channelUsed}.");
        }
    }
    else
    {
        uint eventHandle;
        if(Api.GetValue(channelUsed, PcanParameter.ReceiveEvent, out eventHandle) == PcanStatus.OK)
        {
            receiveEvent.SafeWaitHandle.Close();
            receiveEvent.SafeWaitHandle = new Microsoft.Win32.SafeHandles.SafeWaitHandle(new IntPtr(eventHandle), false);
            Console.WriteLine($"A receive event was configured for {channelUsed}.");
        }
        else
        {
            Console.WriteLine($"Error retrieving the receive event on channel {channelUsed}.");
        }
    }

    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01
Dim receiveEvent As Threading.EventWaitHandle = New Threading.EventWaitHandle(False, Threading.EventResetMode.AutoReset)

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Runtime.InteropServices.RuntimeInformation.IsOSPlatform(Runtime.InteropServices.OSPlatform.Windows) Then

        If Api.SetValue(channelUsed, PcanParameter.ReceiveEvent, CUInt(receiveEvent.SafeWaitHandle.DangerousGetHandle().ToInt32())) = PcanStatus.OK Then
            Console.WriteLine($"A receive event was configured for {channelUsed}.")
        Else
            Console.WriteLine($"Error configuring a receive event on channel {channelUsed}.")
        End If
    Else
        Dim eventHandle As UInteger
        If Api.GetValue(channelUsed, PcanParameter.ReceiveEvent, eventHandle) = PcanStatus.OK Then
            receiveEvent.SafeWaitHandle.Close()
            receiveEvent.SafeWaitHandle = New Microsoft.Win32.SafeHandles.SafeWaitHandle(New IntPtr(eventHandle), False)
            Console.WriteLine($"A receive event was configured for {channelUsed}.")
        Else
            Console.WriteLine($"Error retrieving the receive event on channel {channelUsed}.")
        End If
    End If

    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;
System::Threading::EventWaitHandle^ receiveEvent = gcnew System::Threading::EventWaitHandle(false, System::Threading::EventResetMode::AutoReset);

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (System::Runtime::InteropServices::RuntimeInformation::IsOSPlatform(System::Runtime::InteropServices::OSPlatform::Windows))
    {

        if (Api::SetValue(channelUsed, PcanParameter::ReceiveEvent, (UInt32)receiveEvent->SafeWaitHandle->DangerousGetHandle().ToInt32()) == PcanStatus::OK)
        {
            Console::WriteLine("A receive event was configured for {0}.", channelUsed);
        }
        else
        {
            Console::WriteLine("Error configuring a receive event on channel {0}.", channelUsed);
        }
    }
    else
    {
        UInt32 eventHandle;
        if (Api::GetValue(channelUsed, PcanParameter::ReceiveEvent, eventHandle) == PcanStatus::OK)
        {
            receiveEvent->SafeWaitHandle->Close();
            receiveEvent->SafeWaitHandle = gcnew Microsoft::Win32::SafeHandles::SafeWaitHandle(IntPtr::IntPtr((Int32)eventHandle), false);
            Console::WriteLine("A receive event was configured for {0}.", channelUsed);
        }
        else
        {
            Console::WriteLine("Error retrieving the receive event on channel {0}.", channelUsed);
        }
    }

    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Reading and Flow Control Parameters
Parameter Classification and Usage
Synchronization primitives


MessageFilter

This parameter causes a modification of the acceptance filter of the CAN chip of a PCAN Channel, thus allowing it to receive messages or not. It can be used for switching the acceptance of messages temporarily, for example, to avoid receiving messages during a defined amount of time.

Caution note Caution

An internal hardware reset is carried out when the acceptance filter is modified. If other application is using the same device, its communication could be affected in some scenarios.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter accepts values of type ParameterValueFilter. In a setting operation, this parameter can be opened or closed. In a get operation, a value indicating that the filter was customized can also be retrieved.

Default Value

The default state of the filter is to receive all messages (Open). A PCAN Channel starts receiving messages immediately after it is initialized.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to close the acceptance filter of a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.MessageFilter, ParameterValue.Filter.Close) == PcanStatus.OK)
        Console.WriteLine($"The acceptance filter of {channelUsed} was successfully closed.");
    else
        Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.MessageFilter, ParameterValue.Filter.Close) = PcanStatus.OK Then
        Console.WriteLine($"The acceptance filter of {channelUsed} was successfully closed.")
    Else
        Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::MessageFilter, ParameterValue::Filter::Close) == PcanStatus::OK)
        Console::WriteLine("The acceptance filter of {0} was successfully closed.", channelUsed);
    else
        Console::WriteLine("Error configuring the acceptance filter on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Reading and Flow Control Parameters
Parameter Classification and Usage


ReceiveStatus

This parameter allows / disallows the reception of messages (Data, Status, and Error frames) of a PCAN Channel, regardless of the value of its acceptance filter. The acceptance filter of the PCAN Channel remains unchanged (other applications working with the same hardware will not be disturbed).

This is a so called “preset parameter", which means that it can be configured before a PCAN Channel is initialized. This allow the activation or deactivation of a parameter as fast as possible, avoiding in this way problems that can appear with sensitive operations.

This parameter is useful for applications that want to discard messages for a while, without having to take modifications on the message filter, avoiding in this form disturbances that may arise when an acceptance filter is changed.

Availability

It is available since PCAN-Basic version 1.1.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of the receive status is On. After switching it Off, the receiving status stays inactive until it is expressly reactivated, or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: This parameter can be used on initialized or uninitialized Channels.

Set: This parameter can be used on initialized or uninitialized Channels.

Example

The following code shows how to disable receiving messages on a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.SetValue(channelUsed, PcanParameter.ReceiveStatus, ParameterValue.Activation.Off) == PcanStatus.OK)
    Console.WriteLine($"The {channelUsed} was successfully configured to disallow incoming messages.");
else
    Console.WriteLine($"Error configuring the receive status on channel {channelUsed}.");
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.SetValue(channelUsed, PcanParameter.ReceiveStatus, ParameterValue.Activation.Off) = PcanStatus.OK Then
    Console.WriteLine($"The {channelUsed} was successfully configured to disallow incoming messages.")
Else
    Console.WriteLine($"Error configuring the receive status on channel {channelUsed}.")
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::SetValue(channelUsed, PcanParameter::ReceiveStatus, ParameterValue::Activation::Off) == PcanStatus::OK)
    Console::WriteLine("The {0} was successfully configured to disallow incoming messages.", channelUsed);
else
    Console::WriteLine("Error configuring the receive status on channel {0}.", channelUsed);
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Preset Parameters
Data Reading and Flow Control Parameters
Parameter Classification and Usage


AllowStatusFrames

This parameter allows / disallows the reception of Status frames within a PCAN-Channel. This parameter doesn’t affect the acceptance filter of a PCAN Channel. Furthermore, other applications working with the same hardware can individually configure the reception of Status frames.

Note Note

Disabling the ReceiveStatus parameter also suppresses the reception of Status frames.

Availability

It is available since PCAN-Basic version 4.2.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of receiving Status frames is On. After switching it Off, receiving Status frames stays inactive until it is expressly reactivated, or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to disable receiving Status frames on a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.AllowStatusFrames, ParameterValue.Activation.Off) == PcanStatus.OK)
        Console.WriteLine($"Receiving Status frames on {channelUsed} has been successfully disabled.");
    else
        Console.WriteLine($"Error configuring the reception of Status frames on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.AllowStatusFrames, ParameterValue.Activation.Off) = PcanStatus.OK Then
        Console.WriteLine($"Receiving Status frames on {channelUsed} has been successfully disabled.")
    Else
        Console.WriteLine($"Error configuring the reception of Status frames on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::AllowStatusFrames, ParameterValue::Activation::Off) == PcanStatus::OK)
        Console::WriteLine("Receiving Status frames on {0} has been successfully disabled.", channelUsed);
    else
        Console::WriteLine("Error configuring the reception of Status frames on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Reading and Flow Control Parameters
Parameter Classification and Usage


AllowRtrFrames

This parameter allows / disallows the reception of RTR frames within a PCAN Channel. This parameter doesn’t affect the acceptance filter of a PCAN Channel. Furthermore, other applications working with the same hardware can individually configure the reception of RTR frames.

Note Note

Disabling the ReceiveStatus parameter also suppresses the reception of RTR frames.

Availability

It is available since PCAN-Basic version 4.2.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of receiving RTR frames is On. After switching it Off, receiving RTR frames stays inactive until it is expressly reactivated, or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to disable receiving RTR frames on a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.AllowRtrFrames, ParameterValue.Activation.Off) == PcanStatus.OK)
        Console.WriteLine($"Receiving RTR frames on {channelUsed} has been successfully disabled.");
    else
        Console.WriteLine($"Error configuring the reception of RTR frames on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.AllowRtrFrames, ParameterValue.Activation.Off) = PcanStatus.OK Then
        Console.WriteLine($"Receiving RTR frames on {channelUsed} has been successfully disabled.")
    Else
        Console.WriteLine($"Error configuring the reception of RTR frames on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::AllowRtrFrames, ParameterValue::Activation::Off) == PcanStatus::OK)
        Console::WriteLine("Receiving RTR frames on {0} has been successfully disabled.", channelUsed);
    else
        Console::WriteLine("Error configuring the reception of RTR frames on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Reading and Flow Control Parameters
Parameter Classification and Usage


AllowErrorFrames

This parameter allows / disallows the reception of CAN Error frames within a PCAN Channel. This parameter doesn’t affect the acceptance filter of a PCAN Channel. Furthermore, other applications working with the same hardware can individually configure the reception of Error frames.

Note Note

Disabling the ReceiveStatus parameter also suppresses the reception of Error frames.

Availability

It is available since PCAN-Basic version 4.2.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of receiving Error messages is Off. After switching it On, receiving Error frames stays active until it is expressly deactivated, or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to enable receiving Error frames on a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.AllowErrorFrames, ParameterValue.Activation.On) == PcanStatus.OK)
        Console.WriteLine($"Receiving Error frames on {channelUsed} has been successfully enabled.");
    else
        Console.WriteLine($"Error configuring the reception of Error frames on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.AllowErrorFrames, ParameterValue.Activation.On) = PcanStatus.OK Then
        Console.WriteLine($"Receiving Error frames on {channelUsed} has been successfully enabled.")
    Else
        Console.WriteLine($"Error configuring the reception of Error frames on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::AllowErrorFrames, ParameterValue::Activation::On) == PcanStatus::OK)
        Console::WriteLine("Receiving Error frames on {0} has been successfully enabled.", channelUsed);
    else
        Console::WriteLine("Error configuring the reception of Error frames on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Reading and Flow Control Parameters
Parameter Classification and Usage


AllowEchoFrames

This parameter allows / disallows the reception of Echo frames within a PCAN Channel, this is, the reception of frames sent by itself. This parameter doesn’t affect the acceptance filter of the PCAN Channel. Furthermore, other applications working with the same hardware can individually configure the reception of Echo frames.

Note Note

Disabling the ReceiveStatus parameter also suppresses the reception of Echo frames.

Availability

It is available since PCAN-Basic version 4.6.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Important note Important

Requires a device driver version equal to or greater than 4.3.0.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default state of receiving Echo frames is Off. After switching it On, receiving Echo frames stays active until it is expressly deactivated, or the Channel is disconnected, i.e., using the Uninitialize method.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to enable receiving Echo frames on a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.AllowEchoFrames, ParameterValue.Activation.On) == PcanStatus.OK)
        Console.WriteLine($"Receiving Echo frames on {channelUsed} has been successfully enabled.");
    else
        Console.WriteLine($"Error configuring the reception of Echo frames on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.AllowEchoFrames, ParameterValue.Activation.On) = PcanStatus.OK Then
        Console.WriteLine($"Receiving Echo frames on {channelUsed} has been successfully enabled.")
    Else
        Console.WriteLine($"Error configuring the reception of Echo frames on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::AllowEchoFrames, ParameterValue::Activation::On) == PcanStatus::OK)
        Console::WriteLine("Receiving Echo frames on {0} has been successfully enabled.", channelUsed);
    else
        Console::WriteLine("Error configuring the reception of Echo frames on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Reading and Flow Control Parameters
Parameter Classification and Usage


AcceptanceFilter11Bit

This parameter restricts the reception of messages from a PCAN Channel by modifying the acceptance filter of its CAN chip, using specific 11-bit code and mask values.

It allows the configuration of complex filter patterns, and it is intended for users with extended CAN knowledge. Note that the calculation of mask and code patterns is not a trivial matter. For most applications the use of the FilterMessages for setting message reception ranges is more adequate.

Note Note

  • The acceptance code and mask are coded together in a 64-bit value, each of them using 4 bytes. The acceptance code is stored at the most significant bytes. Bitwise and shifting operations are needed to code and decode the values into and from a 64-bit unsigned integer variable.

  • To set an acceptance code and mask denoting 29-bit CAN IDs, the parameter AcceptanceFilter29Bit must be used instead.

  • The SJA1000 CAN controller has only one acceptance filter for both, standard (11-bit) and extended (64-bit) IDs. When doing settings for 11-bit IDs, the acceptance mask and code are internally shifted to the left as adaptation measure, which also causes possible reception of unwanted messages. For this reason, is also not advisable to mix 11-bits and 29-bits filters.

  • An internal hardware reset is done each time the acceptance filter is modified. If other application is using the same device, its communication could be affected in some scenarios.

For more information on the SJA1000 CAN controller acceptance filter, see Philips Data Sheet SJA1000 Stand-alone CAN-controller.

Availability

It is available since PCAN-Basic version 4.2.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This is a numeric value with a quad-word resolution. Since it contains two double-word values representing the acceptance code and mask, the maximum value range accepted for this parameter is given by the limits of their internal values, which is a range between [0...16838]. This means, the maximum value of this parameter as 64-bit value is 70364449226751 (hexadecimal 00003FFF_00003FFFh).

Default Value

The default state of the receive filter is to receive all messages (Open). This represents a default acceptance code of 0h and an acceptance mask of 7FFh (00000000_000007FFh).

Note Note

An automatic filter reset is done before registering the desired code and mask, if the filter state before using this parameter was Open.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to modify the acceptance filter of a USB Channel using 11-bit code and mask values:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    ulong acceptanceFilter = 0x500;
    if (Api.SetValue(channelUsed, PcanParameter.AcceptanceFilter11Bit, acceptanceFilter) == PcanStatus.OK)
        Console.WriteLine($"The acceptance filter for {channelUsed} has been successfully configured to accept the standard IDs 0x100, 0x400, and 0x500.");
    else
        Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim acceptanceFilter As ULong = &H500
    If Api.SetValue(channelUsed, PcanParameter.AcceptanceFilter11Bit, acceptanceFilter) = PcanStatus.OK Then
        Console.WriteLine($"The acceptance filter for {channelUsed} has been successfully configured to accept the standard IDs 0x100, 0x400, and 0x500.")
    Else
        Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt64 acceptanceFilter = 0x500;
    if (Api::SetValue(channelUsed, PcanParameter::AcceptanceFilter11Bit, acceptanceFilter) == PcanStatus::OK)
        Console::WriteLine("The acceptance filter for {0} has been successfully configured to accept the standard IDs 0x100, 0x400, and 0x500.", channelUsed);
    else
        Console::WriteLine("Error configuring the acceptance filter on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Reading and Flow Control Parameters
Parameter Classification and Usage
Philips Data Sheet SJA1000 Stand-alone CAN-controller


AcceptanceFilter29Bit

This parameter restricts the reception of messages from a PCAN Channel by modifying the acceptance filter of its CAN chip, using specific 29-bit code and mask values.

It allows the configuration of complex filter patterns, and it is intended for users with extended CAN knowledge. Note that the calculation of mask and code patterns is not a trivial matter. For most applications the use of the FilterMessages for setting message reception ranges is more adequate.

Note Note

  • The acceptance code and mask are coded together in a 64-bit value, each of them using 4 bytes. The acceptance code is stored at the most significant bytes. Bitwise and shifting operations are needed to code and decode the values into and from a 64-bit unsigned integer variable.

  • To set an acceptance code and mask denoting 11-bit CAN IDs, the parameter AcceptanceFilter11Bit must be used instead.

  • The SJA1000 CAN controller has only one acceptance filter for both, standard (11-bit) and extended (64-bit) IDs. When doing settings for 11-bit IDs, the acceptance mask and code are internally shifted to the left as adaptation measure, which also causes possible reception of unwanted messages. For this reason, is also not advisable to mix 11-bits and 29-bits filters.

  • An internal hardware reset is done each time the acceptance filter is modified. If other application is using the same device, its communication could be affected in some scenarios.

For more information on the SJA1000 CAN controller acceptance filter, see Philips Data Sheet SJA1000 Stand-alone CAN-controller.

Availability

It is available since PCAN-Basic version 4.2.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This is a numeric value with a quad-word resolution. Since it contains two double-word values representing the acceptance code and mask, the maximum value range accepted for this parameter is given by the limits of their internal values, which is a range between [0...4294967295]. This means, the maximum value of this parameter as 64-bit value is 2305843005455597567 (hexadecimal 1FFFFFFF_1FFFFFFFh).

Default Value

The default state of the receive filter is to receive all messages (Open). This represents a default acceptance code of 0h and an acceptance mask of 1FFFFFFFh (00000000_1FFFFFFFh).

Note Note

An automatic filter reset is done before registering the desired code and mask, if the filter state before using this parameter was Open.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to modify the acceptance filter of a USB Channel using 29-bit code and mask values:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    ulong acceptanceFilter = 0x00001000_00000500;
    if (Api.SetValue(channelUsed, PcanParameter.AcceptanceFilter29Bit, acceptanceFilter) == PcanStatus.OK)
        Console.WriteLine($"The acceptance filter for {channelUsed} has been successfully configured to accept the extended IDs 0x1100, 0x1400, and 0x1500.");
    else
        Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim acceptanceFilter As ULong = &H00001000_00000500
    If Api.SetValue(channelUsed, PcanParameter.AcceptanceFilter29Bit, acceptanceFilter) = PcanStatus.OK Then
        Console.WriteLine($"The acceptance filter for {channelUsed} has been successfully configured to accept the extended IDs 0x1100, 0x1400, and 0x1500.")
    Else
        Console.WriteLine($"Error configuring the acceptance filter on channel {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt64 acceptanceFilter = 0x00001000'00000500;
    if (Api::SetValue(channelUsed, PcanParameter::AcceptanceFilter29Bit, acceptanceFilter) == PcanStatus::OK)
        Console::WriteLine("The acceptance filter for {0} has been successfully configured to accept the extended IDs 0x1100, 0x1400, and 0x1500.", channelUsed);
    else
        Console::WriteLine("Error configuring the acceptance filter on channel {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Reading and Flow Control Parameters
Parameter Classification and Usage
Philips Data Sheet SJA1000 Stand-alone CAN-controller


Logging Parameters

These parameters are intended to support the developing phase of a PCAN-Basic project by helping with debug operations. Using the logging system can help finding logic problems within the use of the API, detecting problems with the data being sent or received, checking parameter data, commands order, etc.

It is also possible to activate / deactivate and configure the logging functionality without having to change the code of an application, which allows later debugging sessions after an application is already released. For more information please see Activate debug-logging over Windows Registry

The logging functionality is not tied to a PCAN Channel but to the use of the PCAN-Basic library itself. This implies three important points:

  • The PCAN Channel to use in any GetValue / SetValue must be None, if any logging parameter is used. Any other value will cause the function to fail.

  • The data logged corresponds to the API calls issued by the process that has loaded the PCAN-Basic library.

  • It is not possible to start a debug session for different threads of the same application.

Parameters
Parameter | Description
LogLocation | Directory path for log files.
LogStatus | Debug-Log activation status.
LogConfigure | Configuration of the debugged information (see ParameterValueLog).
LogText | Custom insertion of text into the log file.
See Also

Reference

PcanParameter

Other Resources

Parameter Classification and Usage


LogLocation

This parameter is used to set the folder on a computer in where a log file generated by the PCAN-Basic will be stored, and to start a debug session.

Note Note

Setting this parameter starts recording debug information automatically if the logging functionality was inactive. It is not needed to call SetValue with the LogStatus parameter afterwards to activate a debug session.

If a debug session is running (a log file is being written), LogLocation instructs the API to close the current log file, create another one in the new location, and continue debugging using that new file. To keep track of the log files used, the path to the new log file is written in the old one, and the path to the old log file is written in the new one.

Note Note

The name of a log file cannot be changed. It is always PCANBasic.log.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • None: Logging parameters are used globally, i.e., they are not tied to a specific PCAN Channel, but to a specific process.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This value is a string containing a fully qualified and valid path to an existing directory on the executing computer. To use the default path (calling process path) an empty string must be set.

Kind of Path | Value
Custom path | A valid directory string (see Files and Paths).
Default path (calling process folder) | An empty string.
Default Value

The default value is the path to the calling process folder.

Initialization Status

Get: Not relevant since this parameter is not channel dependent.

Set: Not relevant since this parameter is not channel dependent.

Example

The following code shows how to set the location of a log file and to start a debug session:

C#
VB
C++
Copy
try
{
    System.IO.DirectoryInfo info = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() + "Logging_" + DateTime.Now.Date.ToString("yyyy.mm.dd"));
    if(Api.SetValue(PcanChannel.None, PcanParameter.LogLocation, info.FullName) == PcanStatus.OK)
    {
        Console.WriteLine($"Logging is active. The log file is located at:\n{info.FullName}");
    }
    else
    {
        Console.WriteLine("Error configuring the location of the log file.");
    }
}
catch(Exception ex)
{
    Console.WriteLine($"Error creating a folder: {ex.Message}.");
}
Try
    Dim info As System.IO.DirectoryInfo = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() & "Logging_" & Date.Now.[Date].ToString("yyyy.mm.dd"))
    If Api.SetValue(PcanChannel.None, PcanParameter.LogLocation, info.FullName) = PcanStatus.OK Then
        Console.WriteLine($"Logging is active. The log file is located at: {info.FullName}")
    Else
        Console.WriteLine("Error configuring the location of the log file.")
    End If
Catch ex As Exception
    Console.WriteLine($"Error creating a folder: {ex.Message}.")
End Try
try
{
    System::IO::DirectoryInfo^ info = System::IO::Directory::CreateDirectory(System::IO::Path::GetTempPath() + "Logging_" + DateTime::Now.Date.ToString("yyyy.mm.dd"));
    if (Api::SetValue(PcanChannel::None, PcanParameter::LogLocation, info->FullName) == PcanStatus::OK)
    {
        Console::WriteLine("Logging is active. The log file is located at:\n{0}", info->FullName);
    }
    else
    {
        Console::WriteLine("Error configuring the location of the log file.");
    }
}
catch (Exception^ ex)
{
    Console::WriteLine("Error creating a folder: {0}.", ex->Message);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Logging Parameters
Parameter Classification and Usage
Files and Paths


LogStatus

This parameter allows to control the activity status of a debug session within the PCAN-Basic API.

Note Note

If the logging status is set to On before having configured a destination path for the log file or without having configured the information to be logged, then the log process will start with its default values, which equates to the log file being placed in the folder where the calling process is located, logging only any internal exception.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • None: Logging parameters are used globally, i.e., they are not tied to a specific PCAN Channel, but to a specific process.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default logging status is Off. After switching it On, logging stays active until it is expressly deactivated.

Initialization Status

Get: Not relevant since this parameter is not channel dependent.

Set: Not relevant since this parameter is not channel dependent.

Example

The following code shows how to deactivate a debug session:

C#
VB
C++
Copy
if (Api.SetValue(PcanChannel.None, PcanParameter.LogStatus, ParameterValue.Activation.Off) == PcanStatus.OK)
    Console.WriteLine("The logging session was successfully disabled.");
else
    Console.WriteLine("Error disabling a log session.");
If Api.SetValue(PcanChannel.None, PcanParameter.LogStatus, ParameterValue.Activation.Off) = PcanStatus.OK Then
    Console.WriteLine("The logging session was successfully disabled.")
Else
    Console.WriteLine("Error disabling a log session.")
End If
if (Api::SetValue(PcanChannel::None, PcanParameter::LogStatus, ParameterValue::Activation::Off) == PcanStatus::OK)
    Console::WriteLine("The logging session was successfully disabled.");
else
    Console::WriteLine("Error disabling a log session.");
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Logging Parameters
Parameter Classification and Usage


LogConfigure

This parameter is used to configure the debug information to be included in the log file generated in a debug session within the PCAN-Basic API. It can be used when only specific debug information is desired.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • None: Logging parameters are used globally, i.e., they are not tied to a specific PCAN Channel, but to a specific process.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

The information to log is configured as a numeric “flag” value, that matches the fields defined within the type ParameterValueLog.

Default Value

The default value of this parameter is to log only internal exceptions (Default) that are generated in the native PCAN-Basic library.

Initialization Status

Get: Not relevant since this parameter is not channel dependent.

Set: Not relevant since this parameter is not channel dependent.

Example

The following code shows how to configure the information to be logged in a debug session:

C#
VB
C++
Copy
if (Api.SetValue(PcanChannel.None, PcanParameter.LogConfigure, ParameterValue.Log.FunctionEntries | ParameterValue.Log.FunctionExits) == PcanStatus.OK)
    Console.WriteLine("The log has been successfully configured to record information on entering and leaving API calls.");
else
    Console.WriteLine("Error configuring a log session.");
If Api.SetValue(PcanChannel.None, PcanParameter.LogConfigure, ParameterValue.Log.FunctionEntries Or ParameterValue.Log.FunctionExits) = PcanStatus.OK Then
    Console.WriteLine("The log has been successfully configured to record information on entering and leaving API calls.")
Else
    Console.WriteLine("Error configuring a log session.")
End If
if (Api::SetValue(PcanChannel::None, PcanParameter::LogConfigure, ParameterValue::Log::FunctionEntries | ParameterValue::Log::FunctionExits) == PcanStatus::OK)
    Console::WriteLine("The log has been successfully configured to record information on entering and leaving API calls.");
else
    Console::WriteLine("Error configuring a log session.");
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Logging Parameters
Parameter Classification and Usage


LogText

This parameter allows the insertion of custom text into the log file generated in a debug session.

Note Note

Using this parameter starts recording debug information automatically if the logging functionality was inactive. It is not needed to call SetValue with the LogStatus parameter afterwards to activate a debug session.

Availability

It is available since PCAN-Basic version 1.0.0.

Supported By

  • None: Logging parameters are used globally, i.e., they are not tied to a specific PCAN Channel, but to a specific process.

Access Mode

This parameter is write-only. It can only be written.

Possible Values

This value is a string containing the data to be inserted into the log file. There is no limit to the length of the string, but it is recommended that it not exceed 256 bytes (inclusive null-termination).

Default Value

Does not apply. This is a value that can only be written.

Initialization Status

Set: Not relevant since this parameter is not channel dependent.

Example

The following code shows how to insert custom information in a log file:

C#
VB
C++
Copy
if (Api.SetValue(PcanChannel.None, PcanParameter.LogText, "This is the beginning of a debug session") == PcanStatus.OK)
    Console.WriteLine("Custom information has been successfully written to the log file.");
else
    Console.WriteLine("Error writing into the log file.");
If Api.SetValue(PcanChannel.None, PcanParameter.LogText, "This is the beginning of a debug session") = PcanStatus.OK Then
    Console.WriteLine("Custom information has been successfully written to the log file.")
Else
    Console.WriteLine("Error writing into the log file.")
End If
if (Api::SetValue(PcanChannel::None, PcanParameter::LogText, "This is the beginning of a debug session") == PcanStatus::OK)
    Console::WriteLine("Custom information has been successfully written to the log file.");
else
    Console::WriteLine("Error writing into the log file.");
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Logging Parameters
Parameter Classification and Usage


Data Tracing Parameters

These parameters are intended to minimize the developing time and cost of CAN applications using the PCAN-Basic API, by allowing the recording and storing of all CAN communication in an ASCII formatted file that can be loaded by any text editor.

Since the trace formats are officially used by PEAK-System applications, there are already several tools that can load and process those trace files, further minimizing the investment in own software programming. For example, the information recorded can be inspected using the software PCAN-Explorer and can even be played back for simulation purposes.

Consider that the trace functionality is available for each PCAN Channel. This implies three important points:

  • The PCAN Channel must be first initialized before a trace session can be started.

  • A trace session can be started for each initialized Channel within an application, simultaneously.

  • The data traced corresponds to the data successfully transmitted through a PCAN Channel, using the methods Read and Write.

    Important note Important

    For messages to be written in the trace file, the receive queue must be read actively, even if the application is only sending. This is because written messages need to be acknowledged in order to be teated as "successfully sent".

Parameters
Parameter | Description
TraceLocation | Directory path for PCAN trace files.
TraceStatus | PCAN tracing activation status.
TraceSize | Configuration of the trace file storing modes (see ParameterValueTrace).
TraceConfigure | Configuration of the maximum file size of a PCAN trace.
See Also

Reference

PcanParameter

Other Resources

Parameter Classification and Usage


TraceLocation

This parameter is used to set the folder on a computer in where the PCAN-Trace files will be stored.

If a session is running (a PCAN-Trace file is being written), TraceLocation instructs the API to close the current PCAN-Trace file and to start the process again using the new location.

Note Note

The name of the trace file cannot be freely specified. The base name of the trace file is always the name of the PCAN Channel being used, as specified in the native PCAN-Basic library (PCAN_USBBUS1.trc, for example). It is only possible to enhance the name with the date and/or time of creation of the file.

Availability

It is available since PCAN-Basic version 1.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This value is a string containing a fully qualified and valid path to an existing directory on the executing computer. To use the default path (calling process path) an empty string must be set.

Kind of Path | Value
Custom path | A valid directory string (see Files and Paths).
Default path (calling process folder) | An empty string.
Default Value

The default value is the path to the calling process folder.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to set the location of the trace file for a USB Channel:

C#
VB
C++
Copy
try
{
    PcanChannel channelUsed = PcanChannel.Usb01;

    if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
    {
        System.IO.DirectoryInfo info = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() + "Tracing_" + DateTime.Now.Date.ToString("yyyy.mm.dd"));
        if (Api.SetValue(channelUsed, PcanParameter.TraceLocation, info.FullName) == PcanStatus.OK)
        {
            Console.WriteLine($"The folder for trace files was successfully set to:\n{info.FullName}");
        }
        else
        {
            Console.WriteLine("Error configuring the location of the trace files.");
        }
        Api.Uninitialize(channelUsed);
    }
}
catch (Exception ex)
{
    Console.WriteLine($"Error creating a folder: {ex.Message}.");
}
Try
    Dim channelUsed As PcanChannel = PcanChannel.Usb01

    If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
        Dim info As System.IO.DirectoryInfo = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() & "Tracing_" & Date.Now.[Date].ToString("yyyy.mm.dd"))
        If Api.SetValue(channelUsed, PcanParameter.TraceLocation, info.FullName) = PcanStatus.OK Then
            Console.WriteLine($"The folder for trace files was successfully set to: {info.FullName}")
        Else
            Console.WriteLine("Error configuring the location of the trace files.")
        End If
        Api.Uninitialize(channelUsed)
    End If
Catch ex As Exception
    Console.WriteLine($"Error creating a folder: {ex.Message}.")
End Try
try
{
    PcanChannel channelUsed = PcanChannel::Usb01;

    if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
    {
        System::IO::DirectoryInfo^ info = System::IO::Directory::CreateDirectory(System::IO::Path::GetTempPath() + "Tracing_" + DateTime::Now.Date.ToString("yyyy.mm.dd"));
        if (Api::SetValue(channelUsed, PcanParameter::TraceLocation, info->FullName) == PcanStatus::OK)
        {
            Console::WriteLine("The folder for trace files was successfully set to:\n{0}", info->FullName);
        }
        else
        {
            Console::WriteLine("Error configuring the location of the trace files.");
        }
        Api::Uninitialize(channelUsed);
    }
}
catch (Exception^ ex)
{
    Console::WriteLine("Error creating a folder: {0}.", ex->Message);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Tracing Parameters
Parameter Classification and Usage
Files and Paths


TraceStatus

This parameter allows to control the activity status of a trace session within the PCAN-Basic API.

Note Note

If the tracing status is set to On before having configured a destination path for the trace files or without having configured the tracing mode, then the trace process will start with its default values, that is:

  • The PCAN-Trace file will be placed in the folder where the calling process is located.

  • The file name to use is the name of the used PCAN Channel as specified in the native PCAN-Basic library (PCAN_USBBUS1.trc, for example).

  • Already existing files will not be overwritten, i.e., starting the trace process will fail if the file to create already exists.

  • The API will create one PCAN-Trace file and will fill it with data until the it reaches a size of 10 megabytes.

Important note Important

For messages to be written in the trace file, the receive queue must be read actively, even if the application is only sending. This is because written messages need to be acknowledged in order to be teated as "successfully sent".

Availability

It is available since PCAN-Basic version 1.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter can be activated or deactivated. Accepts values of type ParameterValueActivation.

Default Value

The default value of tracing is Off. After switching it On, the trace process remains active until one of these cases occurs:

  • The tracing process is expressly deactivated.

  • The PCAN Channel used is disconnected, i.e., using the Uninitialize(PcanChannel) method.

  • The configuration of the tracing session instructs the API to stop tracing (e.g., the maximum size for a trace file is reached).

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to physically identify a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.TraceStatus, ParameterValue.Activation.On) == PcanStatus.OK)
        Console.WriteLine($"The tracing process was successfully activated for {channelUsed}.");
    else
        Console.WriteLine($"Error enabling tracing for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.TraceStatus, ParameterValue.Activation.On) = PcanStatus.OK Then
        Console.WriteLine($"The tracing process was successfully activated for {channelUsed}.")
    Else
        Console.WriteLine($"Error enabling tracing for {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::TraceStatus, ParameterValue::Activation::On) == PcanStatus::OK)
        Console::WriteLine("The tracing process was successfully activated for {0}.", channelUsed);
    else
        Console::WriteLine("Error enabling tracing for {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Tracing Parameters
Parameter Classification and Usage


TraceConfigure

This parameter is used to configure the trace process and the file generated in a trace session.

Note Note

Trying to configure a trace process will fail if tracing is already active.

Availability

It is available since PCAN-Basic version 1.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

The trace process is configured as a numeric “flag” value, that matches the fields defined within the type ParameterValueTrace.

Default Value

The default value of this parameter is SingleFile, which means a single file is created and filled out until the maximum configured file size is reached.

Note Note

The base name of the trace file is always the name of the PCAN Channel being used, as specified in the native PCAN-Basic library (PCAN_USBBUS1.trc, for example).

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to configure the tracing process for a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    if (Api.SetValue(channelUsed, PcanParameter.TraceConfigure, ParameterValue.Trace.MultiFiles) == PcanStatus.OK)
        Console.WriteLine($"The tracing process was successfully configured for {channelUsed} to generate multiple files.");
    else
        Console.WriteLine($"Error configuring tracing for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    If Api.SetValue(channelUsed, PcanParameter.TraceConfigure, ParameterValue.Trace.MultiFiles) = PcanStatus.OK Then
        Console.WriteLine($"The tracing process was successfully configured for {channelUsed} to generate multiple files.")
    Else
        Console.WriteLine($"Error configuring tracing for {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    if (Api::SetValue(channelUsed, PcanParameter::TraceConfigure, ParameterValue::Trace::MultiFiles) == PcanStatus::OK)
        Console::WriteLine("The tracing process was successfully configured for {0} to generate multiple files.", channelUsed);
    else
        Console::WriteLine("Error configuring tracing for {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Tracing Parameters
Parameter Classification and Usage


TraceSize

This parameter is used to set the maximum size in megabytes that a single PCAN-Trace file can have.

Note Note

Trying to configure a trace process will fail if tracing is already active.

Availability

It is available since PCAN-Basic version 1.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

  • PCAN-PCI: Channels Pci01 to Pci16

  • PCAN-LAN: Channels Lan01 to Lan16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

A numeric value representing the number of megabytes a file can store. To use the default size, 10 megabytes, the value of 0 must be set.

Kind of Size | Value
Custom size | A value in the range [1...100].
Default size (10 megabytes) | A value of 0.
Default Value

The default size is 10 Megabytes. This allows to record about 166.000~ CAN messages (Standard frames, with 8 data bytes).

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to configure the size of trace files for a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    uint size = 50;
    if (Api.SetValue(channelUsed, PcanParameter.TraceSize, size) == PcanStatus.OK)
        Console.WriteLine($"The size for traces files generated with {channelUsed} was set to {size} megabytes.");
    else
        Console.WriteLine($"Error configuring the trace file size for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim size As UInteger = 50
    If Api.SetValue(channelUsed, PcanParameter.TraceSize, size) = PcanStatus.OK Then
        Console.WriteLine($"The size for traces files generated with {channelUsed} was set to {size} megabytes.")
    Else
        Console.WriteLine($"Error configuring the trace file size for {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt32 size = 50;
    if (Api::SetValue(channelUsed, PcanParameter::TraceSize, size) == PcanStatus::OK)
        Console::WriteLine("The size for traces files generated with {0} was set to {1} megabytes.", channelUsed, size);
    else
        Console::WriteLine("Error configuring the trace file size for {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Data Tracing Parameters
Parameter Classification and Usage


Electronic Circuits Parameters

These parameters are intended to condense features. Some CAN devices are equipped with pins for digital and analog signals, that make it possible to provide electronic circuits with I/O functionality. Instead of offering separate APIs for this, the I/O features are accessible as parameters, over the GetValue / SetValue methods.

At the time of writing this documentation, only the PCAN-Chip USB module offers I/O capabilities in form of 5 digital input pins, that also can be configured as digital outputs, and one analog input pin.

Parameters
Parameter | Description
IoDigitalConfiguration | Activation of digital pins as outputs.
IoDigitalValue | Multiple setting of digital pin values.
IoDigitalSet | Selective setting of digital pin values to "high".
IoDigitalClear | Selective setting of digital pin values to "low".
IoAnalogValue | Value reading of a single analog pin.
See Also

Reference

PcanParameter

Other Resources

Parameter Classification and Usage


IoDigitalConfiguration

This parameter is used to configure the output mode of all digital Input / Output Pins available on a device. It allows the configuration of up to 32 Pins, as a bit mask value.

Note Note

At the time of writing this documentation only PCAN-Chip USB based devices, with a firmware version equal to or greater than 3.3.0, support the configuration of a maximum of 5 digital Pins. For this reason, all other (unused) bits are automatically discarded from the bit mask value.

No error is generated by setting a bit for a nonexistent Pin.

Availability

It is available since PCAN-Basic version 4.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter has a resolution of a double-word (range [0...MaxValue]). It is a bit mask, in which every bit represents a digital input. Bit0, the least significant bit, corresponds to Pin0; Bit1 corresponds to Pin1, and so on until Pin31.

Each digital input Pin of the device can be set as digital output.

Bit value | Description
0 | The Pin works as digital input.
1 | The Pin works as digital input and digital output.
Default Value

The default value for each Pin (and so for the whole mask) is 0, meaning that all Pins are configured as digital input only (no digital outputs active).

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to configure all the digital Pins of a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    uint pinMask = 0x1F;
    if (Api.SetValue(channelUsed, PcanParameter.IoDigitalConfiguration, pinMask) == PcanStatus.OK)
        Console.WriteLine($"All digital Pins (0 to 4) of {channelUsed} were successfully configured as digital outputs.");
    else
        Console.WriteLine($"Error configuring digital Pins for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim pinMask As UInteger = &H1F
    If Api.SetValue(channelUsed, PcanParameter.IoDigitalConfiguration, pinMask) = PcanStatus.OK Then
        Console.WriteLine($"All digital Pins (0 to 4) of {channelUsed} were successfully configured as digital outputs.")
    Else
        Console.WriteLine($"Error configuring digital Pins for {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt32 pinMask = 0x1F;
    if (Api::SetValue(channelUsed, PcanParameter::IoDigitalConfiguration, pinMask) == PcanStatus::OK)
        Console::WriteLine("All digital Pins (0 to 4) of {0} were successfully configured as digital outputs.", channelUsed);
    else
        Console::WriteLine("Error configuring digital Pins for {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Electronic Circuits Parameters
Parameter Classification and Usage


IoDigitalValue

This parameter is used to set the output values represented by the digital Pins available on a device, as a bit mask value. Unlike IoDigitalSet and IoDigitalClear, this operation applies to all Pins, i.e., each available Pin is set to one of the two possible states.

Note Note

The bit mask allows setting the value of 32 Pins, though, at the time of writing this documentation only PCAN-Chip USB based devices, with a firmware version equal to or greater than 3.3.0, support the configuration of a maximum of 5 digital Pins. For this reason, all other (not used) bits are automatically discarded from the bit mask value.

No error is generated by setting a bit for a nonexistent Pin.

Availability

It is available since PCAN-Basic version 4.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

This parameter has a resolution of a double-word (range [0...MaxValue]). It is a bit mask, in which every bit represents the value for a digital output Pin. Bit0, the least significant bit, corresponds to the value of Pin0; Bit1 corresponds to the value of Pin1, and so on until Pin31.

Bit value | Description
0 | The digital pin value is “low”.
1 | The digital pin value is “high”.
Default Value

The default value for each Pin (and for the whole mask) is 0, meaning that the values of all digital output Pins are set to “low”.

Initialization Status

Get: The PCAN Channel must be initialized before using this parameter.

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to set the value of all digital outputs of a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    uint pinMask = 0x11;
    if (Api.SetValue(channelUsed, PcanParameter.IoDigitalValue, pinMask) == PcanStatus.OK)
    {
        Console.WriteLine($"Pin0 and Pin4 of {channelUsed} were successfully set to 'high'.");
        Console.WriteLine($"Pin1, Pin2, and Pin3 of {channelUsed} were successfully set to 'low'. ");
    }
    else
        Console.WriteLine($"Error configuring digital Pin states for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim pinMask As UInteger = &H11
    If Api.SetValue(channelUsed, PcanParameter.IoDigitalValue, pinMask) = PcanStatus.OK Then
        Console.WriteLine($"Pin0 and Pin4 of {channelUsed} were successfully set to 'high'.")
        Console.WriteLine($"Pin1, Pin2, and Pin3 of {channelUsed} were successfully set to 'low'. ")
    Else
        Console.WriteLine($"Error configuring digital Pin states for {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt32 pinMask = 0x11;
    if (Api::SetValue(channelUsed, PcanParameter::IoDigitalValue, pinMask) == PcanStatus::OK)
    {
        Console::WriteLine("Pin0 and Pin4 of {0} were successfully set to 'high'.", channelUsed);
        Console::WriteLine("Pin1, Pin2, and Pin3 of {0} were successfully set to 'low'. ", channelUsed);
    }
    else
        Console::WriteLine("Error configuring digital Pin states for {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Electronic Circuits Parameters
Parameter Classification and Usage


IoDigitalSet

This parameter is used to configure the value of selected digital output Pins to “high” within a device, using a bit mask value. Unlike IoDigitalValue, only needed Pins are set to “high”; unwanted ones are not touched, i.e., they are not re-configured.

Note Note

At the time of writing this documentation only PCAN-Chip USB based devices, with a firmware version equal to or greater than 3.3.0, support the configuration of a maximum of 5 digital Pins. For this reason, all other (not used) bits are automatically discarded from the bit mask value.

No error is generated by setting a bit for a nonexistent Pin.

Availability

It is available since PCAN-Basic version 4.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

Access Mode

This parameter is write-only. It can only be written.

Possible Values

This parameter has a resolution of a double-word (range [0...MaxValue]). It is a bit mask, in which every bit represents digital Pin. Bit0, the least significant bit, corresponds to Pin0; Bit1 corresponds to Pin1, and so on until Pin31.

Bit value | Description
0 | The digital pin at this position is ignored.
1 | The value of the digital pin at this position is set to “high”.
Default Value

Does not apply.

Initialization Status

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to set the value of digital outputs of a USB Channel to "high":

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    uint pinMask = 0x4;
    if (Api.SetValue(channelUsed, PcanParameter.IoDigitalSet, pinMask) == PcanStatus.OK)
        Console.WriteLine($"Pin2 of {channelUsed} was successfully set to 'high'.");
    else
        Console.WriteLine($"Error configuring digital Pin states for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim pinMask As UInteger = &H4
    If Api.SetValue(channelUsed, PcanParameter.IoDigitalSet, pinMask) = PcanStatus.OK Then
        Console.WriteLine($"Pin2 of {channelUsed} was successfully set to 'high'.")
    Else
        Console.WriteLine($"Error configuring digital Pin states for {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt32 pinMask = 0x4;
    if (Api::SetValue(channelUsed, PcanParameter::IoDigitalSet, pinMask) == PcanStatus::OK)
        Console::WriteLine("Pin2 of {0} was successfully set to 'high'.", channelUsed);
    else
        Console::WriteLine("Error configuring digital Pin states for {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Electronic Circuits Parameters
Parameter Classification and Usage


IoDigitalClear

This parameter is used to configure the value of selected digital output Pins to “low” within a device, using a bit mask value. Unlike IoDigitalValue, only needed Pins are set to “low”; unwanted ones are not touched, i.e., they are not re-configured.

Note Note

At the time of writing this documentation only PCAN-Chip USB based devices, with a firmware version equal to or greater than 3.3.0, support the configuration of a maximum of 5 digital Pins. For this reason, all other (not used) bits are automatically discarded from the bit mask value.

No error is generated by setting a bit for a nonexistent Pin.

Availability

It is available since PCAN-Basic version 4.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

Access Mode

This parameter is write-only. It can only be written.

Possible Values

This parameter has a resolution of a double-word (range [0...MaxValue]). It is a bit mask, in which every bit represents digital Pin. Bit0, the least significant bit, corresponds to Pin0; Bit1 corresponds to Pin1, and so on until Pin31.

Bit value | Description
0 | The digital Pin at this position is ignored.
1 | The value of the digital pin at this position is set to “low”.
Default Value

Does not apply.

Initialization Status

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to set the value of digital outputs of a USB Channel to "low":

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    uint pinMask = 0x1;
    if (Api.SetValue(channelUsed, PcanParameter.IoDigitalClear, pinMask) == PcanStatus.OK)
        Console.WriteLine($"Pin0 of {channelUsed} was successfully set to 'low'.");
    else
        Console.WriteLine($"Error configuring digital Pin states for {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim pinMask As UInteger = &H1
    If Api.SetValue(channelUsed, PcanParameter.IoDigitalClear, pinMask) = PcanStatus.OK Then
        Console.WriteLine($"Pin0 of {channelUsed} was successfully set to 'low'.")
    Else
        Console.WriteLine($"Error configuring digital Pin states for {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt32 pinMask = 0x1;
    if (Api::SetValue(channelUsed, PcanParameter::IoDigitalClear, pinMask) == PcanStatus::OK)
        Console::WriteLine("Pin0 of {0} was successfully set to 'low'.", channelUsed);
    else
        Console::WriteLine("Error configuring digital Pin states for {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Electronic Circuits Parameters
Parameter Classification and Usage


IoAnalogValue

This parameter is used for reading analog voltages from the analog input Pin of a device.

Note Note

At the time of writing this documentation only PCAN-Chip USB based devices, with a firmware version equal to or greater than 3.3.0, support only 1 analog pin.

No error is generated by setting a bit for a nonexistent Pin.

Availability

It is available since PCAN-Basic version 4.3.0.

Supported By

  • PCAN-USB: Channels Usb01 to Usb16.

Access Mode

This parameter can only be retrieved. It cannot be modified.

Possible Values

This parameter has a resolution of a double-word (range [0...MaxValue]). The returned value represents the direct value from the A/D converter, which is an unsigned integer value.

The returned value must be converted into a signed value, considering the external wiring.

Default Value

Does not apply.

Initialization Status

Set: The PCAN Channel must be initialized before using this parameter.

Example

The following code shows how to retrieve the value of the analog Pin of a USB Channel:

C#
VB
C++
Copy
PcanChannel channelUsed = PcanChannel.Usb01;

if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
    uint rawValue;
    if (Api.GetValue(channelUsed, PcanParameter.IoAnalogValue, out rawValue) == PcanStatus.OK)
        Console.WriteLine($"The raw value of the analog Pin of {channelUsed} is {rawValue}.");
    else
        Console.WriteLine($"Error retrieving the analog Pin value from {channelUsed}.");
    Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01

If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
    Dim rawValue As UInteger
    If Api.GetValue(channelUsed, PcanParameter.IoAnalogValue, rawValue) = PcanStatus.OK Then
        Console.WriteLine($"The raw value of the analog Pin of {channelUsed} is {rawValue}.")
    Else
        Console.WriteLine($"Error retrieving the analog Pin value from {channelUsed}.")
    End If
    Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;

if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
    UInt32 rawValue;
    if (Api::GetValue(channelUsed, PcanParameter::IoAnalogValue, rawValue) == PcanStatus::OK)
        Console::WriteLine("The raw value of the analog Pin of {0} is {1}.", channelUsed, rawValue);
    else
        Console::WriteLine("Error retrieving the analog Pin value from {0}.", channelUsed);
    Api::Uninitialize(channelUsed);
}
See Also

Reference

GetValue
SetValue
PcanParameter

Other Resources

Electronic Circuits Parameters
Parameter Classification and Usage


Preset Parameters

Parameter setting within the PCAN-Basic API, except of the parameters grouped as “Logging Parameters” (these are not tied to a channel in particular), is allowed after a Channel has been successfully initialized. However, there are some cases where some configuration needs to be done even before a Channel is initialized. The following parameters can be configured on a Channel before it is initialized.

Parameters
Parameter | Description
ReceiveStatus | "Receive Status" parameter for incoming messages.
ListenOnly | PCAN "listen-only" parameter.
BitrateAdapting | Attachment to an existing connection with unknown/different bit rate.
See Also

Reference

PcanParameter

Other Resources

Parameter Classification and Usage


Backward Compatible Definitions

The following topics show the fields of the backward compatibility PCANBasic class grouped as categories:

Name | Description
PCAN Handle Definitions | Defines the handles for the different PCAN Channels.
Parameter Value Definitions | Defines the possible parameters for configuring and retrieving PCAN's environment values with the methods SetValue and GetValue.
FD Bit rate Parameter Definitions | Defines the different configuration parameters used to create a Flexible Data rate string for FD capable PCAN Channels initialization.
Look Up Parameter Definitions | Defines the different parameters used to search for PCAN Channels.

The following topics contain important information to keep into account when using the backward compatibility PCANBasic class:

Name | Description
Error Frames | This section contains information about CAN Error frames.
Status Frames | This section contains information about PCAN Status frames.
Log File Generation | This section contains information about logging debug data within PCAN-Basic.


PCAN Handle Definitions

PCAN Handles represent the different PCAN buses (Channels) available to use within the API when a PCAN Handle is required. The values listed here are fields of the class PCANBasic.

Default handle value
Type | Identifier | Value | Description
UInt16 | PCAN_NONEBUS | 0 | Represents a standard PCAN channel. This channel cannot be initialized.

Handles for the ISA Bus (Non Plug-and-Play)
Type | Identifier | Value | Description
UInt16 | PCAN_ISABUS1 | 0x21 | PCAN-ISA interface, channel 1.
UInt16 | PCAN_ISABUS2 | 0x22 | PCAN-ISA interface, channel 2.
UInt16 | PCAN_ISABUS3 | 0x23 | PCAN-ISA interface, channel 3.
UInt16 | PCAN_ISABUS4 | 0x24 | PCAN-ISA interface, channel 4.
UInt16 | PCAN_ISABUS5 | 0x25 | PCAN-ISA interface, channel 5.
UInt16 | PCAN_ISABUS6 | 0x26 | PCAN-ISA interface, channel 6.
UInt16 | PCAN_ISABUS7 | 0x27 | PCAN-ISA interface, channel 7.
UInt16 | PCAN_ISABUS8 | 0x28 | PCAN-ISA interface, channel 8.

Handles for the Dongle Bus (Non Plug-and-Play)
Type | Identifier | Value | Description
UInt16 | PCAN_DNGBUS1 | 0x31 | PCAN-Dongle/LPT interface, channel 1.

Handles for the PCI Bus
Type | Identifier | Value | Description
UInt16 | PCAN_PCIBUS1 | 0x41 | PCAN-PCI interface, channel 1.
UInt16 | PCAN_PCIBUS2 | 0x42 | PCAN-PCI interface, channel 2.
UInt16 | PCAN_PCIBUS3 | 0x43 | PCAN-PCI interface, channel 3.
UInt16 | PCAN_PCIBUS4 | 0x44 | PCAN-PCI interface, channel 4.
UInt16 | PCAN_PCIBUS5 | 0x45 | PCAN-PCI interface, channel 5.
UInt16 | PCAN_PCIBUS6 | 0x46 | PCAN-PCI interface, channel 6.
UInt16 | PCAN_PCIBUS7 | 0x47 | PCAN-PCI interface, channel 7.
UInt16 | PCAN_PCIBUS8 | 0x48 | PCAN-PCI interface, channel 8.
UInt16 | PCAN_PCIBUS9 | 0x409 | PCAN-PCI interface, channel 9.
UInt16 | PCAN_PCIBUS10 | 0x40A | PCAN-PCI interface, channel 10.
UInt16 | PCAN_PCIBUS11 | 0x40B | PCAN-PCI interface, channel 11.
UInt16 | PCAN_PCIBUS12 | 0x40C | PCAN-PCI interface, channel 12.
UInt16 | PCAN_PCIBUS13 | 0x40D | PCAN-PCI interface, channel 13.
UInt16 | PCAN_PCIBUS14 | 0x40E | PCAN-PCI interface, channel 14.
UInt16 | PCAN_PCIBUS15 | 0x40F | PCAN-PCI interface, channel 15.
UInt16 | PCAN_PCIBUS16 | 0x410 | PCAN-PCI interface, channel 16.

Handles for the USB Bus
Type | Identifier | Value | Description
UInt16 | PCAN_USBBUS1 | 0x51 | PCAN-USB interface, channel 1.
UInt16 | PCAN_USBBUS2 | 0x52 | PCAN-USB interface, channel 2.
UInt16 | PCAN_USBBUS3 | 0x53 | PCAN-USB interface, channel 3.
UInt16 | PCAN_USBBUS4 | 0x54 | PCAN-USB interface, channel 4.
UInt16 | PCAN_USBBUS5 | 0x55 | PCAN-USB interface, channel 5.
UInt16 | PCAN_USBBUS6 | 0x56 | PCAN-USB interface, channel 6.
UInt16 | PCAN_USBBUS7 | 0x57 | PCAN-USB interface, channel 7.
UInt16 | PCAN_USBBUS8 | 0x58 | PCAN-USB interface, channel 8.
UInt16 | PCAN_USBBUS9 | 0x509 | PCAN-USB interface, channel 9.
UInt16 | PCAN_USBBUS10 | 0x50A | PCAN-USB interface, channel 10.
UInt16 | PCAN_USBBUS11 | 0x50B | PCAN-USB interface, channel 11.
UInt16 | PCAN_USBBUS12 | 0x50C | PCAN-USB interface, channel 12.
UInt16 | PCAN_USBBUS13 | 0x50D | PCAN-USB interface, channel 13.
UInt16 | PCAN_USBBUS14 | 0x50E | PCAN-USB interface, channel 14.
UInt16 | PCAN_USBBUS15 | 0x50F | PCAN-USB interface, channel 15.
UInt16 | PCAN_USBBUS16 | 0x510 | PCAN-USB interface, channel 16.

Handles for the PC_Card Bus
Type | Identifier | Value | Description
UInt16 | PCAN_PCCBUS1 | 0x61 | PCAN-PC Card interface, channel 1.
UInt16 | PCAN_PCCBUS2 | 0x62 | PCAN-PC Card interface, channel 2.

Handles for the LAN Bus
Type | Identifier | Value | Description
UInt16 | PCAN_LANBUS1 | 0x801 | PCAN-LAN interface, channel 1.
UInt16 | PCAN_LANBUS2 | 0x802 | PCAN-LAN interface, channel 2.
UInt16 | PCAN_LANBUS3 | 0x803 | PCAN-LAN interface, channel 3.
UInt16 | PCAN_LANBUS4 | 0x804 | PCAN-LAN interface, channel 4.
UInt16 | PCAN_LANBUS5 | 0x805 | PCAN-LAN interface, channel 5.
UInt16 | PCAN_LANBUS6 | 0x806 | PCAN-LAN interface, channel 6.
UInt16 | PCAN_LANBUS7 | 0x807 | PCAN-LAN interface, channel 7.
UInt16 | PCAN_LANBUS8 | 0x808 | PCAN-LAN interface, channel 8.
UInt16 | PCAN_LANBUS9 | 0x809 | PCAN-LAN interface, channel 9.
UInt16 | PCAN_LANBUS10 | 0x80A | PCAN-LAN interface, channel 10.
UInt16 | PCAN_LANBUS11 | 0x80B | PCAN-LAN interface, channel 11.
UInt16 | PCAN_LANBUS12 | 0x80C | PCAN-LAN interface, channel 12.
UInt16 | PCAN_LANBUS13 | 0x80D | PCAN-LAN interface, channel 13.
UInt16 | PCAN_LANBUS14 | 0x80E | PCAN-LAN interface, channel 14.
UInt16 | PCAN_LANBUS15 | 0x80F | PCAN-LAN interface, channel 15.
UInt16 | PCAN_LANBUS16 | 0x810 | PCAN-LAN interface, channel 16.

Remarks

The PCAN_NONEBUS value is used as default channel value. It is used for general purposes, e.g., configuring the Log capabilities of the PCAN-Basic API. It can also be used to remove all connections made by an application.

These values are declared as object fields in an object oriented environment (Delphi, .NET Framework) and declared as #define's in C++ (plain API).

Hardware Type and Channels

Non Plug-and-Play: The hardware channels of this kind are used as registered. This mean, for example, it is allowed to register the PCAN_ISABUS3 without having registered PCAN_ISABUS1 and PCAN_ISABUS2. It is a decision of each user, how to associate a PCAN Channel (logical part) and a port/interrupt pair (physical part).

Plug-and-Play: For hardware handles of PCI, USB and PC-Card, the availability of the channels is determined by the count of hardware connected to a computer in a given moment, in conjunction with their internal handle. This mean, that having four PCAN-USB connected to a computer will let the user connect to the channels PCAN_USBBUS1 to PCAN_USBBUS4. The association of each channel with a hardware is managed internally using the handle of a hardware.

See Also

Other Resources

Backward Compatible Definitions


Parameter Value Definitions

Defines the possible parameters for configuring and retrieving PCAN's environment values with the methods SetValue and GetValue.

Activation
Type | Identifier | Value | Description
Int32 | PCAN_PARAMETER_OFF | 0 | The PCAN parameter is not set (inactive).
Int32 | PCAN_PARAMETER_OFF | 1 | The PCAN parameter is set (active).

Filter
Type | Identifier | Value | Description
Int32 | PCAN_FILTER_CLOSE | 0 | The PCAN filter is closed. No messages will be received.
Int32 | PCAN_FILTER_OPEN | 1 | The PCAN filter is fully opened. All messages will be received.
Int32 | PCAN_FILTER_CUSTOM | 2 | The PCAN filter is custom configured. Only registered messages will be received.

Channel Availability
Type | Identifier | Value | Description
Int32 | PCAN_CHANNEL_UNAVAILABLE | 0 | The PCAN Channel handle i.e. its associated hardware is not available.
Int32 | PCAN_CHANNEL_AVAILABLE | 1 | The PCAN Channel handle is valid to connect/initialize. Furthermore, for plug-and-play hardware, this means that the hardware is plugged-in.
Int32 | PCAN_CHANNEL_OCCUPIED | 2 | The PCAN Channel handle is valid, and is currently being used.
Int32 | PCAN_CHANNEL_PCANVIEW | PCAN_CHANNEL_AVAILABLE OR PCAN_CHANNEL_OCCUPIED | The PCAN Channel handle is currently being used by a PCAN-View application and is valid to connect.

Log-Configuration
Type | Identifier | Value | Description
Int32 | LOG_FUNCTION_DEFAULT | 0x00 | Logs system exceptions and errors. Custom log texts are also included.
Int32 | LOG_FUNCTION_ENTRY | 0x01 | Logs the entries to the PCAN-Basic API functions.
Int32 | LOG_FUNCTION_PARAMETERS | 0x02 | Logs the parameters passed to the PCAN-Basic API functions.
Int32 | LOG_FUNCTION_LEAVE | 0x04 | Logs the exits from the PCAN-Basic API functions.
Int32 | LOG_FUNCTION_WRITE | 0x08 | Logs the CAN messages passed to the Write / WriteFD methods.
Int32 | LOG_FUNCTION_READ | 0x10 | Logs the CAN messages received with the Read / ReadFD methods.
Int32 | LOG_FUNCTION_ALL | 0xFFFF | Logs all possible information within the PCAN-Basic API functions.

Trace-Configuration
Type | Identifier | Value | Description
Int32 | TRACE_FILE_SINGLE | 0x00 | Stores messages in a single file until the configured file size is reached.
Int32 | TRACE_FILE_SEGMENTED | 0x01 | Stores messages distributed in several files.
Int32 | TRACE_FILE_DATE | 0x02 | Includes date information into the name of the trace file.
Int32 | TRACE_FILE_TIME | 0x04 | Includes the time information into the name of the trace file.
Int32 | TRACE_FILE_OVERWRITE | 0x08 | Forces the overwriting of available traces (same name).

Features
Type | Identifier | Value | Description
Int32 | FEATURE_FD_CAPABLE | 1 | The PCAN Channel represents a device that supports flexible data rate (CAN-FD).
Int32 | FEATURE_DELAY_CAPABLE | 2 | The PCAN Channel represents a device that supports the configuration of a delay between sending frames (FPGA devices only).
Int32 | FEATURE_IO_CAPABLE | 4 | The PCAN Channel represents a device that supports the configuration of digital and/or analogue IOs (input/output) for using with electronic circuits.

Service-Status
Type | Identifier | Value | Description
Int32 | SERVICE_STATUS_STOPPED | 1 | The service is not running.
Int32 | SERVICE_STATUS_RUNNING | 4 | The service is running.
Channel-Direction
Type | Identifier | Value | Description
Int32 | LAN_DIRECTION_READ | 0x01 | The PCAN Channel is limited to incoming communication only.
Int32 | LAN_DIRECTION_WRITE | 0x02 | The PCAN Channel is limited to outgoing communication only.
Int32 | LAN_DIRECTION_READ_WRITE | LAN_DIRECTION_READ OR LAN_DIRECTION_WRITE | The PCAN Channel communication is bidirectional.
Other Constants
Type | Identifier | Value | Description
Int32 | MAX_LENGTH_HARDWARE_NAME | 33 | Maximum length of the name of a device: 32 characters + terminator.
Int32 | MAX_LENGTH_VERSION_STRING | 256 | Maximum length of a version string: 255 characters + terminator.

Remarks

These values are declared as object fields in an object oriented environment (Delphi, .NET Framework) and declared as #define's in C++ (plain API).

Important: For more information about each TPCANParameter value, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.

See Also

Other Resources

Backward Compatible Definitions


FD Bit rate Parameter Definitions

Defines the different configuration parameters used to create a Flexible Data rate string for FD capable PCAN Channels initialization.

Clock Frequency parameters
Type | Identifier | Value | Description
String | PCAN_BR_CLOCK | "f_clock" | Clock frequency in Hertz (80000000, 60000000, 40000000, 30000000, 24000000, 20000000).
String | PCAN_BR_CLOCK_MHZ | "f_clock_mhz" | Clock frequency in Megahertz (80, 60, 40, 30, 24, 20).

Nominal Bit rate parameters
Type | Identifier | Value | Description
String | PCAN_BR_NOM_BRP | "nom_brp" | Clock prescaler for nominal time quantum (1..1024).
String | PCAN_BR_NOM_TSEG1 | "nom_tseg1" | TSEG1 segment for nominal bit rate in time quanta (1..256).
String | PCAN_BR_NOM_TSEG2 | "nom_tseg2" | TSEG2 segment for nominal bit rate in time quanta (1..128).
String | PCAN_BR_NOM_SJW | "nom_sjw" | Synchronization Jump Width for nominal bit rate in time quanta (1..128).

Data Bit rate parameters
Type | Identifier | Value | Description
String | PCAN_BR_DATA_BRP | "data_brp" | Clock prescaler for fast data time quantum (1..1024).
String | PCAN_BR_DATA_TSEG1 | "data_tseg1" | TSEG1 segment for fast data bit rate in time quanta (1..32).
String | PCAN_BR_DATA_TSEG2 | "data_tseg2" | TSEG2 segment for fast data bit rate in time quanta (1..16).
String | PCAN_BR_DATA_SJW | "data_sjw" | Synchronization Jump Width for fast data bit rate in time quanta (1..16).

Remarks

These values are declared as object fields in an object oriented environment (Delphi, .NET Framework) and declared as #define's in C++ (plain API).

Following points are to be respected in order to construct a valid FD Bit rate string:

  • The string must contain only one of the two possible Clock Frequency parameters. Example: "f_clock_mhz=80"

  • The value for each used identifier must be one of the values listed for it in the Range table. Example: "f_clock=80000000"

  • The value for each parameter must be separated with a '='. Example: "data_brp=1"

  • Each pair of parameter/value must be separated with a ','. Blank spaces are allowed but are not necessary. Example: "f_clock_mhz=24, nom_brp=1,"

  • According to the kind of bit rate being defined, all 4 parameters listed in the nominal or data bit rate section are to be used. Example: "nom_brp=5, nom_tseg1=2, nom_tseg2=1, nom_sjw=1"

  • Either the nominal bit rate or both, nominal and data bit rate, must be defined within the parameter string. Example: "f_clock_mhz=20, nom_brp=5, nom_tseg1=2, nom_tseg2=1, nom_sjw=1"

Example with nominal Bit rate only:

A valid string representing 1 Mbit/sec for both, nominal and data Bit rates:

"f_clock_mhz=20, nom_brp=5, nom_tseg1=2, nom_tseg2=1, nom_sjw=1"

Example with nominal and data Bit rate:

A valid string representing 1 Mbit/sec for nominal Bit rate, and 2 Mbit/sec for data Bit rate:

"f_clock_mhz=20, nom_brp=5, nom_tseg1=2, nom_tseg2=1, nom_sjw=1, data_brp=2, data_tseg1=3, data_tseg2=1, data_sjw=1"

Parameter Value Ranges
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
See Also

Reference

InitializeFD

Other Resources

Backward Compatible Definitions


Look Up Parameter Definitions

Defines the available parameters used as search criteria for PCAN channels with the LookUpChannel method.

LookUp Channel values
Type | Identifier | Value | Description
String | LOOKUP_DEVICE_TYPE | "devicetype" | Searches a PCAN Channel by its device type (see TPCANDevice).
String | LOOKUP_DEVICE_ID | "deviceid" | Searches a PCAN Channel by its device identifier.
String | LOOKUP_CONTROLLER_NUMBER | "controllernumber" | Searches a PCAN Channel by its 0-based CAN controller index.
String | LOOKUP_IP_ADDRESS | "ipaddress" | Searches a PCAN Channel by its IP address (PCAN_LAN Channels only).
Remarks

These values are declared as object fields in an object oriented environment (Delphi, .NET Framework) and declared as #define's in C++ (plain API).

Following rules are to be taken into account in order to construct a valid lookup parameter string:

  • The value for each parameter must be separated with a '='. Example: "deviceid=1".

  • Each pair of parameter/value must be separated with a ','. Blank spaces are allowed but are not necessary. Example: "devicetype=pcan_usb, deviceid=1,".

  • Non-existent parameters are ignored instead of causing the function call to fail. Example, this would work well: "devicetype=pcan_usb,unknownparam=4".

  • Numeric parameter values that are out of the current supported range just return no results instead of causing the function to fail. Example: "controllernumber=2500".

  • Repeated parameters within the string don't cause the function to fail. Only the last occurrences of repeated parameters are evaluated. Example, only PCI devices are looked up: "devicetype=pcan_usb, devicetype=pcan_pci".

  • When more than one channel is found, the first of them is returned. Example: "devicetype=pcan_usb" (having more than one USB device attached).

  • The order of evaluation is fixed, regardless of the position of the parameters within the string. The order is:

    1. Device Type.

    2. Device ID .

    3. CAN Controller Number.

    4. IP-Address .

Parameters and Value Ranges
Identifier | Value Range
LOOKUP_DEVICE_TYPE | A TPCANDevice value. The input can be numeric, in hexadecimal or decimal format, or as string denoting a TPCANDevice value name (case insensitive). Examples: "devicetype=1". "devicetype=pcan_usb". "devicetype=PCAN_USB".
LOOKUP_DEVICE_ID | Value in range of a double word (0 .. 4294967295), in hexadecimal or decimal format. Examples: "deviceid=10". "deviceid=Ah". "deviceid=0xA".
LOOKUP_CONTROLLER_NUMBER | A zero-based index value in range of a double word (0 .. 4294967295), in hexadecimal or decimal format. Currently, a maximum of 6 channels per device are supported (controller index in range [0 .. 5]). Examples: "controllernumber=1". "controllernumber=1h". "controllernumber=0x1".
LOOKUP_IP_ADDRESS | A valid Internet Protocol address string. Examples: "ipaddress=192.168.2.1".
See Also

Reference

LookUpChannel(String, UInt16)

Other Resources

Backward Compatible Definitions


Error Frames

Error frames can be received by configured the parameter PCAN_ALLOW_ERROR_FRAMES on the connected PCAN Channel. This is carried out using the SetValue(UInt16, TPCANParameter, UInt32, UInt32) method.

The error frame data will be placed into a TPCANMsg or TPCANMsgFD structure, according to the kind of initialization used. The field MSGTYPE of these structures will have the flag PCAN_MESSAGE_ERRFRAME set.

The following list shows the elements of an error frame:

Field | Information from... | Contents
ID | ECC register SJA1000 (Error Code Capture), bits 6 and 7 (ERRC0, ERRC1) | 0: The message only transports updated error counter values 1: Bit error 2: Form error 4: Stuff error 8: Other type of error
DATA[0] | ECC register, bit 5 (DIR) | 0: Error has occurred during transmission 1: Error has occurred during reception
DATA[1] | ECC register, bits 0 to 4 (SEG0 to SEG4) | Current position of the bit stream processor: 2: ID.28 to ID.21 3: Start of frame 4: Bit SRTR 5: Bit IDE 6: ID.20 to ID.18 7: ID.17 to ID.13 8: CRC Sequence 9: Reserved Bit 0 10: Data Field 11: Data Length Code 12: Bit RTR 13: Reserved Bit 1 14: ID.4 to ID.0 15: ID.12 to ID.5 17: Active Error Flag 18: Intermission 19: Tolerate Dominant Bits 23: Error Delimiter 24: CRC Delimiter 25: Acknowledge Slot 26: End of Frame 27: Acknowledge Limiter 28: Overload Flag
DATA[2] | RX Error Counter Register (RXERR) | Current value of the receive error counter
DATA[3] | TX Error Counter Register (TXERR) | Current value of the transmit error counter

Remarks

For further information about this, see Philips Data Sheet SJA1000 Stand-alone CAN controller.

See Also

Reference

SetValue
GetValue

Other Resources

Backward Compatible Definitions


Status Frames

Status frames can be received or discarded by configuring the parameter PCAN_ALLOW_STATUS_FRAMES on the connected PCAN Channel. This is carried out using the SetValue(UInt16, TPCANParameter, UInt32, UInt32) method.

The status frame data will be placed into a TPCANMsg or TPCANMsgFD structure, according to the kind of initialization used. The field TPCANMsg.MSGTYPE/TPCANMsgFD.MSGTYPE will have the flag PCAN_MESSAGE_STATUS set.

The TPCANMsg.ID/TPCANMsgFD.ID, and TPCANMsg.LEN/TPCANMsgFD.DLC fields can be ignored. The first 4 data bytes of the message represent a 32 bit value in big endian format (MSB is byte 0, LSB is byte 3), that maps the reported TPCANStatus value. The following table shows the posisble values for a status frame:

Data0 | Data1 | Data2 | Data3 | Identifier | Code | Description
00h | 00h | 00h | 00h | PCAN_ERROR_OK | 0000h | The CAN controller has been successfully activated.
00h | 00h | 00h | 02h | PCAN_ERROR_OVERRUN | 0002h | The CAN controller has been read out too late.
00h | 00h | 00h | 04h | PCAN_ERROR_BUSLIGHT | 0004h | Bus error: An error counter has reached the 'light' limit.
00h | 00h | 00h | 08h | PCAN_ERROR_BUSWARNING | 0008h | Bus error: An error counter has reached the 'warning' limit.
00h | 04h | 00h | 00h | PCAN_ERROR_BUSPASSIVE | 4000h | The CAN controller is in error passive state.
00h | 00h | 00h | 08h | PCAN_ERROR_BUSHEAVY | 0008h | Bus error: An error counter has reached the 'heavy' limit.
00h | 00h | 00h | 10h | PCAN_ERROR_BUSOFF | 0010h | Bus error: CAN Controller is in 'bus-off' state.

Remarks

According to the communication being used (CAN / CAN FD) some of the satus values described above may or may not be supported.

See Also

Reference

SetValue
GetValue

Other Resources

Backward Compatible Definitions


Log File Generation

To support debugging of problems, that can arise during CAN communication, PCAN-Basic can generate a log file, containing a protocol of all API function calls. There are two different ways to configure and activate this logging functionality:

  • Using the API

  • Using the Windows Registry

Log configuration using API

In order to configure the log functionality, the PCAN-Basic API provides 3 parameters that can be configured using the SetValue method. These parameters are:

  • PCAN_LOG_LOCATION, to set the location of the log file.

  • PCAN_LOG_CONFIGURE, to configure the content of the log file.

  • PCAN_LOG_STATUS, to enable/disable logging.

Example

The following example shows how the PCAN-Basic is configured to log all possible information (LOG_FUNCTION_ALL), and to store the log file on the desktop of an user called "admin".

C#
VB
C++
Copy
TPCANStatus result;
System.Text.StringBuilder strMsg;

strMsg = new System.Text.StringBuilder(256);

// Configures the data in the log file.
//
uint iBuffer = PCANBasic.LOG_FUNCTION_ALL;
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_CONFIGURE, ref iBuffer, sizeof(UInt32));
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}

// Configures the path of the log file.
//
string buffer = "C:\\users\\admin\\desktop";
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_LOCATION, buffer, (UInt32)buffer.Length);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}

// Configures the status of the log file
//
iBuffer = PCANBasic.PCAN_PARAMETER_ON;
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_STATUS, ref iBuffer, sizeof(UInt32));
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder

strMsg = New System.Text.StringBuilder(256)

' Configures the data in the log file.
'
Dim iBuffer As UInt32 = PCANBasic.LOG_FUNCTION_ALL
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_CONFIGURE, iBuffer, CType(System.Runtime.InteropServices.Marshal.SizeOf(iBuffer), UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error And show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString())
End If

' Configures the path of the log file.
'
Dim Buffer As String = "C:\\users\\admin\\desktop"
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_LOCATION, Buffer, CType(Buffer.Length, UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error And show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString())
End If

' Configures the status of the log file
'
iBuffer = PCANBasic.PCAN_PARAMETER_ON
result = PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_STATUS, iBuffer, CType(System.Runtime.InteropServices.Marshal.SizeOf(iBuffer), UInteger))
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error And show it
    '
    PCANBasic.GetErrorText(result, 0, strMsg)
    Console.WriteLine(strMsg.ToString())
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;

strMsg = gcnew System::Text::StringBuilder(256);

// Configures the data in the log file.
//
UInt32 iBuffer = PCANBasic::LOG_FUNCTION_ALL;
result = PCANBasic::SetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_LOG_CONFIGURE, iBuffer, sizeof(UInt32));
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}

// Configures the path of the log file.
//
String^ buffer = "C:\\users\\admin\\desktop";
result = PCANBasic::SetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_LOG_LOCATION, buffer, buffer->Length);
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}

// Configures the status of the log file
//
iBuffer = PCANBasic::PCAN_PARAMETER_ON;
result = PCANBasic::SetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_LOG_STATUS, iBuffer, sizeof(UInt32));
if (result != TPCANStatus::PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic::GetErrorText(result, 0, strMsg);
    Console::WriteLine(strMsg->ToString());
}
Log configuration using Windows Registry

In order to enable the log file generation, the following registry key must be created:

HKEY_CURRENT_USER\SOFTWARE\PEAK-System\PCAN-Basic\Log

The existence of this key is analogous to use the SetValue method to set the PCAN_LOG_STATUS parameter to "on". If this key is not present, then no log file is generated.

Configuration

If no further configuration is made, then the default values for PCAN_LOG_LOCATION , and PCAN_LOG_CONFIGURE are used. In order to configure the location and content of the log file, two registry values are used:

  • Flags: This is a UInt32 value, that represents a logical OR operation between the values LOG_FUNCTION_* that are wanted to be included within the logging data. The value LOG_FUNCTION_ALL causes logging all possible information.

  • Path: This is a String value, that represents the path to a folder in the computer, where the log file will be created.

Example

[HKEY_CURRENT_USER\SOFTWARE\PEAK-System\PCAN-Basic\Log]
"Flags"=dword:00000007
"Path"="C:\\Users\\admin\\desktop"

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.

See Also

Reference

SetValue

Other Resources

Backward Compatible Definitions


Error Frames

Error frames can be received or discarded by configuring the parameter AllowErrorFrames on the connected PCAN Channel. This is carried out using the SetValue(PcanChannel, PcanParameter, UInt32) method.

The error frame data will be placed into a PcanMessage object. The field MsgType of these objects will have the flag Error set.

The following list shows the elements of an error frame:

Field | Information from... | Contents
ID | ECC register SJA1000 (Error Code Capture), bits 6 and 7 (ERRC0, ERRC1) | 0: The message only transports updated error counter values 1: Bit error 2: Form error 4: Stuff error 8: Other type of error
DATA[0] | ECC register, bit 5 (DIR) | 0: Error has occurred during transmission 1: Error has occurred during reception
DATA[1] | ECC register, bits 0 to 4 (SEG0 to SEG4) | Current position of the bit stream processor: 2: ID.28 to ID.21 3: Start of frame 4: Bit SRTR 5: Bit IDE 6: ID.20 to ID.18 7: ID.17 to ID.13 8: CRC Sequence 9: Reserved Bit 0 10: Data Field 11: Data Length Code 12: Bit RTR 13: Reserved Bit 1 14: ID.4 to ID.0 15: ID.12 to ID.5 17: Active Error Flag 18: Intermission 19: Tolerate Dominant Bits 23: Error Delimiter 24: CRC Delimiter 25: Acknowledge Slot 26: End of Frame 27: Acknowledge Limiter 28: Overload Flag
DATA[2] | RX Error Counter Register (RXERR) | Current value of the receive error counter
DATA[3] | TX Error Counter Register (TXERR) | Current value of the transmit error counter

Remarks

For further information about this, see Philips Data Sheet SJA1000 Stand-alone CAN controller.

See Also

Reference

SetValue
GetValue

Other Resources

Additional Information


Status Frames

Status frames can be received or discarded by configuring the parameter AllowStatusFrames on the connected PCAN Channel. This is carried out using the SetValue(PcanChannel, PcanParameter, UInt32) method.

The status frame data will be placed into a PcanMessage object. The field MsgType of these objects will have the flag Status set.

The ID and DLC fields can be ignored. The first 4 data bytes of the message represent a 32 bit value in big endian format (MSB is byte 0, LSB is byte 3), that maps the reported PcanStatus value. The following table shows the possible values for a status frame:

Data0 | Data1 | Data2 | Data3 | Identifier | Code | Description
00h | 00h | 00h | 00h | OK | 0000h | The CAN controller has been successfully activated.
00h | 00h | 00h | 02h | Overrun | 0002h | The CAN controller has been read out too late.
00h | 00h | 00h | 04h | BusLight | 0004h | Bus error: An error counter has reached the 'light' limit.
00h | 00h | 00h | 08h | BusWarning | 0008h | Bus error: An error counter has reached the 'warning' limit.
00h | 04h | 00h | 00h | BusPassive | 4000h | The CAN controller is in error passive state.
00h | 00h | 00h | 08h | BusHeavy | 0008h | Bus error: An error counter has reached the 'heavy' limit.
00h | 00h | 00h | 10h | BusOff | 0010h | Bus error: CAN Controller is in 'bus-off' state.

Remarks

According to the communication being used (CAN / CAN FD) some of the status values described above may or may not be supported.

See Also

Reference

SetValue
GetValue

Other Resources

Additional Information


Log File Generation

To support debugging of problems, that can arise during CAN communication, PCAN-Basic can generate a log file, containing a protocol of all API function calls. There are two different ways to configure and activate this logging functionality:

  • Using the API

  • Using the Windows Registry

Log configuration using API

In order to configure the log functionality, the PCAN-Basic API provides 3 parameters that can be configured using the SetValue method. These parameters are:

  • LogLocation, to set the location of the log file.

  • LogConfigure, to configure the content of the log file.

  • LogStatus, to enable/disable logging.

Example

The following example shows how the PCAN-Basic is configured to log all possible information (All), and to store the log file on the desktop of an user called "admin".

C#
VB
C++
Copy
// Configures the data in the log file.
//
PcanStatus result = Api.SetValue(PcanChannel.None, PcanParameter.LogConfigure, ParameterValue.Log.All);
if (result != PcanStatus.OK)
{
    // An error occurred, get a text describing the error and show it
    //
    string strMsg;
    Api.GetErrorText(result, out strMsg);
    Console.WriteLine(strMsg.ToString());
}

// Configures the path of the log file.
//
result = Api.SetValue(PcanChannel.None, PcanParameter.LogLocation, "C:\\users\\admin\\desktop");
if (result != PcanStatus.OK)
{
    // An error occurred, get a text describing the error and show it
    //
    string strMsg;
    Api.GetErrorText(result, out strMsg);
    Console.WriteLine(strMsg.ToString());
}

// Configures the status of the log file
//
result = Api.SetValue(PcanChannel.None, PcanParameter.LogStatus, ParameterValue.Activation.On);
if (result != PcanStatus.OK)
{
    // An error occurred, get a text describing the error and show it
    //
    string strMsg;
    Api.GetErrorText(result, out strMsg);
    Console.WriteLine(strMsg.ToString());
}
' Configures the data in the log file.
'
Dim result As PcanStatus = Api.SetValue(PcanChannel.None, PcanParameter.LogConfigure, ParameterValue.Log.All)
If result <> PcanStatus.OK Then
    ' An error occurred, get a text describing the error And show it
    '
    Dim strMsg As String = Nothing
    Api.GetErrorText(result, strMsg)
    Console.WriteLine(strMsg.ToString())
End If

' Configures the path of the log file.
'
result = Api.SetValue(PcanChannel.None, PcanParameter.LogLocation, "C:\\users\\admin\\desktop")
If result <> PcanStatus.OK Then
    ' An error occurred, get a text describing the error And show it
    '
    Dim strMsg As String = Nothing
    Api.GetErrorText(result, strMsg)
    Console.WriteLine(strMsg.ToString())
End If

' Configures the status of the log file
'
result = Api.SetValue(PcanChannel.None, PcanParameter.LogStatus, ParameterValue.Activation.On)
If result <> TPCANStatus.PCAN_ERROR_OK Then
    ' An error occurred, get a text describing the error And show it
    '
    Dim strMsg As String = Nothing
    Api.GetErrorText(result, strMsg)
    Console.WriteLine(strMsg.ToString())
End If
// Configures the data in the log file.
//
PcanStatus result = Api::SetValue(PcanChannel::None, PcanParameter::LogConfigure, ParameterValue::Log::All);
if (result != PcanStatus::OK)
{
    // An error occurred, get a text describing the error and show it
    //
    String^ strMsg;
    Api::GetErrorText(result, strMsg);
    Console::WriteLine(strMsg->ToString());
}

// Configures the path of the log file.
//
result = Api::SetValue(PcanChannel::None, PcanParameter::LogLocation, "C:\\users\\admin\\desktop");
if (result != PcanStatus::OK)
{
    // An error occurred, get a text describing the error and show it
    //
    String^ strMsg;
    Api::GetErrorText(result, strMsg);
    Console::WriteLine(strMsg->ToString());
}

// Configures the status of the log file
//
result = Api::SetValue(PcanChannel::None, PcanParameter::LogStatus, ParameterValue::Activation::On);
if (result != PcanStatus::OK)
{
    // An error occurred, get a text describing the error and show it
    //
    String^ strMsg;
    Api::GetErrorText(result, strMsg);
    Console::WriteLine(strMsg->ToString());
}
Log configuration using Windows Registry

In order to enable the log file generation, the following registry key must be created:

HKEY_CURRENT_USER\SOFTWARE\PEAK-System\PCAN-Basic\Log

The existence of this key is analogous to use the SetValue method to set the LogStatus parameter to On. If this key is not present, then no log file is generated.

Configuration

If no further configuration is made, then the default values for LogLocation , and LogConfigure are used. To configure the location and content of the log file, two registry values are used:

  • Flags: This is a UInt32 value, that represents a logical OR operation between the ParameterValueLog values, that are wanted to be included within the logging data. The value All causes logging all possible information.

  • Path: This is a string value, that represents the path to a folder in the computer, where the log file will be created.

Example

[HKEY_CURRENT_USER\SOFTWARE\PEAK-System\PCAN-Basic\Log]
"Flags"=dword:00000007
"Path"="C:\\Users\\admin\\desktop"

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.

See Also

Reference

SetValue

Other Resources

Logging Parameters


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 buses 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 buses. Furthermore, several hardware components are supported, which are based on the CAN controller Philips SJA1000.

So-called Nets are available. These specify virtual CAN buses 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

Other Resources

Additional Information
Understanding PCAN-Basic


PCAN-API

The professional programming interface PCAN-API, also called CanApi4 interface, makes it possible to create complex Windows® applications with CAN and CAN FD support. The API (Application Programming Interface) provides an extensive function library using interface DLLs for 32-bit and 64-bit systems.

Unlike PCAN-Basic, the CAN communication is handled by Clients and offers significant advantages. Thus, not only a single but multiple applications can access a physical CAN channel. Furthermore, it works even without hardware: Via virtual connections, Clients establish a simulated CAN communication among Windows® applications.

Important differences to PCAN-Basic at a glance:

  • Allow transmitting CAN messages at a fixed point of time (sending with timestamp).

  • Several applications can be connected to the same PCAN device at the same time.

  • Works with virtual hardware and internal nets.

  • Connection to the hardware is done over a client and a net, instead of using a pseudo channel.

See Also

Other Resources

Additional Information
PCAN-Developer 4


Version History

The topics in this section describe the changes made to the PCAN-Basic.NET library over the life of the project.

Version History

Select a version below to see a description of its changes.

  • Version 4.6.1

See Also

Other Resources

Welcome to the PCAN-Basic.NET Package Documentation


Version 4.6.1

Release Date: 2022-07-13.

PCANBasic.dll library (native changes):

Improvements:

  • The documentation was updated.

Bug fixes:

  • Asking the parameter PCAN_CHANNEL_CONDITION on PCAN-LAN channels associated to a PCAN-Ethernet Gateway DR device was returning wrong values.

  • When using the logging feature, the API was failing to include the value of the parameter 'BitrateFD' of the function CAN_InitializeFD.

  • The API was able to initialize a PCAN-LAN channel (CAN_Initialize/CAN_InitializeFD), even when the parameter PCAN_BITRATE_ADAPTING was not being used and the bit rate passed to the function was different that the one configured on the device.

  • Echo frames were not marked as such when being received by a Channel associated to a PCAN-Ethernet gateway DR FD device.

PCANBasic.NET assembly (managed changes):

Improvements:

  • First release of the PCANBasic.dll assembly.

See Also

Other Resources

Version History