help with serial communication
Hi guys!
I'm about to develop a windows program that will by used in combination with telephone systems. It's job is to receive data by the telephone system over the serial port, find the right country in a database, calculate the price and so on. Now everything works well so far except that I am unable to receive any data from the serial port.
First I wanted to use some code from an older project of mine where the serial input worked without any problems. But since it didn't work the first few test runs I recoded it almost completely. I used some code I found on the web to compare it with mine to see whether i was missing something. But as you would guess: same result! It didn't even receive a single byte.
I found out that when use hyperterminal with the same port properties (4800, 8, n, 1, xonxoff) as in my program the data comes in perfectly. So there must be something wrong with my code. But the strange thing is that when I plug an old mouse into my serial port and switch to rtscts flow control it does receive data.
I really have no idea why it doesn't work. It would be great if someone could give me some tips or even take a look at the source(link below). Thanks a lot in advance!
Thomas
source files (zipped)
Edited by - Homesick Alien on October 6, 2001 7:08:17 AM
You need to pay attention to the return value of WaitCommEvent, it tells you what you need to do next. You need to check every return value from all those functions, and handle every case, otherwise it won''t ever work correctly.
Be certain not to mix syncronous and asyncronous methods either. If you want a decent asyncronous CComPort object, it needs to handle overlapped read and overlapped write operations simutaneously. You should issue another overlapped comevent operation after each read completion (be sure to continue reading the port until there''s no more data available, it''s a common mistake to do only one read per event signal).
Magmai Kai Holmlor
- Not For Rent
Be certain not to mix syncronous and asyncronous methods either. If you want a decent asyncronous CComPort object, it needs to handle overlapped read and overlapped write operations simutaneously. You should issue another overlapped comevent operation after each read completion (be sure to continue reading the port until there''s no more data available, it''s a common mistake to do only one read per event signal).
Magmai Kai Holmlor
- Not For Rent
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement