Asynchronous Serial Communications 
Author Message
 Asynchronous Serial Communications

I'm using RB 2.0.1 to communicate with a scientific device via its
RS-232 serial port. I can send commands and receive data alright. But my
problem is trying to interpret the returned data. Since everything is
asynchronous, I'm having trouble matching the output with my input
because everything gets handled in the DataAvailable method.

So, for example, I have a button that connects to the device and asks
for the software version of the device and then asks for the device
status. I want to put the 2 results into 2 variables. So in my button's
Activate method, I send the first command and do a "serial1.XmitWait".
Then I send the second command. But the output gets picked up by the
DataAvailable method of the serial control. How does it know what to do
with the data? I put it all into a large text field like the Dev. Guide
suggests. But how do I "parse" it into separate variables?

Thanks in advance for tips,
Frank

--
-Frank Schima

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Fri, 23 Nov 2001 03:00:00 GMT  
 Asynchronous Serial Communications
(Asynchronious) data handling wihtout any protocol is by no means easy.
I understand your problem is, that you want to "chain" request without being
willing to wait all the time for the answers.

Try: In your activate botton collect all your request (in an global array e.g.)
and send the first request only. When DataAvailable receives data it knows that
they belong to the first request in that array and can process them accordingly.
After that DataAvailable will send the next request from that array und return.

That goes on until all requsts from that array are handled.

Mike
----------------


Quote:
> I'm using RB 2.0.1 to communicate with a scientific device via its
> RS-232 serial port. I can send commands and receive data alright. But my
> problem is trying to interpret the returned data. Since everything is
> asynchronous, I'm having trouble matching the output with my input
> because everything gets handled in the DataAvailable method.

> So, for example, I have a button that connects to the device and asks
> for the software version of the device and then asks for the device
> status. I want to put the 2 results into 2 variables. So in my button's
> Activate method, I send the first command and do a "serial1.XmitWait".
> Then I send the second command. But the output gets picked up by the
> DataAvailable method of the serial control. How does it know what to do
> with the data? I put it all into a large text field like the Dev. Guide
> suggests. But how do I "parse" it into separate variables?

> Thanks in advance for tips,
> Frank

> --
> -Frank Schima

> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.



Fri, 23 Nov 2001 03:00:00 GMT  
 Asynchronous Serial Communications

Quote:

> (Asynchronious) data handling wihtout any protocol is by no means easy.
> I understand your problem is, that you want to "chain" request without being
> willing to wait all the time for the answers.

> Try: In your activate botton collect all your request (in an global
array e.g.)
> and send the first request only. When DataAvailable receives data it
knows that
> they belong to the first request in that array and can process them
accordingly.
> After that DataAvailable will send the next request from that array und
return.

> That goes on until all requsts from that array are handled.

I got it working! Thanks Mike. The only quirk (??) seems to be that
RealBasic does not process events until I've left the method from an
earlier event. So what happens is that both results come back at the same
time. Not a big deal, I just put a while loop in the DataAvailable method.

However, is there a way to have RB process events while inside a method -
like, I think, "DoEvents" in Visual Basic?

Regards,
Frank



Fri, 23 Nov 2001 03:00:00 GMT  
 Asynchronous Serial Communications

Frank,
I think RB processes method by method in an orderly fashion and makes no
exception for real asynchronious events like Mouse Clicks or Serial Data.

To give priority to DataAvailable for the next process step, you e.g. cann call
"SerialControl.Poll". But I am not sure whether this call will immediately
link to the DataAvailable Event Routine (of course only If data are available!).

If it doesnt you can use THREAD. This is easyer than you might expect and
there is no reason to shy away from that high end feature. However you
should experiment with it some time apart from data transfer. It worked
fine with my first try,  drawing moving pictures in one window and
working other things in another. I think THREAD is sufficiently explained
in the manual..

Mike

Quote:

> I got it working! Thanks Mike. The only quirk (??) seems to be that
> RealBasic does not process events until I've left the method from an
> earlier event. So what happens is that both results come back at the same
> time. Not a big deal, I just put a while loop in the DataAvailable method.

> However, is there a way to have RB process events while inside a method -
> like, I think, "DoEvents" in Visual Basic?

> Regards,
> Frank



Sat, 24 Nov 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. trouble with serial communication (serial port init.vi)

2. Asynchronous Communication Events

3. Asynchronous communication

4. Asynchronous communication between protected types

5. Asynchronous Communications (RS232) under Unix

6. Asynchronous device communications

7. Asynchronous Inter Process Communication in a Prolog debugger

8. ILPS 91 Post Conference Workshop on Semantics of Asynchronous Communication

9. Corrections, Semantics of Asynchronous Communication, ILPS 91

10. Workshop on Semantics of Asynchronous Communication

11. multiple, parallel, asynchronous, continuous Serial VISA reads

12. Reading asynchronous data from a serial device

 

 
Powered by phpBB® Forum Software