finally some working code 0x0006

today I solved one of my problems.

of course I will also provide you my solution. It was the simple question, how to write some data into a textfile for later analysis.

variables
{
byte buffer[1024];   // receive buffer for CAN-data via OSEK_tp.dll (1024 byte)
char StringLong[howeverlongyouneedit];  // for output string
dword glbHandle = 0;
}
OSEKTL_DataInd (long rxCount) /function to receive data via OSEK_tp.dll
{

[some code…]

OSEKTL_GetRxData( buffer, rxCount );
EmpfangAuswerten(rxCount);

[some code…]

}

/*with the OSEK function, we’re able to send and receive data directly to an addressed ECU. That said, if we do a diagnosis request to our ECU and read the memory by Address, the cells  of the memory are looking like this: Address: 0x0000, 0x0001, …. ; data: 0x00 … 0xFF. So this would be memory size of 1. We can handle this via a PDU command which looks like (naaah, I wouldn’t tell you, I guess its very specific, lets just say its looking like) 11 22 00 00 01 00 01, where some of the fields gives us the address (e.g. 01 00 = #256) and the „01“ at the end a memory size of 1.*/

/*[send a Request to ECU – read memory – e.g. 4 cells Memory]
[receive Response – e.g. 00 01 02 01] ; response is written in „buffer“*/
glbHandle = openFileWrite („testreport.txt“,0);

/* Format and store the data */
snprintf(StringLong, elcount(StringLong), „bufferdata: %02X … %02X\n“,buffer[1], buffer[2], …, buffer[i]); //in this case i = 4

/*I did it the way that the number of „%02X“ equals number of „i“ — which is veeery complicated when you want to read >> 100 byte) */
filePutString (StringLong, elcount(StringLong),glbHandle);
fileClose(glbHandle);

finally some working code 0x0006

Hinterlasse einen Kommentar