Twincat FileRead/Invalid or unknown file handle

Join Date
Feb 2009
Location
Ant
Posts
54
Guys,

I get error ID 'Invalid or unknown file handle' when I want to read a file after opening it in Twincat.

The first time I tried to read it, it worked.

After changing my structure of the ReadBuffer instance(FILEDATA) I get this error.

All my files are in the correct directory.

I see some strange things happening with the 'file handler' address. Everytime when opening the file, the address is different?

Code:
fbFileRead(sNetId:='',
              hFile:=hFile,
              pReadBuff:=ADR(FILEDATA),
              cbReadLen:=SIZEOF(FILEDATA),
              bExecute:=bFileRead,
              bBusy=>bFileReadBusy,
              bError=>bFileReadError,
              nErrId=>nFileReadErrorId,
              cbRead=>nFileReadCount,
              bEOF=>bFileReadEOF);




Kind regards
 
Last edited:
Hi PlayerByNature, The file handle should be unique, it should be different every time you open the file. You only have to open a file once, once you get a handle too it, you can use that handle as long as you want, are you trying to open the file more than once?

If your code isn't proprietary, upload your code on a here via an attachment and I'll give it a look. Otherwise PM me and I'll talk to you via e-mail.
 
Steve, yes, the fileopen function was hanging in a constant loop. But the handler was the same value in every cycle.
 
Make sure you call the fb with the execute input set to False when you have finished with it, otherwise it will never see another rising edge on it's input

Roger
 

Similar Topics

I'm trying to control a device via MODBUS RTU and the ModbusRtuMasterV2_PcCOM in Twincat 3. I've configured a device with the right com port and...
Replies
7
Views
197
Hi! I am trying to run the 'SimpleSample' (https://infosys.beckhoff.com/content/1033/TF5100_TC3_NC_I/Resources/3438746891/.zip ) to understand the...
Replies
2
Views
100
I am developing a library in twincat and one of the function uses IID_ITcVnAccess_TcVnPoint2_DINT and the definition of this type is defined in...
Replies
0
Views
70
Sorry if this has been asked before, and apologies if this seems like a trivial issue, but I am new to Beckhoff and have been banging my head...
Replies
2
Views
148
Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
990
Back
Top Bottom