TraceStatus

This parameter allows to control the activity status of a trace session within the PCAN-Basic API.

  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

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

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

See Also