用于写入文件的CAPL在离线模式下不起作用

时间:2019-10-04 12:39:34

标签: capl canoe

我编写了一个简单的CAPL程序,将数据输出到文件中。

离线模式下执行仿真时,文件上没有任何内容打印。我无法在在线模式下进行测试。我不明白为什么。

在主分支的在线/离线开关之后,将脚本置于测量设置中。我正在使用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);
}


2 个答案:

答案 0 :(得分:0)

如果我很快使用filePutString(buffer, elcount(buffer), fileHandle);,则会遇到缓冲区大小问题,并且程序崩溃。

使用WriteLineEx(file_link, type_of_logging, out_string)就像一种魅力。

答案 1 :(得分:-1)

可悲,但The Simulation Setup is not active in offline mode. Test Setup is not displayed.

来自帮助文档:Measurement Setup >> Online/Offline Mode >> Offline