jari-koivuluoma - 2023-09-08

FB jsonFileWriter gives a NULL_POINTER error, why?

JSONByteArrayWriter works fine so the JSONData FB should be fine.

The device is CODESYS Control Win V3 x64 in simulation mode.

Codesys version is V3.5 SP16 Patch 5

JSON_Utilities_SL version is 1.3.0.0

Src: ST_TestStruct1a;
TXT: WSTRING(10000);
MakeJSON : BOOL := TRUE;
SrcJSONData: JSON.JSONData;
jsonFileWriter : JSON.JSONFileWriter;

IF MakeJSON THEN
    MakeJSON := FALSE;

    // Struct data to JSONData FB
    F_TestStructToJSON(ADR(Src),ADR(SrcJSONData));

    // Writing to file
    jsonFileWriter(
        xExecute := TRUE,
        sFileName := 'c:\JSONTEST\JSON.txt',
        eEncoding := JSON.Encoding.UTF_16,
        xAsyncMode := TRUE,
        jsonData := SrcJSONData
    );

    // Waiting to finish
    WHILE jsonFileWriter.xBusy DO
        ;
    END_WHILE

    // To text
    jsonArrayWriter(
        xExecute := TRUE,
        pwData := ADR(TXT),
        udiSize := SIZEOF(TXT),
        jsonData := SrcJSONData,
        xAsyncMode := FALSE,
    );
END_IF