Reading data from serial port

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I am trying to read/write data to/from Serial port using C++ in Windows
98. I want to do this using fopen(), fwrite() and fread()functions or
inportb()and outportb() functions. But i don't know how to set the port
properties including baud rate, buffer size etc and to make the control
lines of port ready for reading/writting data. Please help me...


Re: Reading data from serial port

Quoted text here. Click to load it


Google "16550 UART", buy a book, or look here:
http://dzcomm.sourceforge.net

Regards,
Richard.



http://www.FreeRTOS.org



Re: Reading data from serial port

Quoted text here. Click to load it

Use CreateFile, ReadFile, WriteFile, SetupComm, SetCommState,
SetCpmmTimeouts etc. which should work an all Win32 platforms, while
manipulating the UART bits directly work in Win9x only.

Paul


Re: Reading data from serial port

Quoted text here. Click to load it

Use Cygwin, or learn Windows APIs.


Re: Reading data from serial port

Quoted text here. Click to load it

fopen, fread and fwrite for serial I/O? Hmm, since ANSI C doesn't
cover serial I/O, why use ANSI calls instead of generic Win32 API?
After all, it won't work.

Quoted text here. Click to load it

What the heck is inportb()and outportb()? Neither ANSI, nor Win32. You
want to access hardware registers? No need for Windows then.

Quoted text here. Click to load it

See http://sourceforge.net/projects/serialapi made by Andi Martin with
some contributions from me. Lacks still some documentation
(volunteers?), but is stable.

Since you have no clue (no offence meant), this seems to be the
easiest way.

Otherwise, get the Win32 Platform SDK and read at least "Serial
Communications in Win32" by Allen Denver
http://msdn.microsoft.com/library/en-us/dnfiles/html/msdn_serial.asp

Oliver
--
Oliver Betz, Muenchen (oliverbetz.de)

Site Timeline