Menu

Reading data from modem with read()

2007-08-08
2012-09-26
  • Nobody/Anonymous

    Hi All,

    I am writing a program to send/receive data from a modem, I have written a program which can do this, however, if I read from the modem and there is no information in the buffer the program hangs until information is received in the buffer, I was just wondering if anyone knows how to set a timeout for the read command(read(fd,buf, 1);).

    Thanks,

    Rob.

     
    • Anonymous

      Anonymous - 2007-08-08

      You might use SetCommTimeouts() ( http://msdn2.microsoft.com/en-us/library/aa363437.aspx ). I assume it will work even though you are using low-level I/O rather than Win32 I/O but if not you will have to use the Win32 comms API ( http://msdn2.microsoft.com/en-us/library/ms810467.aspx ).

      Using this API offers other solutions such as WaitForSingleObject(), overlapped I/O, and multi-threading - these are described in the article at the above link.

      Note also that Windows itself already supports modem communications using RAS for remote TCP/IP connections - this uses PPP to establish the connection.

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.