How to create a .btrc or .asc file with the entire CAN frame in a own firmware?
How to create a .btrc or .asc file with the entire CAN frame in a own firmware?
Hi,
I am trying to create my own firmware in order to have channel routing and create a .btrc or .asc file with all the CAN frame information.
In the default firmware, a .btrc file is created with the entire CAN frame each time the "Log off card" button is pressed. That file is the one that I want to be able to create from my own firmware without having to press the "Log off card" button.
I've mostly seen the "21_RTOS_FILESYSTEM" example where it opens a .txt file if a message with ID=100 is sent to it, writes if the message has ID=101, and closes the file if the message has ID=102. This behavior is what I need, but instead of creating a .txt file with just the message data, I want it to create a .btrc or .asc file with the entire CAN frame.
Is there any example where it appears to create a .btrc or .asc file with all CAN traffic as in the default firmware?
Thank you!
I am trying to create my own firmware in order to have channel routing and create a .btrc or .asc file with all the CAN frame information.
In the default firmware, a .btrc file is created with the entire CAN frame each time the "Log off card" button is pressed. That file is the one that I want to be able to create from my own firmware without having to press the "Log off card" button.
I've mostly seen the "21_RTOS_FILESYSTEM" example where it opens a .txt file if a message with ID=100 is sent to it, writes if the message has ID=101, and closes the file if the message has ID=102. This behavior is what I need, but instead of creating a .txt file with just the message data, I want it to create a .btrc or .asc file with the entire CAN frame.
Is there any example where it appears to create a .btrc or .asc file with all CAN traffic as in the default firmware?
Thank you!
Re: How to create a .btrc or .asc file with the entire CAN frame in a own firmware?
Hi,
yes, the "21_RTOS_FILESYSTEM" is the only example source we have for writing files to SD card. Unfortunately we do not open the *.btrc format to the public (only the *.trc forma, see: https://www.peak-system.com/quick/DOC-TRC-CAN). If you want to write in *.asc file format, you have to take care to use the file format specification of that log format. An example source for this format is not available from us, but you will find some tools on github which will use that format.
regards
Michael
yes, the "21_RTOS_FILESYSTEM" is the only example source we have for writing files to SD card. Unfortunately we do not open the *.btrc format to the public (only the *.trc forma, see: https://www.peak-system.com/quick/DOC-TRC-CAN). If you want to write in *.asc file format, you have to take care to use the file format specification of that log format. An example source for this format is not available from us, but you will find some tools on github which will use that format.
regards
Michael
Re: How to create a .btrc or .asc file with the entire CAN frame in a own firmware?
Hi Michael,
First of all, thanks for your answer.
The .trc format file would also work for me.
Would it be possible to have a small code example of how to open and write to a .trc file all the CAN information a channel receives please?
thank you!
First of all, thanks for your answer.
The .trc format file would also work for me.
Would it be possible to have a small code example of how to open and write to a .trc file all the CAN information a channel receives please?
thank you!
Re: How to create a .btrc or .asc file with the entire CAN frame in a own firmware?
Hi,
please see main.c line 338 of 21_RTOS_FILESYSTEM example :
In that example the following steps are necessary to write to the eMMC card:
- with ID 0x100 you open the file for the write process (card will be mounted), file name: Example_21_File.txt
- with ID 0x101 the data bytes of the message will be written to the file
- with ID 0x102 the file will be closed and the eMMC card will be unmounted, so that you can access it again by other tasks (USB connection etc.).
regards
Michael
please see main.c line 338 of 21_RTOS_FILESYSTEM example :
Code: Select all
// catch ID 100h to mount eMMC and open file
if ( RxMsg.id == 0x100 && ! myFileIsOpen)
{
// pass USB to me. This will kick USB host machine accessing the memory devices !!
HW_PassUsbToMe();
// mount MSD
frslt = f_mount ( &fs_msd, MY_MSD_DRIVE, 1);
if ( frslt != FR_OK)
{
HW_SetLED ( HW_LED_STATUS, HW_LED_RED);
break;
}
// open file
frslt = f_open ( &hMyFile, MY_MSD_DRIVE "\\Example_21_File.txt", FA_WRITE | FA_CREATE_ALWAYS);
if ( frslt != FR_OK)
{
HW_SetLED ( HW_LED_STATUS, HW_LED_ORANGE);
break;
}
myFileIsOpen = 1;
}
// catch ID 101h to write some data to file
else if ( RxMsg.id == 0x101 && myFileIsOpen)
{
// write to file
char dataAsText[30];
uint32_t bytes2write, dlc, i;
UINT bw;
bytes2write = 1;
// limit DLC
dlc = RxMsg.dlc > 8 ? 8 : RxMsg.dlc;
// write up to 8 bytes like
// 02,11,22,33,44,
for ( i = 0; i < dlc; i++)
{
dataAsText[i*3+0] = hex2ascii[RxMsg.data8[i] >> 4];
dataAsText[i*3+1] = hex2ascii[RxMsg.data8[i] & 0xF];
dataAsText[i*3+2] = ',';
bytes2write += 3;
}
// line ends with \n
dataAsText[i*3+0] = '\n';
// write line to file
frslt = f_write ( &hMyFile, dataAsText, bytes2write, &bw);
if ( frslt != FR_OK)
{
HW_SetLED ( HW_LED_STATUS, HW_LED_RED);
break;
}
}
// catch ID 102h to close file, unmount eMMC and enable access to USB host
else if ( RxMsg.id == 0x102 && myFileIsOpen)
{
// close file
frslt = f_close ( &hMyFile);
if ( frslt != FR_OK)
{
HW_SetLED ( HW_LED_STATUS, HW_LED_RED);
break;
}
myFileIsOpen = 0;
frslt = f_unmount ( MY_MSD_DRIVE);
if ( frslt != FR_OK)
{
HW_SetLED ( HW_LED_STATUS, HW_LED_ORANGE);
break;
}
// pass USB back to host machine
HW_PassUsbToHost();
}
- with ID 0x100 you open the file for the write process (card will be mounted), file name: Example_21_File.txt
- with ID 0x101 the data bytes of the message will be written to the file
- with ID 0x102 the file will be closed and the eMMC card will be unmounted, so that you can access it again by other tasks (USB connection etc.).
regards
Michael
Re: How to create a .btrc or .asc file with the entire CAN frame in a own firmware?
Hi,
I think there was a confusion when explaining myself. What I wanted to refer to is having an example of how to open and write the entire CAN frame in a .trc file, including all the columns such as timestamp, type, bus, id, Rx/Tx, data length, data, etc.
A structure like in the link you gave me of the .trc file format.
Thank you!
I think there was a confusion when explaining myself. What I wanted to refer to is having an example of how to open and write the entire CAN frame in a .trc file, including all the columns such as timestamp, type, bus, id, Rx/Tx, data length, data, etc.
A structure like in the link you gave me of the .trc file format.
Thank you!
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: How to create a .btrc or .asc file with the entire CAN frame in a own firmware?
We do not offer a "ready to use" Lib or Function code.
It is a simple Text based file , all is explained in this PDF https://www.peak-system.com/quick/DOC-TRC-CAN
When you check the content of CAN-Frame that you received , you have all needed parts.
It is a simple Text based file , all is explained in this PDF https://www.peak-system.com/quick/DOC-TRC-CAN
When you check the content of CAN-Frame that you received , you have all needed parts.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------