|
-
January 6th, 2009, 09:03 AM
#20
Re: while loop w/ sleep(1) doesnt work
>> Polling every 1 second will require at least 1000 seconds to complete
Yes - if you only try to read something once a second. But if you use canReadWait() with a timeout, then the function will return as soon as there is data available or if a timeout occurs.
Typically, when dealing with a message-response type protocol, there is a "time window" in which a response is expected. If a response isn't received within that window, then you assume "communications error". You will have to decide at what point does a lack of a response indicate an error.
How long does it typically take to receive a response?
At what point does a lack of response indicate "communication error"?
>> it's single thread.
If you're not familiar with it, making it multi-threaded may add more complications than you care to deal with right now. But without it, you'll need to find a way to keep the UI responsive while handling CAN communications.
The single threaded approach wouldn't be too hard if, for example, you had a modal dialog with a cancel button and some sort of progress indicator. You would then use a special message loop just for this modal dialog. This special message loop would periodically pump messages while handling CAN message/response pairs.
gg
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
|