Page 1 of 2

Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 09:27
by yesweCAN
PCIE CANBUS
c# / Visual Studio
Windows

Hi,
I've implemented with success the log file in my application.
Now I would like to know If :
Is there a parameter to put the log file in a subdirectory of my application ? : "\\CANLog\\" for example
Is there a function to add text in the log file to write the step on my protocol in the file to read it easily ?
Is there a solution to add the Transmitted message in the message listview of your sample code ?

Thanks

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 09:39
by K.Wagner
Hello,

please check the available parameters for LOG handling:
PCAN-Basic-Log.JPG
PCAN-Basic-Log.JPG (36.65 KiB) Viewed 36088 times
yesweCAN wrote:
Fri 27. Oct 2023, 09:27
Is there a parameter to put the log file in a subdirectory of my application ? : "\\CANLog\\" for example
See PCAN_LOG_LOCATION
yesweCAN wrote:
Fri 27. Oct 2023, 09:27
Is there a function to add text in the log file to write the step on my protocol in the file to read it easily ?
See PCAN_LOG_TEXT
yesweCAN wrote:
Fri 27. Oct 2023, 09:27
Is there a solution to add the Transmitted message in the message listview of your sample code ?
Not sure to understand. IF you mean the GUI sample project, well transmitted messages are already being written in that List-View. This is just what that List-View is intended for.

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 09:45
by K.Wagner
Correction:
K.Wagner wrote:
Fri 27. Oct 2023, 09:27
Not sure to understand. IF you mean the GUI sample project, well transmitted messages are already being written in that List-View. This is just what that List-View is intended for.
Received messages are shwon here. If you want to include the transmitt messages you have to change the code, of course. Just study the code and see where you have to pass your transmitted messages and how to handle those information. It will be very similar to that what is already implemented for received messages

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 09:50
by F.Vergnaud
Hello,

You can enable the parameter PCAN_ALLOW_ECHO_FRAMES and you will receive your transmitted messages in the message listview.

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 09:52
by K.Wagner
I agree,

the solution from F.Vergnaud just suits best for your needs.

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 10:00
by yesweCAN
The log works fine thanks
Thanks for the ECHO tips but in the log it will appear in Rx instead Tx.

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 10:06
by K.Wagner
Please read your own question:
yesweCAN wrote:
Fri 27. Oct 2023, 09:27
Is there a solution to add the Transmitted message in the message listview of your sample code ?
The Echos are transmitt messages that will appear in the listview.

If you want to include sent and received messages in the LOG file you just need to configure the LOG as needed, by using PCAN_LOG_CONFIGURE. Please check and read the documentation. All paramerters are well documented and explained with sample code.

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 10:16
by yesweCAN
I've tried to add text in the log file like the documentation

Code: Select all

        private void VarStepChange(string Step)
        {
            if(PCANBasic.SetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_LOG_TEXT, Step, (uint)Step.Length) == TPCANStatus.PCAN_ERROR_OK)
                Console.WriteLine("logged sucessfully");
            else
                Console.WriteLine("Error! It was not possible to log own message");

        }
I can see the logged sucessfully in the console but the text is not added in the log

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 10:25
by yesweCAN
I don't want to add more message in the CAN BUS.
I will stay with the analyze of the log file.

Re: Add text in log file and change log directory

Posted: Fri 27. Oct 2023, 11:16
by K.Wagner
Hello,

If you principally want to analyse the CAN data, you should rather use a TRACE file (not log file). For generating such a file you have similar parameter to the LOG ones.