|
-
Mar 14th, 2000, 01:30 AM
#1
Thread Starter
Lively Member
I already wite code for reading and writing on comm. I have another problem. Wher I send some data to Comm my electronic ciruct returns other data (some kind of response to given command). I comunicate with 4800 bps.
Problem is this: I need to pause program while i get data from comm.
I don't know how much data will I receive (it is less than 256 bytes) and how long program must be paused.
At the moment I solved this problem with timer which trrigers every 700ms (enough time to send and recieve all data).
In my super-fast computer works fine (more or less), but when I installed program on super-slow machine (486/50) Timer execute his code every 5 seconds.
What should I do!
Ermin
-
Mar 14th, 2000, 06:45 AM
#2
New Member
Hi Ermin!
You could try to use MSComm control. It can be used as polling or as event-driven manner. If you used it as event-driven, you'd know, for example, when output buffer is empty or when you have received data.
-
Mar 14th, 2000, 01:24 PM
#3
Thread Starter
Lively Member
I already use MSComm.
I yust wanna write code that will tell me that there is no "trafic" on Comm port anymore.
Because I don't know how to do that I put in timer with time set to a little more than all 256 bytes of data needs to be read from Comm (256 * 10 /4800 = 580 ms) and then I do all the stuff again (send command and read data).
Thnx!
Ermin
-
Mar 14th, 2000, 05:35 PM
#4
New Member
I have done a couple of apps which use com port for input and output. I had similar problem: I needed to know if a whole message was received. Its length was altering, so i couldnt just check how many bytes i had received, and then determine weather the whole message was received. I solved the problem by reading all incoming data at the time it was received, and storing it into FILO(first-in-last-out) queue. After this i checked the queue for new WHOLE message(s). Checking the messages is ofcourse dependant of the protocol you use to format them.
I hope this was what you were looking for!(?)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|