Sep 16, 2010 at 10:02am UTC
Hi All,
I really need your help and advise to save the databyte output on file(.dat or csv or .txt). I have canbus data comes from hardware and i develop software to record all output on file.
Below are the code:
int8_t receiveCallback(cb_DataReceivedInfo_t* rcvInfos)
{
if (rcvInfos->status < 0) { /* multipacket transfer aborted */
receiveBufferActive = 0;
return 0;
}
ofstream j1939File("j1939.txt", ios::out);
if (!j1939File)
{
printf("File cant be found");
exit(1);
}
case 61442:
{ int iTransInputShaftSpdraw=0;
for (int i = 0; i < rcvInfos->dataLen; i++)
int iTransInputShaftSpdraw = (rcvInfos->data[7]);
int iTransInputShaftSpd=iTransInputShaftSpdraw*0.125;
int iTransOutputShaftSpdraw = (rcvInfos->data[3]) ;
int iTransOutputShaftSpd = (iTransOutputShaftSpdraw*0.125);
printf("TransInputShaftSpd [SPN161] = %d RPM\n",iTransInputShaftSpd);
printf("TransOutputShaftSpd [SPN161] = %f RPM\n",iTransOutputShaftSpd);
j1939File<< rcvInfos->data <<' '<< endl;
printf("\n");
}
break;
Issue: The file.txt is created, but it was empty (no output captured).
Please kindly help. !
Sinaga00
Sep 16, 2010 at 11:31am UTC
hello Sinaga00,
What's this -> for (int i = 0; i < rcvInfos->dataLen; i++)
? A loop without { }?
What's the type of 'rcvInfos->data'?