Page 1 of 2

Serial Port Events

PostPosted: Sat Nov 27, 2010 5:08 am
by tseyfarth
Hello,

I cannot find any docs either in Q7B or KB about the various events and programming syntax for Serial Port Events. Can anyone point me to the right location or provide more info?

TY
Tim

Re: Serial Port Events

PostPosted: Sat Nov 27, 2010 10:44 am
by Henning

Re: Serial Port Events

PostPosted: Sat Nov 27, 2010 4:57 pm
by tseyfarth
Hi Henning,
Thank you for your response. In Q7B, there is no object to drag to a form, so you cannot see the same items as you can in KB. Also, in the KB doc, there is only one line that discusses events, with none listed and no details at all. It is the last item in the Serial section. I had already reviewed that doc before posting.

In the Qext... doc, I have not found any events listed anywhere in that doc.

I am looking for the equivalent(s) of:

Case comEvCD ' Change in the CD line.
Case comEvCTS ' Change in the CTS line.
Case comEvDSR ' Change in the DSR line.
Case comEvRing ' Change in the Ring Indicator.
Case comEvReceive ' Received RThreshold # of
' chars.
Case comEvSend ' There are SThreshold number of
' characters in the transmit
' buffer.
Case comEvEof ' An EOF charater was found in
' the input stream

Tim

Re: Serial Port Events

PostPosted: Sat Nov 27, 2010 9:27 pm
by Henning
Untested aircode:
Code: Select all
Sub SerialPort_OnEvent()
  With SerialPort    ' not sure if With is implemented
  If .IsCTS() Then
    ....
  Else
    ....
  End If
  If .IsDSR() Then
    ....
  Else
    ...
  End If
  .......
  MyInt = .BytesAvailable()
  End With
End Sub


I agree that documentation is almost nada, but it is still only Alpha. If I get the time, I will try it out.

@Bernd
Shouldn't theese be declared as functions?
Declare Sub "Q7BSerialPort" bool IsCTS();
Declare Sub "Q7BSerialPort" bool IsDSR();
Declare Sub "Q7BSerialPort" bool IsDCD();
Declare Sub "Q7BSerialPort" bool IsRI();

/Henning

Re: Serial Port Events

PostPosted: Sun Nov 28, 2010 12:18 am
by tseyfarth
It is alpha, but it is also pretty cool and VERY hard what B is doing! Others will not appreciate how hard it is, but will certainly enjoy the fruits of B's labor!

The Qext docs are quite different too than what VB6 is. But so long as it works, that is all that counts. I read today that it may be better to poll the object for send/receipt of data rather than use the event technique. I'd like to look at both. The trouble I ran into was no docs on using a timer :(

Oh well, it'll come soon enough I am sure!

Thanks Henning!
Tim

Re: Serial Port Events

PostPosted: Mon Nov 29, 2010 1:10 pm
by berndnoetscher
@Bernd
Shouldn't theese be declared as functions?
Declare Sub "Q7BSerialPort" bool IsCTS();
Declare Sub "Q7BSerialPort" bool IsDSR();
Declare Sub "Q7BSerialPort" bool IsDCD();
Declare Sub "Q7BSerialPort" bool IsRI();




Thanks Henning! Corrected.
Code: Select all
Declare Function "Q7BSerialPort" bool IsCTS();
Declare Function "Q7BSerialPort" bool IsDSR();
Declare Function "Q7BSerialPort" bool IsDCD();
Declare Function "Q7BSerialPort" bool IsRI();

Re: Serial Port Events

PostPosted: Mon Dec 06, 2010 6:55 pm
by tseyfarth
What is the Event for when data has arrived at the serial port, and conversely bytes are being sent out of the port?

The equivalents of
Case comEvSend '1 There are fewer than SThreshold number of characters in the transmit buffer.

Case comEvReceive

And how do you tell the object that you want to use it in Event mode rather than polling mode?
This appears to be the declaration, but what are the vars that fill it?
Code: Select all
Declare Sub "Q7BSerialPort" void  SetQueryMode(const QString & s);



Thank you
Tim

Re: Serial Port Events

PostPosted: Mon Dec 06, 2010 7:23 pm
by Henning
AFAIK

Add this to the SerialPort example.
Sub sp_OnEvent()
Simulate()
End Sub

At least it compiles ok :)

/Henning

Re: Serial Port Events

PostPosted: Mon Dec 06, 2010 7:36 pm
by tseyfarth
It compiles with both

Code: Select all
Private Sub OnEvent()
  Dim e As Integer
 MsgBox("On Event")
' OnEvent
 MsgBox (e)
 End Sub



and also
Code: Select all
Private Sub sp_OnEvent()
  Dim e As Integer
 MsgBox("On Event")
' OnEvent
 MsgBox (e)
 End Sub


But the event never fires. So likely it is not set up TO fire, just one of the issues with working with there SP event. Am trying the timer method but was looking to cover the bases when the event would in fact work....

Thanks again Henning

Re: Serial Port Events

PostPosted: Mon Dec 06, 2010 7:41 pm
by Henning
Have you tried,

Private Sub Q7BSerialPort_OnEvent().

Are all parameters for the Com Port set correctly, I have nothing to test with right now.

/Henning