Reading data from serial port

I am trying to read/write data to/from Serial port using C++ in Windows

  1. 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...
Reply to
Naeem
Loading thread data ...

Google "16550 UART", buy a book, or look here:

formatting link

Regards, Richard.

formatting link

Reply to
Richard

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

Reply to
Paul Keinanen

Use Cygwin, or learn Windows APIs.

Reply to
larwe

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.

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

See

formatting link
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

formatting link

Oliver

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

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.