RS232 class not triggering events

intx13

Member
Joined
Jun 21, 2006
Messages
7
Programming Experience
5-10
I'm using Microsoft's RS232 class to access serial ports via VB.net (.net 2.0).

It seems to work alright... Monitoring the raw serial data on anotehr computer (using a crossover cable) shows the right stuff coming through. But the three events that the RS232 class seem to trigger never actually happen. Or at least my handlers don't pick them up.

In the class I declare my serial port as follows
VB.NET:
Private WithEvents CommPort As New Rs232()

Later on I have these handlers:
VB.NET:
Private Sub DataReceived(ByVal CommPort As Rs232, ByVal databuffer As Byte()) Handles CommPort.DataReceived
        MsgBox("Got data!")
End Sub

Private Sub TxCompleted(ByVal CommPort As Rs232) Handles CommPort.TxCompleted
        MsgBox("Transfer completed!")
End Sub

Private Sub CommEventHandler(ByVal source As Rs232, ByVal Mask As Rs232.EventMasks) Handles CommPort.CommEvent
        MsgBox("Comm event!")
End Sub

None of these handlers ever show a message box, even while I monitoring that the information is succesfully being sent across the link.

Any help is appreciated!
 
intx13 said:
I'm using Microsoft's RS232 class to access serial ports via VB.net (.net 2.0).
Where is this class?
 
CommEvent is not used in that class. TxCompleted event is raised with AsyncWrite and DataReady event is raised with AsyncRead when methods completes successfully, because they work asynchronous on separate threads. If you use the Read/Write methods you will know when they complete by when they return from calls.
 
Ah... that makes sense. I was under the impression that those events were triggered via Read() and Write() as well, and that CommEvent would be triggered all the time. Thanks a lot for the help!

I actually found a revamped version of the code which supports CommEvent, and fits a little better with what I wanted to do (though I'm about to go post another question about it in the more general board about why its trying to access my main frame after I quit).

Thanks again!
 
Back
Top