TraceLocation
This parameter is used to set the folder on a computer in where the PCAN-Trace files will be stored.
If a session is running (a PCAN-Trace file is being written), TraceLocation instructs
the API to close the current PCAN-Trace file and to start the process again using the new location.
The name of the trace file cannot be freely specified. The base name of the trace file is always the name of the PCAN Channel being used, as specified in the
native PCAN-Basic library (PCAN_USBBUS1.trc, for example).
It is only possible to enhance the name with the date and/or time of creation of the file.
It is available since PCAN-Basic version 1.3.0.
This parameter is read/write. It can be configured and retrieved.
This value is a string containing a fully qualified and valid path to an existing directory on the executing computer. To use the default
path (calling process path) an empty string must be set.
Kind of Path | Value |
|---|
Custom path
|
A valid directory string (see Files and Paths).
|
Default path (calling process folder)
|
An empty string.
|
The default value is the path to the calling process folder.
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 set the location of the trace file for a USB Channel:
try
{
PcanChannel channelUsed = PcanChannel.Usb01;
if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
System.IO.DirectoryInfo info = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() + "Tracing_" + DateTime.Now.Date.ToString("yyyy.mm.dd"));
if (Api.SetValue(channelUsed, PcanParameter.TraceLocation, info.FullName) == PcanStatus.OK)
{
Console.WriteLine($"The folder for trace files was successfully set to:\n{info.FullName}");
}
else
{
Console.WriteLine("Error configuring the location of the trace files.");
}
Api.Uninitialize(channelUsed);
}
}
catch (Exception ex)
{
Console.WriteLine($"Error creating a folder: {ex.Message}.");
}
Try
Dim channelUsed As PcanChannel = PcanChannel.Usb01
If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
Dim info As System.IO.DirectoryInfo = System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() & "Tracing_" & Date.Now.[Date].ToString("yyyy.mm.dd"))
If Api.SetValue(channelUsed, PcanParameter.TraceLocation, info.FullName) = PcanStatus.OK Then
Console.WriteLine($"The folder for trace files was successfully set to: {info.FullName}")
Else
Console.WriteLine("Error configuring the location of the trace files.")
End If
Api.Uninitialize(channelUsed)
End If
Catch ex As Exception
Console.WriteLine($"Error creating a folder: {ex.Message}.")
End Try
try
{
PcanChannel channelUsed = PcanChannel::Usb01;
if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
System::IO::DirectoryInfo^ info = System::IO::Directory::CreateDirectory(System::IO::Path::GetTempPath() + "Tracing_" + DateTime::Now.Date.ToString("yyyy.mm.dd"));
if (Api::SetValue(channelUsed, PcanParameter::TraceLocation, info->FullName) == PcanStatus::OK)
{
Console::WriteLine("The folder for trace files was successfully set to:\n{0}", info->FullName);
}
else
{
Console::WriteLine("Error configuring the location of the trace files.");
}
Api::Uninitialize(channelUsed);
}
}
catch (Exception^ ex)
{
Console::WriteLine("Error creating a folder: {0}.", ex->Message);
}