help with serial communication

Started by
1 comment, last by Homesick Alien 22 years, 6 months ago
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
Homesick Alien alias Thomas Flanitzer_____________________________If you have stopped getting better, you have stopped being good
Advertisement
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
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
thanks for your reply magmai!

I do pay attention to all the return values. Everything seems to be ok. The only problem is that the WaitForMultipleObjects() function won''t ever return.

Is it possible that the flow control xonxoff is mixed with dtrdsr or rtscts?

Thomas
Homesick Alien alias Thomas Flanitzer_____________________________If you have stopped getting better, you have stopped being good

This topic is closed to new replies.

Advertisement