Add text in log file and change log directory

The free CAN Software API (Application Programming Interface) for Windows®
yesweCAN
Posts: 14
Joined: Tue 25. Jul 2023, 14:34

Add text in log file and change log directory

Post by yesweCAN » Fri 27. Oct 2023, 09:27

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

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Add text in log file and change log directory

Post by K.Wagner » Fri 27. Oct 2023, 09:39

Hello,

please check the available parameters for LOG handling:
PCAN-Basic-Log.JPG
PCAN-Basic-Log.JPG (36.65 KiB) Viewed 36092 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.
Best regards,
Keneth

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Add text in log file and change log directory

Post by K.Wagner » Fri 27. Oct 2023, 09:45

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
Best regards,
Keneth

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: Add text in log file and change log directory

Post by F.Vergnaud » Fri 27. Oct 2023, 09:50

Hello,

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

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Add text in log file and change log directory

Post by K.Wagner » Fri 27. Oct 2023, 09:52

I agree,

the solution from F.Vergnaud just suits best for your needs.
Best regards,
Keneth

yesweCAN
Posts: 14
Joined: Tue 25. Jul 2023, 14:34

Re: Add text in log file and change log directory

Post by yesweCAN » Fri 27. Oct 2023, 10:00

The log works fine thanks
Thanks for the ECHO tips but in the log it will appear in Rx instead Tx.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Add text in log file and change log directory

Post by K.Wagner » Fri 27. Oct 2023, 10:06

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.
Best regards,
Keneth

yesweCAN
Posts: 14
Joined: Tue 25. Jul 2023, 14:34

Re: Add text in log file and change log directory

Post by yesweCAN » Fri 27. Oct 2023, 10:16

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

yesweCAN
Posts: 14
Joined: Tue 25. Jul 2023, 14:34

Re: Add text in log file and change log directory

Post by yesweCAN » Fri 27. Oct 2023, 10:25

I don't want to add more message in the CAN BUS.
I will stay with the analyze of the log file.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Add text in log file and change log directory

Post by K.Wagner » Fri 27. Oct 2023, 11:16

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.
Attachments
TRACE.JPG
TRACE.JPG (30.76 KiB) Viewed 36074 times
Best regards,
Keneth

Locked