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

IFM - CR1081 *.cvs file read.

Sendarix
2014-09-25
2014-09-30
  • Sendarix - 2014-09-25

    Hello, as the title says, I'm using a IFM CR1081 panel, and write string array to an cvs file. But I can't seem to find out how to read it from the storage of the panel. I do not wish to split the text line into several lines, only 1. Using Timestamp AND 'Sensor ' AND a number that indicates which sensor that has trigged.

    Read/Write to the panel from the USB flash drive is ready, the only thing that I need is to actually read the *.cvs file that I recieve from the USB-storage.

    So, writing from the panel into *.cvs file, to the USB-Flash drive, then automatically back to the panel, and read it and show it in a table is what I want to do.

    • Sendarix

    https://www.youtube.com/watch?v=ovTJ5AZY22g

    IF xStart THEN
       FileIdent:=SysFileOpen(FileName:=sFilename, Mode:='r');
       IF fileident<>0 THEN
          SysFileRead(File:=Fileident, Buffer:=ADR(rawdata), Size:=SIZEOF(rawdata));
          filesizev:=SysFileGetSize(FileName:=sFilename);
          IF filesizev>gc_RawDataSize THEN
             filesizev:=gc_RawDataSize;
          END_IF
          SysFileClose(File:=fileident);(*this function is blocking*)
       ELSE
          sStatus:='File does not exist';
          xStart:=FALSE;
          RETURN;(*no such file available*)
       END_IF
    (*copy data to typData array*)
       startposition:=0;
       i:=0;
       FOR j:=1 TO iMaxParams DO
          (*First value in dataset is of type DT. The following value is seperated by bSeperator*)
          WHILE rawdata[startposition+i]<>bSeperator DO
             i:=i+1;
          END_WHILE
          rawdata[startposition+i]:=0;
          MEMCPY(pSourceAddress:=ADR(rawdata[startposition]), pDestinationAddress:=ADR(tempstring), BytesToCopy:=i+1);
          typdata[j].sDescription:=tempstring;
          startposition:=startposition+i+1;
          i:=0;
          (*The parameter values are of type word. The following values are seperated by bSeperator*)
          FOR k:=1 TO gc_ParameterCount-1 DO
             WHILE rawdata[startposition+i]<>bSeperator DO
                i:=i+1;
             END_WHILE
             rawdata[startposition+i]:=0;
             MEMCPY(pSourceAddress:=ADR(rawdata[startposition]), pDestinationAddress:=ADR(tempstring), BytesToCopy:=i+1);
             typdata[j].Parameter[k]:=STRING_TO_REAL(tempstring);
             startposition:=startposition+i+1;
             i:=0;
          END_FOR
          (*Copying the last parameter from typ word. The data set is terminated by CR LF*)
          WHILE rawdata[startposition+i]<>bEndOfFile DO
             i:=i+1;
          END_WHILE
          rawdata[startposition+i]:=0;
          MEMCPY(pSourceAddress:=ADR(rawdata[startposition]), pDestinationAddress:=ADR(tempstring), BytesToCopy:=i+1);
          typdata[j].Parameter[k]:=STRING_TO_REAL(tempstring);
          startposition:=startposition+i+2;(*The data set is terminated by CR LF(13,10)*)
          i:=0;
       END_FOR
    (*copy data to typData array finished*)
       sStatus:='Data read OK';
       xStart:=FALSE;
    END_IF
    
     
  • Sendarix - 2014-09-30

    Found out an other way for my task, just made an array in the retain memory, and write it to usb too.

     

Log in to post a comment.