1

I wrote a simple CAPL program to output data to a file.

When executing simulation in offline mode, nothing gets printed on file. I can't test it in online mode. I can't understand why.

Script is put in measurement setup right after the online/offline switch, on the main branch. I'm using CANoe.

/*@!Encoding:1252*/
includes
{

}

variables
{
    dword fileHandle;
    char buffer[1024];
}

on preStart
{
    setFilePath("mypath");
    fileHandle = openFileWrite("file.txt", 2);
}

on stopMeasurement
{
    fileClose(fileHandle);
}

on linFrame someFrame
{
    snprintf(buffer, elcount(buffer), "somestring %d", somevalue);
    filePutString(buffer, elcount(buffer), fileHandle);
}


Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
  • Which log-files do you use as a source in offline mode? Do they contain the expected LIN frames? Also, there is no online/offline switch in the simulation setups, I assume you are talking about the measurement setup, right? – MSpiller Oct 08 '19 at 12:07
  • I'm using log files that I know contain the expected LIN frames (I'm also working on the same log converted into ascii, I can see the frames). I took the log files myself earlier that day. This goes one with the fact that keyboard input appears to be ignored in the simulation when offline mode is used (and CANoe does not provide replay blocks in the measurement setup, except for the offline switch one). I also amended the question, you are right indeed. – Daemon Painter Oct 08 '19 at 13:07

2 Answers2

0

If I use filePutString(buffer, elcount(buffer), fileHandle); soon I encounter issues with the size of the buffer & the program crashes.

Using WriteLineEx(file_link, type_of_logging, out_string) worked like a charm.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
  • well, that has probably nothing to do with the buffer, but with how you fill the buffer. Are you putting too many chars in? Try to format your code properly and welcome to SO. – Daemon Painter Nov 25 '20 at 13:38
  • In any case, my code does not crash and works in Online mode, but not in Offline mode. How did you address this in your answer? – Daemon Painter Nov 25 '20 at 13:40
-1

Sadly, but The Simulation Setup is not active in offline mode. Test Setup is not displayed.

Taken from help doc: Measurement Setup >> Online/Offline Mode >> Offline

maslovw
  • 99
  • 6
  • The one I'm using is not a Test Setup, but a Programmable node on the Measurement Setup. If I put a `write()` condition in the CAPL code, I see the output in the Write Window. If I ask it to write to a file, I don't see this happening. – Daemon Painter Oct 14 '19 at 16:15