Hey ppl,
I'm doing a project which needs serial communication. I'm sending and receiving data from a PIC through the serial port. I'm using Windows XP and dev cpp.
I'm succesfully sending data by my program to the PIC. I'm using inpout32.dll file to access serial port because windows dosen't give direct access to those ports.
The problem occurs when reading the data I get from the PIC. I need to read 30 characters sent by the PIC, but I couldn't do it by my program. But I get all that data to hyperterminal.
So is there any syntax or header file in c to read data from serial port????

Most likely your program is losing data because it does not have an interrupt driven input driver. If you used win32 api functions you would not have that problem. See this article

There is no standard library functions in C for serial port access because it is too platform dependent.

The Win32 API does support serial ort access however mildly confusingly you have to use CreateFile to open a serial port and ReadFile and WriteFile to read and write data to it.

There are a bunch of specific comfiguration and tuning functions reference available here.

hey,
I'm new to this serial port programming thing and I don't understand how i should use these functions in my c program.
can u two give me a simple example c program using these functions 4 me to figure out how to use these functions???

It is no trivial thing to do. Read the link I posted because it contains a few examples.
1) call CreateFile() to open the port
2) Set the port configuration (data bits, stop, bits, parity)
3) Check if anything is at the port, it there is then call ReadFile() to read it. If you use overlapped mode MS-Windows will call your function when data is available at the port.

That is all explained in the link I posted above. Study it carefully.

as an aside, check out TeraTerm. its probably the best Serial/FTP/SSH terminal interface available. if you're going to do any amount of serial work, you really need to get away from HyperTerm.

http://www.ayera.com/teraterm/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.