Topic: MSComm vs SComm timing differences
|By: Guest||Posted on: Sep 21 2016 at 09:44:01 PM|
|I'm running a VB6 application using MSComm to receive a short serial string from a depth sensor. When I substitute SComm (trial) the time to complete the transaction goes very long (26ms vs. 235ms.) Can you confirm that SComm takes a longer time to complete a read transaction?|
|By: Support||Posted on: Sep 22 2016 at 08:06:37 AM|
|There will always be differences but i'm not sure why it should be that extreme.|
How are receiving? I mean does the windows application send a request to the remote device and get a response (and its that whole roundtrip that takes time)
Or does the windows program just sit listening? (Using the oncomm event?) In which case what event do you use to trigger the start of the time measurement?
No problem whichever way you do it. I'd like to set up a test here and would like to measure time that same way you do.
|By: Jay Scott||Posted on: Sep 22 2016 at 05:57:55 PM|
|I am working on this same issue with the previous requestor.|
We are using the purchased release (9.1). We are using the OnComm Event ("comReceive") to start or trigger the IO bit we are using to time this. We are receiving 1 character at a time. We send the timing IO bit HIGH when we receive the 1st character and send it low when we receive a "CR" or ASCII 10 from the device. There is generally 10 to 15 characters received from the outside device.
We are setup the same for both the MSCOMM and SCOMM (I simply did a Find/Replace of the MSCOMM to SCOMM so there is theoretically no difference, yet the SCOMM is taking much longer to finish (receive all characters) and this is messing up our timing
|By: Support ||Posted on: Sep 22 2016 at 08:05:34 PM|
I did two tests.
Test #1. The OnComm event will read one character and then, if more characters are available to be read it reads another - basically looping reading one char at a time until no more chars are available or until it hits CR.
Test #2. The OnComm event will read only ONE character and then exit the OnComm event. Another OnComm event occurs and the next character is read. etc etc until all characters are read.
I measure the length of time between reading the first character and reading CR. (In my test it's 15 bytes)
Test#1 = mostly 0ms although occasionally it showed 10 or 15ms
Test#2 = 250ms (pretty much what you said)
So. The only way I could make it take such a long time is my Test #2. Reading just one character for each occurrence of the OnComm event. Is that really what you're doing?
|By: Jay Scott||Posted on: Sep 23 2016 at 04:05:34 PM|
|Test#2 is what we are doing. In this test the MSComm ran in about 15mS while the SComm ran at about 250mS|
Any idea as to why?
|By: Support ||Posted on: Sep 23 2016 at 04:25:37 PM|
|I also tested with MSComm32 and got similar results to you. In your scenario MSComm32 is faster.|
It looks as though MScomm32 raises the OnComm event internally so the next event is ready to be triggered as soon as the current event exits.
SComm32 is not MSComm32. If it was identical then there'd be no point in using our component. It would be the same as MSComm32.
Under some circumstances the MSComm32 can actually trigger another OnComm event before the previous one has finished. That can cause a problem when the CommEvent property can be changed by that second, pending, event even though the first instance hasn't finished with it yet. It causes unexplained problems - one of the reason why some people switch to our OCX.
We've solved that problem by ensuring that the OCX can not even begin thinking about triggering another event until the previous event has completed.
This, unfortunately, creates a slight delay which would not normally be visible. But because you're reading just one character, even though more characters are available, means you're exaggerating that delay (ie multiplying it by the number of chars that you're reading)
I know you want to read one char at a time so that you can detect that CR but why can't you just loop in the oncomm event getting more chars if more chars are available?
Reply - add a comment to this topic.
You may enter letters, numbers and standard punctuation only. HTML and other scripts/tags will be rejected.