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

FILE.Diropen on Raspberry PI

i.nendels
2015-03-20
2015-03-21
  • i.nendels - 2015-03-20

    Hi,

    I am trying to use som file acces on my Raspberry PI but i don't know what i'm doing wrong.
    For a test i first try to open a directory for listing but it doesn't work.

    here is my code

    PROGRAM PLC_PRG
    VAR
       TimerOn      : TON :=(pt:=T#30S);
       xDirOpen     : BOOL;
       DirOpen      : FILE.DirOpen;
       DirList      : FILE.DirList;
    END_VAR
    TimerOn (IN:= DirList.xExecute);
    DirOpen.sDirName := '/tmp';
    IF xDirOpen  THEN 
    DirOpen.xExecute := TRUE;
    xDirOpen := FALSE;
    END_IF
    DirList.hDir := DirOpen.hDir;
    IF DirOpen.xDone OR TimerOn.Q OR DirOpen.eError > 0 OR DirOpen.xError THEN
       DirOpen.xExecute := FALSE;
    END_IF
    

    And here is the watchlist output.

    DirOpen.xExecute is TRUE but no error or busy and done also stays FALSE

    i hope someone has a solution for me.

    IMG: WatchList.jpg

     
  • plcmax - 2015-03-21

    Hi,

    In your code snippet we are missing the function call:
    SysDirOpen();
    you only set the Inputs of SysDirOpen you missed to call the function.
    There is a good example in the store:

    http://store.codesys.com/application/fi ... ities.html

    Regards
    plcmax

     
  • i.nendels - 2015-03-21

    Ty for your answer. I tested the example and sysdiropen worked oke. So i can use it in my program.

     

Log in to post a comment.