Peak.PCANBasic.NET
4.9.0.942
Prefix Reserved
dotnet add package Peak.PCANBasic.NET --version 4.9.0.942
NuGet\Install-Package Peak.PCANBasic.NET -Version 4.9.0.942
<PackageReference Include="Peak.PCANBasic.NET" Version="4.9.0.942" />
paket add Peak.PCANBasic.NET --version 4.9.0.942
#r "nuget: Peak.PCANBasic.NET, 4.9.0.942"
// Install Peak.PCANBasic.NET as a Cake Addin #addin nuget:?package=Peak.PCANBasic.NET&version=4.9.0.942 // Install Peak.PCANBasic.NET as a Cake Tool #tool nuget:?package=Peak.PCANBasic.NET&version=4.9.0.942
PCAN-Basic.NET Assembly
PCAN-Basic.NET
is an interface for accessing and using the native PCAN-Basic API in .NET applications. The assembly is written using .NET Standard 2.0 which makes it suitable for developing under Windows and Linux.
The underlying native library (PCANBasic.dll
on Windows and libpcanbasic.so
on Linux), is used to do CAN communication through plug-and-play devices from PEAK-System Technik GmbH like PCAN-USB FD, and PCAN-PCI Express, among others.
Note: the native library files are not part of the PCAN-Basic.NET
package. See next block for installation instructions.
Documentation
For full online API documentation see docs.peak-system.com/API/PCAN-Basic.Net. Alternatively, the documentation is available as a CHM file. It can be found within the "NuGet" folder of the PCAN-Basic package, and can also be downloaded directly using this link.
Getting Started
Windows:
For using PCAN-Basic.NET
you need:
- to have the Windows device drivers installed, by using the PEAK-Drivers Setup,
- to have any plug-and-play device of the PCAN series attached to your PC, and
- to have the PCAN-Basic API installed, by using the PEAK-Drivers Setup (recommended). Alternatively, you can download a package containing all needed files and setting instructions.
PCAN-Gateway devices: If you want to communicate to PCAN-Gateways devices using PCAN-Basic, then you need to additionally install the feature "Virtual PCAN-Gateway" within the PEAK-Drivers Setup. Note that this is only supported on Windows systems.
For Linux:
For using PCAN-Basic.NET
you need:
- to have the character-based Linux driver (chardev) installed, by compiling the source code yourself. Instructions are found in the PEAK-System Linux site.
- to have any plug-and-play device of the PCAN series attached to your PC, and
- to have the PCAN-Basic API installed, by downloading and compiling the source files. See instructions in the readme.txt file enclosed in the package.
Usage
Reference the following namespace from the file where you want to use PCAN-Basic functionality:
C#:
using Peak.Can.Basic;
VB:
Imports Peak.Can.Basic
C++/CLI:
using namespace Peak::Can::Basic;
The namespace contains type enumerations, structures and classes for PCAN-Basic API accessing. Use the class Api to access API methods and constants:
C#:
PcanStatus result;
result = Api.Initialize(PcanChannel.Usb01, Bitrate.Pcan500);
VB:
Dim result As PcanStatus
result = Api.Initialize(PcanChannel.Usb01, Bitrate.Pcan500)
C++/CLI:
using namespace Peak::Can::Basic;
result = Api::Initialize(channelUsed, Bitrate::Pcan500);
Use the class Worker for event driven reading and writing
C#:
Worker myWorker = new Worker();
PcanMessage message = new PcanMessage(0x100, MessageType.Standard, 3, new byte[] { 1, 2, 3 }, false);
Broadcast broadcast = new Broadcast(message, 100);
myWorker.MessageAvailable += OnMessageAvailable;
if (myWorker.AddBroadcast(ref broadcast))
Console.WriteLine($"Broadcast {broadcast.Index}' configured successfully.");
myWorker.Start();
Console.WriteLine("The Worker was activated successfully.");
VB:
Dim myWorker As Worker = New Worker()
Dim message As PcanMessage = New PcanMessage(&H100, MessageType.Standard, 3, New Byte() {1, 2, 3}, False)
Dim broadcast As Broadcast = New Broadcast(message, 100)
AddHandler myWorker.MessageAvailable, AddressOf OnMessageAvailable
If myWorker.AddBroadcast(broadcast) Then
Console.WriteLine($"Broadcast '{broadcast.Index}' configured successfully.")
End If
myWorker.Start()
Console.WriteLine("The Worker object was activated successfully.")
C++/CLI:
Worker^ myWorker = gcnew Worker();
PcanMessage^ message = gcnew PcanMessage(0x100, MessageType::Standard, 3, gcnew array<Byte> { 1, 2, 3 }, false);
Broadcast^ broadcast = gcnew Broadcast(message, 100);
myWorker->MessageAvailable += gcnew System::EventHandler(&OnMessageAvailable);
if (myWorker->AddBroadcast(broadcast))
Console::WriteLine("Broadcast '{0}' configured successfully.", broadcast->Index);
myWorker->Start(false, false, false);
Console::WriteLine("The Worker object was activated successfully.");
Need Support?
If you need further information or help, you can contact us using the following channels:
- Documentation: Online documentation
- Community: PCAN-Basic Forum
- Phone: +49 6151 / 8173-20
- Fax: +49 6151 / 8173-29
- E-mail: support@peak-system.com
PEAK-System team
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- NETStandard.Library (>= 1.6.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Peak.PCANBasic.NET:
Package | Downloads |
---|---|
Meadow.Foundation.ICs.CAN.PCanBasic
PCAN-Basic USB CAN Controller for Windows |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Peak.PCANBasic.NET:
Repository | Stars |
---|---|
WildernessLabs/Meadow.Foundation
Unified driver and library framework for Meadow applications.
|
See https://www.peak-system.com/PCAN-Basic.126.0.html for more information.