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

Access to disk_sys

paulo
2011-12-20
2011-12-20
  • paulo - 2011-12-20

    Helo,

    I'm trying to access files from internal memory (create, open and write), but even using SysLibAsync I still getting watchdog timout when try to execute de open command.

    The code that I wrote for tests are below. Any idea of what I can do to avoid that watchdog exception?

    SYSFILE_OPEN : SysFileOpenAsync;
    SYSFILE_CLOSE : SysFileCloseAsync;
    SYSFILE_WRITE : SysFileWriteAsync;
    BUFFER : STRING := 'test';
    FILE : DWORD := 0;
    WRITEN : DWORD;
    ERROR : BOOL;
    ERRORID : WORD;
    ESTADO : INT := 0;
    PRONTO : BOOL;

    CASE ESTADO OF
    0: (Abrindo o arquivo)
    SYSFILE_OPEN(stFileName := '\My Documents\teste.txt', stMode := 'a', bEnable := TRUE, hFile => FILE, bError=> ERROR, wErrorID => ERRORID, bDone => PRONTO);
    IF PRONTO THEN
    ESTADO := 1;
    END_IF
    1: (Escrevendo no arquivo)
    SYSFILE_WRITE(hFile := FILE, pBuffer := ADR(BUFFER ), dwSize:= SIZEOF(BUFFER ), bError=> ERROR, wErrorID => ERRORID, dwWrite => WRITEN, bEnable := TRUE, bDone => PRONTO);
    IF PRONTO THEN
    ESTADO := 2;
    END_IF
    2: (Fechando o arquivo)
    SYSFILE_CLOSE(hFile := FILE, bEnable := TRUE, bDone => PRONTO);
    IF PRONTO THEN
    SYSFILE_OPEN(bEnable := FALSE);
    SYSFILE_WRITE(bEnable := FALSE);
    SYSFILE_CLOSE(bEnable := FALSE);
    ESTADO := 0;
    END_IF
    ELSE
    ESTADO := 0;
    END_CASE

     
  • singleton - 2011-12-20

    Hi,
    try to execute read/write operations in a separate low priority task with enough cycletime.
    SysFileOpen can take up to 100ms and SysFileWrite can take several 100ms.

    That should be the source of your watchdog

     

Log in to post a comment.