Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

CSV.CSVWriter End of Buffer Error

mrehberg
2021-10-14
2021-10-15
  • mrehberg - 2021-10-14

    Hey there,

    I am running an application and using the CSVWriter as a data logger. It will work well for 29 kb but then stops recording.
    The CSVWriter parameter logDemoExiration turns true when this 29 kb limit is hit. I have the license for the SL IoT library which contains the CSV utility installed on my workstation so I am thinking it may be some other reason. At this time my add values to file function throws the "End_of_buffer" error.

    I essentially copied the code I am using to write the CSV from the Codesys sample project on the matter.

    Anyone know why this 29 kb limit is being reached? Or a better way of logging data (my application will only be used for a batch experiment so server level data management doesn't really apply) ?

     
  • mrehberg - 2021-10-14

    Figured it out I believe. Its been able to save 16, 8 kb files so far and is still trugging along.

    The save program from the codesys example project does not CSVWriter.InitSave the new file that is created when the max file size has been reached. The following code changes the the initiated file name to the new file. 'First' is written to be TRUE by a StartDone program.

    IF First THEN
    FileName:=standard.CONCAT(sFileName,'.csv');
    ELSE
    FileName:=standard.CONCAT(sFileName,standard.CONCAT('(',standard.CONCAT(INT_TO_STRING(count), standard.CONCAT( ')', '.csv'))));
    END_IF

    IF NOT xInit THEN
    eError := Globals.gCSVWriter.InitSave( sDirectoryPath:=sDirectoryPath, sFileName:=FileName);
    IF eError <> CSV.CSV_ERROR.NO_ERROR THEN
    iSave := 32767;
    END_IF
    xInit := TRUE;
    END_IF

    CASE iSave OF

    0:
        (* Save the data from the buffer*)
        IF Globals.gCSVWriter.Save() <> CSV.CSV_ERROR.NO_ERROR THEN
            iSave := 32767;
        END_IF
        (* When the file is bigger, than 8000 Byte, a new file with an generated name is created.*)
        udiFileSize :=  Globals.gCSVWriter.GetFileSize(peError := ADR(eError));
        IF eError = CSV.CSV_ERROR.NO_ERROR AND udiFileSize > 8000 THEN
            count:=count+1;
            First:=FALSE;
            Globals.gCSVWriter.NewFile('');
            Sequential_Add_Values.First:=TRUE;
        END_IF
    
        IF  eError <> CSV.CSV_ERROR.NO_ERROR THEN
            iSave := 32767;
        END_IF
    
    32767: (* Error *);
    

    END_CASE

     
  • mrehberg - 2021-10-14

    Nope. It appears the it was not limited by the amount of data but instead there is a 30 minute timer on the CSV utility before it is not possible to write data.

    But there is no license for the CSV utility since its part of the IIOT library now. Codesys, what is the solution here?

     
  • i-campbell

    i-campbell - 2021-10-15

    You need to install an IIoT Libraries SL license on your PLC, to use any libraries from IIoT Libraries SL.

     

Log in to post a comment.