B4J Question how to wating util receive data and system message will processing continue

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

i have a sub named write2plc will send data(count) to PLC and waiting respone. the inside loop will waiting util timeout up if plc don't respone.

B4X:
sub write2plc(data() as byte,count as int,timeout as int) as int
    ;
end sub

I don't know how to implement sleep() let system message processing continue when i am waiting plc's respone ?
 

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi

I have use AsyncStreams.
 
Upvote 0

KitCarlson

Active Member
Licensed User
Longtime User
The NewData is used to bring in data and put together in buffer. When data is complete, then call is made to process, and clear processed data from buffer. Data does not always arrive at once, so assemble in static buffer, is important step. There are many ways for protocol to help handle data, that frame, count, checksum... and correct or reset in the event of errors.

Erel has written Text class for AsyncStreams with tutorial. It shows how to receive text string with an end terminator.
 
Upvote 0
Top