Thread: Serial port communication timeout

  1. #1
    Registered User
    Join Date
    Oct 2008

    Serial port communication timeout

    I'm implementing a simple protocol to communicate to a device via serial port.
    My program should:
    1)Write a packet
    2)Wait till a timer is expired, or exactly N characters are read

    In other words a complete packet should arrive within a certain time, or the read fails.

    I've read about termios config (VMIN & VTIME), as well as about open system call flags, but I'm a bit confused and need some clarification.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    VMIN and VTIME is a bit tricky to get right.

    I think, if you have a set packet size, then you can set VMIN to the number of characters, and VTIME to the timeout value.

    If you have a variable packet size, then you will need to use a different technique - the best way is to set it up so that you have a short timeout, and then use a different mechanism (such as a timer) to detect overall timeouts.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. serial port to poll on request
    By infineonintern in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2009, 06:52 AM
  2. Duplex communication thro serial port
    By Priyachu in forum Networking/Device Communication
    Replies: 1
    Last Post: 05-30-2009, 04:24 AM
  3. Duplex communication thro serial port
    By Priyachu in forum Linux Programming
    Replies: 1
    Last Post: 05-30-2009, 04:03 AM
  4. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM
  5. Need help or info about serial port communication
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 01-08-2002, 01:48 PM