Reading the Serial Port

S

sean_in_raleigh

There are various nonstandard packages that allow you to create
C++ streams from stdio streams or file descriptors:

http://wwwcdf.pd.infn.it/MLO/fd.tar.gz
http://www.google.com/search?q=__gnu_cxx::stdio_filebuf
http://www.boost.org/libs/iostreams/doc/classes/file_descriptor.html#file_descriptor

They let you do something along the lines of:

#include "fdstream.hh"

int fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
fdostream modem(fd)
modem << "8675309";


For the gory details on how talking to serial ports is different
to regular files, this would be a good start:

http://www.kohala.com/start/apue.html

Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top