B4J Question Serial port question - Events

rspitzer

Active Member
Currently I am reading and writing data to the serial port using the async streams, no problems, everything is great. The issue I wanted to explore is currently I am reading the serial port via a Timer (polling every 300 ms.) I used to code in the .Net Compact Framework from Microsoft. The serial port method in the framework had a received byte threshold coupled with an addevent function. What this did was when I set the threshold to a certain number of bytes in the receive buffer, it would trigger an interrupt for a lack of better words, that then would automatically take the program to my receive function for processing, no timer or polling needed, this way the program could do other things without polling the receive buffer at a certain interval. Is there a way to implement this type of function in B4J, if not no big deal, it was a nice feature of the .Net Compact Framework.
 

rspitzer

Active Member
Good question for me, as I mentioned I am using the async streams to read the serial port and getting the data, not a problem. I thought to read the stream, I would use a timer to interrupt the program to take a look at the serial port and see if there where bytes available to be read. Are you saying that once the async stream is implemented, the stream itself interrupts the program for the read and transfer of bytes (written in the async call) for the program to process and if so, in my case the program should be being interrupted continually since the serial port I am reading provides a constant flow of data with absolutely no interruptions. ? I think then I have a fundamental miss understanding of using the stream then, can you elaborate?
 
Upvote 0

rspitzer

Active Member
Thank you, I will take a look at it, I remember viewing the tutorial before, but I think a second look will be helpful. I will get back to you if I have anymore questions.
 
Upvote 0

rspitzer

Active Member
Actually I am using the async stream properly, re-looked at the sample code and the video, I of course was not putting 2 and 2 together, I have coded it as an event, just was not thinking about it.
 
Upvote 0
Top