Comm32 Logo
Home Button   

Topic:   SComm32 - OnComm triggered

By: OddbjørnPosted on: Mar 11 2015 at 07:21:24 PM
I use the SComm32 with Excel 2010 VBA. I send a signal no.1 and OnComm is triggered as it is supposed to be. If I send a signal no.2 shortly after, while the transmit buffer (SComm1.Read) still has a value (value from signal no.1), OnComm is not triggered and the signal no.2 seems not even to be queued for later handling when the handling of signal no.1 is done. From the homesite of SComm32.com I can read: "When you are handling an SComm32 OnComm event no further events will be triggered - any further events are queued so that you get them one after the other... ". How can I get the signals to queu up and than be handled (trigger the event SComm1_OnComm()) one after the other.

I had no problems with MSComm32.

Here is the start of my code:

Private Sub SComm1_OnComm()
If SComm1.CommEvent = 2 Then
Sleep (400)
Dim buffer As String
Do While SComm1.InBufferCount > 0
buffer = buffer & SComm1.Read
Loop
receive = StrConv(buffer, vbLowerCase)
execution_mode = Mid(receive, 3, 1)


Here is some of the properties of the SComm32:
Name: SComm1
CommPort: 1
DTREnable: True
EOFChar: 26
EOFEnable: False
EvtChar: 0
EvtCharEnable: False
Handshaking: 0
InBufferSize: 2048
InputLen: 0
InputMode: 0
NullDiscard: False
OutBufferSize: 1024
ParityReplace: ?
RThreshold: 1
RTSEnable: True
Settings: 9600,e,7,2
SThreshold: 1
Tag:
Version: 8.1.8


By: GuestPosted on: Mar 11 2015 at 09:18:25 PM
If the OnComm event that responds to your signal #1 is active when signal #2 arrives then is it possible that the first oncomm event is emptying the receive buffer of both signals so that no more data exists in the rx buffer so no further oncomm event is necessary?

By: Guest3Posted on: Mar 11 2015 at 10:46:04 PM
Looking at your OnComm event It looks as though your signal 2 arrives while the first oncomm event iis still looping so the first oncomm event simply keeps looping and reads signal 2 as well.

Your string buffer contains both signals/messages.

When the first oncomm event is finished there is no more data in the receive buffer so the rthreshold condition is not met so no further oncomm event is triggered.



both signal 1 and signal 2 are being read from the receive buffer by the first oncomm event.

By: Guest4Posted on: May 2 2015 at 01:38:37 PM
"When you are handling an SComm32 OnComm event no further events will be triggered - any further events are queued so that you get them one after the other... ". According to this the second event should not be received while the first is still being processed; therefore the data associated with the second event should not be in the buffer until after the first event is completed. Sounds like SComm32 is not queuing the second event as it should. I'm still debating purchasing SComm32 because of a one-time bad experience with MSComm32, but it's beginning to look like I'd be trading one set of problems for another set of different problems.

By: Guest Posted on: May 3 2015 at 10:11:33 AM
I think you don't understand how serial port works.

The original description at the top of the page suggests there are separate packets of data. You therefore assume there should be separate events for each packet.

Unfortunately There's only one receive buffer so if the second packet of data arrives while some bytes from the first packet are still in the receive buffer then both packets are simply one continuous stream of data and the serial port driver not know where one packet ends and the next one starts.

As soon as the first character of the first packet arrives your application will be notified via the oncomm event. If your application then reads both packets out of the receive buffer then no further events will be raised.

If you are receiving separate packets of data then it is up to your application to separate them.