I have problem with timeout in the "SysComRead" function.
I send the message with COM port successfully and then I want to read the answer, but function "SysComRead" doesn't wait for setting timeout to the answer.
How may I set this communication?
Thank you for your help.
Here is part of my code:
```
Global variables:
  port: PORTS:=COM1;
  setting: COMSETTINGS := (Port:=COM1,
        dwBaudRate:=9600,
        byStopBits:=0,
        byParity:=0,
        dwTimeout:=5000,
        dwBufferSize:=0,
        dwScan:=0);
Function:
  handle: DWORD;
  message: ARRAY [0..9] OF BYTE;
  handle := SysComOpen( port );   ( Open COM port )
  SysComSetSettings(dwHandle:=handle, ComSettings:=ADR(setting));   ( Setting up communication )
  SysComWrite(handle, ADR(message), 7, 5000);   ( Send message (7bytes) )
  SysComRead(handle, ADR(message), 3, 5000);   ( Read answer (3bytes) )
  SysComClose(handle);   ( Close COM port )
```[/code]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have problem with timeout in the "SysComRead" function.
I send the message with COM port successfully and then I want to read the answer, but function "SysComRead" doesn't wait for setting timeout to the answer.
How may I set this communication?
Thank you for your help.
Here is part of my code:
```
Global variables:
  port: PORTS:=COM1;
  setting: COMSETTINGS := (Port:=COM1,
        dwBaudRate:=9600,
        byStopBits:=0,
        byParity:=0,
        dwTimeout:=5000,
        dwBufferSize:=0,
        dwScan:=0);
Function:
  handle: DWORD;
  message: ARRAY [0..9] OF BYTE;
  handle := SysComOpen( port );   ( Open COM port )
  SysComSetSettings(dwHandle:=handle, ComSettings:=ADR(setting));   ( Setting up communication )
  SysComWrite(handle, ADR(message), 7, 5000);   ( Send message (7bytes) )
  SysComRead(handle, ADR(message), 3, 5000);   ( Read answer (3bytes) )
  SysComClose(handle);   ( Close COM port )
```[/code]
Hello,
Here is answer from CoDeSys support:
The timeout is the time a function waits in total till it returns.
If the function is called and no data is available then it returns immediately.
I think you must wait until you call the read function as it seems that it takes some time till data is available.