Worker(PcanChannel, Bitrate, Boolean) Constructor

Initializes a PCAN-Basic Worker object.

Definition

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
C#
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

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#
// 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}");

See Also