I am facing an issue while configuring the trace file location using PCAN-Basic API.
When I set TPCANParameter.PCAN_TRACE_LOCATION to a specific folder for the first time, it works correctly.
However, when I try to set the same folder again, the API returns an error.
Code snippet:
Code: Select all
ushort channelUsed = PCANBasic.PCAN_USBBUS1;
string tracesFolder = System.IO.Path.GetTempPath();
string fullPath;
fullPath = System.IO.Path.Combine(tracesFolder, "PCAN-Basic_Flashing");
System.IO.Directory.CreateDirectory(fullPath);
if (PCANBasic.Initialize(channelUsed, TPCANBaudrate.PCAN_BAUD_500K) == TPCANStatus.PCAN_ERROR_OK)
{
if (PCANBasic.SetValue(
channelUsed,
TPCANParameter.PCAN_TRACE_LOCATION,
fullPath,
(uint)fullPath.Length) == TPCANStatus.PCAN_ERROR_OK)
{
Console.WriteLine("Trace location set successfully");
}
else
{
Console.WriteLine("Error while setting trace location");
}
}- First time setting trace location → Success
- Setting same folder again → Error
Is PCAN_TRACE_LOCATION required to be set only before Initialize()?
Is Uninitialize() required before setting it again?
Any guidance would be appreciated.
Best regards,
Pranav Bodke
