gibt es eine Funktion/Bibliothek um den Steuerungsnamen aus CODESYSCONTROL.CFG auszulesen?
Oder muss ich das von Hand und mit SysFile selbst bewerkstelligen?
Does a function/library exist to read out the nodename-value from CODESYSCONTROL.CFG?
Or do I have to read manually with library 'SysFile'?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Good question. Please share your solution if you have found out how to do this.
You could use the CmpApp library to get information about the application, but as far as I have seen this doesn't give information about the device name.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
my solution, quick and possibly "dirty" -> is there a better solution ?
e.g.
PROGRAMReadOutSysInfosVAR
  init: BOOL;
  strTemp: STRING(255);
  strBoardName: STRING(30);
  strBoardName2: STRING(30);
  wstrBoardName2: WSTRING(30);
  fileHandle:   SysTypes.RTS_IEC_HANDLE;            // File handle number
  fileName:    STRING[63] :='/flashdisk/CodesysV3/CoDeSysControl.cfg';    // Path and file name
  rte:       RTS_IEC_RESULT;            // Error code according runtime error list
  ptrToString: POINTERTOBYTE;
  ptrToString1: POINTERTOBYTE;
  ptrToString1a: POINTERTOSTRING(255);
  strCmp1: STRING(12):='[SysTarget]';
  readSize: UDINT :=constantReadSize;
  bytesRead: UDINT :=0;
  udi :UDINT;
  readLog:    ARRAY [0..constantReadSize] OFBYTE;// Array to read old logs
  str_offset: INT;
  str_offset2: INT;
  iLen: INT;
  strComponent : STRING:='SysTarget';
  strKeyValue: STRING:='NodeName';END_VARVARCONSTANT
  constantReadSize:  UDINT:=4000;  END_VARIFinit=FALSETHEN
  IFstrBoardName=''THEN
    fileHandle :=SysFileOpen(fileName, AM_READ, ADR(rte));  // Open original file
    IF(fileHandle=16#FFFFFFFF)OR(fileHandle=0)THEN
      strBoardName :='invalid handle';
    ELSE
      strBoardName :='not found';
      ptrToString :=ADR(readLog);
      ptrToString1 :=ADR(strCmp1);
      bytesRead :=SysFileRead(fileHandle, ptrToString, readSize, ADR(rte));  // Read the original file
      FORudi:=1TO(bytesRead-250)DO
        ptrToString1a :=ptrToString;
        str_offset :=Standard.FIND(ptrToString1a^, strCmp1);
        IFstr_offset>0THEN
          ptrToString1a :=ptrToString1a+str_offset;
          str_offset :=Standard.FIND(ptrToString1a^, 'NodeName=')+8;
          IFstr_offset>8THEN
            ptrToString1a :=ptrToString1a+str_offset+1;
            ptrToString1 :=ptrToString1a+Standard.FIND(ptrToString1a^, '$R')-2;
            ptrToString1^ :=0;
            strBoardName :=ptrToString1a^;
            EXIT;
          END_IF
        END_IF
        ptrToString :=ptrToString+1;
      END_FOR
      rte :=SysFileClose(fileHandle);        // Close original file
    END_IF
  END_IF
  init:=TRUE;END_IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hallo Forum,
gibt es eine Funktion/Bibliothek um den Steuerungsnamen aus CODESYSCONTROL.CFG auszulesen?
Oder muss ich das von Hand und mit SysFile selbst bewerkstelligen?
Does a function/library exist to read out the nodename-value from CODESYSCONTROL.CFG?
Or do I have to read manually with library 'SysFile'?
Good question. Please share your solution if you have found out how to do this.
You could use the CmpApp library to get information about the application, but as far as I have seen this doesn't give information about the device name.
my solution, quick and possibly "dirty" -> is there a better solution ?
e.g.