TraceStatus
This parameter allows to control the activity status of a trace session within the PCAN-Basic API.
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.
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".
It is available since PCAN-Basic version 1.3.0.
This parameter is read/write. It can be configured and retrieved.
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).
Get: The PCAN Channel must be initialized before using this parameter.
Set: The PCAN Channel must be initialized before using this parameter.
The following code shows how to physically identify a USB Channel:
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);
}