Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 2 made on Monday February 8, 2010 at 17:40
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,996
There is no way other than doing a receive() or match() polling operation. Also note that if you transmit data to the serial port using send() or match(), that the existing buffer is cleared.

This behavior makes it more difficult (read as not 100% reliable) to do full-duplex communication as prior to a send, you must always do receive() or match() prior to send() or match() and there is always a small window that can occur where you blow away data that is in the buffer.

Assuming you are using async model for serial port, you can do:

s.receive(1024,125); // initial read to drain the buffer waiting only 125ms.
// data will be delivered asynchronously either in onData() or onTimeout()
// callback - onTimeout will be called if less than 1024 bytes of data.
s.match(toSend,"\r",1000);

Yes, to me, this is very quirky. Almost makes for easier programming to do the serial operation synchronously. In fact, that is exactly what I do with my X10 module. :-)
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse