I am currently working on a program that involves periodic reads from and writes to the serial port (interfacing with a device on the other end which can be queried and sends back responses). The program is working absolutely flawlessly except for the following: when running unattended, i.e. no user interaction by mouse, keyboard, or otherwise, the OS (Windows XP) will switch the computer into standby mode after 25 minutes. At this point, the program stops doing what it is supposed to do, i.e. reading and writing to and from the serial port (I suppose this is supposed to happen whenever the computer is placed into standby mode). After coming out of standby mode, the program is still running (or running again?), but reading/writing the serial port does not work, in the sense that I do not receive any responses from the device that I am attempting to communicate with. I would surmise that this is happening because the file handle is closed (I open the serial port when starting the program using the Win API CreateFile() function, and perform read and write operations using the ReadFile()/WriteFile() functions).
* is this expected behavior?
* why is the computer switched into standby mode when there is an active program running, albeit without any user input
* is the file handle for the serial port being closed when the computer is switched into standby mode? (for that matter, does this happen to 'regular' files as well?)
* what are the possibilities for resolving the issue? (the straightforward solution I can think of is to simply disable the standby/hibernate options from within the control panel)