Comm32 Logo
Home Button   

Topic:   generate OnComm when a complete datapacket is received

By: DavePosted on: Jun 30 2011 at 05:32:19 PM
I deal mostly with receiving packets of data. A packet of data is defined as a starting sequence of characters, followed by the data and then followed by an ending sequence of characters. Ideally I would like to only generate the oncomm event when the entire data packet is received. Right now, using mscomm, I capture each character as it comes in, save it to a buffer string variable and set flags when the start character is received and when the end character is received ... then I process the data in the buffer string. Is that the way your control works or can I fire the oncomm when an entire packet of data is received?

By: SupportPosted on: Jun 30 2011 at 08:22:43 PM
You'll see our ocx has a property called .evtChar and another called .evtCharEnable

Set .evtChar to the character ASCII numeric value you're waiting for and you'll get an oncomm evtChar event when that character is detected by the hardware.

Set rThreshold to 0 so that you don't get any evReceive events at all. You'll get the evtChar event as soon as the evtChar is detected in the data.

By: DavePosted on: Oct 15 2014 at 01:48:25 PM
Do you have an example of this anywhere? Doing what you suggest wouldn't it be possible to get a "packet" of data that looks like this: garbagedata startcharacter gooddata endcharacter

By: GuestPosted on: Oct 15 2014 at 08:28:38 PM
You could set evtChar to the ascii byte value of your end character and set evcharenable to true. Dont read any data out of the receive buffer until you get an evtChar oncomm event.

When you get the event The receive buffer could contain:-

GarbageData+StartChar+GoodData+EndChar+GarbageDate so its up to you to index into the string to extract the data between your start and end characters.

Go to the website www.comm32.com and theres a page that deacribes the event and shows an example of its use.