Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial communication with HEX

Status
Not open for further replies.

willstuck

Programmer
Aug 6, 2002
2
GB
Hello,

I am having major problems communicating with a device I have connected to my computers com port. I wish to send a HEX value to the serial port. I am using Visual C++ 6 and don't have any idea how to even open the port. Please, any advice would be appreciated. Will.
 
You need the API's to do this:
- CreateFile to open the port, like CreateFile ( "COM1:", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, NULL ); The OPEN_EXISTING is important, other options for a comm-port will cause CreateFile to fail.
- ReadFile to receive data
- WriteFile to send data
- CloseHandle to close the port
- Some functions for confguration and error handling, like SetCommState, ClearCommError and others. They are all in the Platform SDK documentation. Marcel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top