Subj : Re: reading com port To : wanes98 From : Jeff Silverman Date : Sun Aug 22 2004 07:32 am On Sat, 21 Aug 2004 23:11:46 -0400, wanes98 wrote: > Hello > I am connecting a device to one of the com port of the PC > is there any code or directin on how to start. > I might be using C programming for this project > thanks > wanes There is a lot of material on this subject. I recomend the Linux Serial How-to for starters. First of all, the serial ports are /dev/ttySx where x varies from 0 to 3 in a standard PC configuration (you can have hundreds of serial ports on a PC if you want to go to an oddball configuration). You can change the baud rate and other characteristics of a serial port with the setserial command. If you just want to read data from a serial port into a program, you can do that very easily using redirection: program < /dev/ttyS0 or program < /dev/ttyS0 > /dev/ttyS1 for example. If you have to have asynchronous I/O or if you want to avoid having your program hang waiting for a character, then you have to either use threads or multiple processes or you can use the select(2) system service call. My recommendation is that if you can avoid asynchronous I/O, then avoid asynchronous I/O, because it is challenging to debug. Be wary also of the "Deadly embrace" problem, where both your program and the remote device are waiting for the other. I hope this is helpful. Jeff .