C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-20-2008, 02:54 AM   #1
Registered User
 
Join Date: Oct 2008
Posts: 1
Serial port communication timeout

Hello,
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.
Thanks!
John
johnfulgor is offline   Reply With Quote
Old 10-20-2008, 03:07 AM   #2
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
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.

--
Mats
__________________
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.
matsp is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 09:54 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22