Serial port programming

This is a discussion on Serial port programming within the C Programming forums, part of the General Programming Boards category; I want to learn how to send and receive data using the serial (com) port on my computer, but i ...

Serial port programming

I want to learn how to send and receive data using the serial (com) port on my computer, but i don't know of any tutorials or anything, so if any of you know where to find tutorials or anything about that, can you please tell me?

Below is a list of the most commonly used functions in doing COM programming (AFAIK), which you can look up on MSDN and/or Google:

HANDLE
CreateFile(...)
WriteFile(...)
ReadFile(...)

Now, to actually do the programming is up to you, and it also depends on if you want to do multithreading in it, or not. Read up on those, and you should be set (HANDLE is a variable type (like int, char, float, etc...), but it's still on MSDN).

I want to learn how to send and receive data using the serial (com) port on my computer, but i don't know of any tutorials or anything, so if any of you know where to find tutorials or anything about that, can you please tell me?

Mark Nelson (a Cisco programmer) came out with a really great book on serial communications (with a focus on the Window environment). Lots of great code examples and plenty of solid theory, too. Highly recommended.

In windows, there are two ways of doing so.
1. use bioscom built-in function in <bios.h> provided by all standard compilers
2. there are 10 registers available for the purpose. u will have to control them. that is u will have to understand how the data transfer takes place and accordingly u will have to set/reset appropriate bits (DTR,DSR,etc) in those registers. theres a book "IBM PC CLONES" available in market, it can help u out.

I had handled project on PC-PC communication earlier using second method. I can provide u with code in case u need it.

Mark Nelson (a Cisco programmer) came out with a really great book on serial communications (with a focus on the Window environment). Lots of great code examples and plenty of solid theory, too. Highly recommended.

Originally Posted by Devil Panther

I were unable to find this book on amazon. Tell me, does it also explains about usb ports programming?