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.
IFxStartTHEN
  FileIdent:=SysFileOpen(FileName:=sFilename, Mode:='r');
  IFfileident<>0THEN
    SysFileRead(File:=Fileident, Buffer:=ADR(rawdata), Size:=SIZEOF(rawdata));
    filesizev:=SysFileGetSize(FileName:=sFilename);
    IFfilesizev>gc_RawDataSizeTHEN
      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(*copydatatotypDataarray*)
  startposition:=0;
  i:=0;
  FORj:=1TOiMaxParamsDO
    (*FirstvalueindatasetisoftypeDT. ThefollowingvalueisseperatedbybSeperator*)
    WHILErawdata[startposition+i]<>bSeperatorDO
      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;
    (*Theparametervaluesareoftypeword. ThefollowingvaluesareseperatedbybSeperator*)
    FORk:=1TOgc_ParameterCount-1DO
      WHILErawdata[startposition+i]<>bSeperatorDO
        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
    (*Copyingthelastparameterfromtypword. ThedatasetisterminatedbyCRLF*)
    WHILErawdata[startposition+i]<>bEndOfFileDO
      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(*copydatatotypDataarrayfinished*)
  sStatus:='Data read OK';
  xStart:=FALSE;END_IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
https://www.youtube.com/watch?v=ovTJ5AZY22g
Found out an other way for my task, just made an array in the retain memory, and write it to usb too.