Activate debug-logging over Windows Registry

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
K.Wagner
Software Development
Software Development
Posts: 1076
Joined: Wed 22. Sep 2010, 13:36

Activate debug-logging over Windows Registry

Post by K.Wagner » Mon 4. Jun 2012, 10:59

Hello everybody,

As you know, PCAN-Basic allows you to save different data/information in a log file for debug purpose. This is achieved by configuring the kind of information you want to debug through the function PCAN_SetValue.

But sometimes, after the development and/or shipment phase of your application is done, it is possible that you need to do some extra checking, e.g. by using the log functionality. If this happens, there is no need to modify your code in order to include debug Information. PCAN-Basic allows you to set up the logging functionallity using the Windows's Registry :)

In order to enable Logging, follow these steps:
  1. Open the registry of Windows, e.g. using the "Start menu/execute/" command, by typing "regedit".
  2. Create the following registry key under the [HKEY_CURRENT_USER] hive: \Software\PEAK-System\PCAN-Basic\Log.
  3. To specify the data to be logged, add a new DWORD value to the key created before, called "Flags" and copy in there the value representing the desired configuration. This value is one LOG_FUNCTION_*** value or a combination of them. For example, for logging in/out CAN messages, the value should be 0x18 (LOG_FUNCTION_READ OR LOG_FUNCTION_WRITE).
  4. If you also want to save the file in a different folder than the default (folder of the calling application), then add a new string value to the key created before, called "Path" and copy in there the path to the directory you want. Example: Path="C:\Logs". Note that the path must exists; if it not, then the default path will be used.
  5. After your debug session is finished, delete the key created before (\Software\PEAK-System\PCAN-Basic\Log) to disable the logging functionality again.
VERY IMPORTANT: Please don't forget to delete the created key after your debug session is done. If you leave the key, all PCAN-Basic applications running under your account will remain writing data to their log files, generating in this way huge text files that consume hard-disk space unnecessarily.
Best regards,
Keneth

Post Reply