public bool Transmit(
PcanMessage message
)
Public Function Transmit (
message As PcanMessage
) As Boolean
public:
bool Transmit(
PcanMessage^ message
)
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.
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.
// 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);
}
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. |