[Gambas-user] using events of serial ports for reading how_?

PICCORO McKAY Lenz mckaygerhard at gmail.com
Mon Aug 6 18:05:51 CEST 2018


OK hans, and tobias, yes the code in my first mail last week was bad,
now i understant some problems when i read agains the printert
but i need and i want a manual read funtion "also": so i have now:

the read event for the port, as documents suggest "is triggered"
when data "can be read" so if there's some data to read or available
the event will be executed by itselft, but i want also a manual "rp" method
that read also the port manually, at this point i dont know
if will be sync or async, i have a "sale" class that will be polled into a
form,
but as Tobias said i used the Scom_Read
but still need a manual read funtion due the inherits so i have :

1) the read event:

' this event will be triggered in read operations by the stream when data
its available
Public Sub SComm_Read()
   dim buffers as string = ''
  Read #SComm, buffers, Lof(SComm)
   dataread &= buffers
End

2) here, how can i code a read manual operation do not conflict if there's
already an operation triggered by teh read event?

i used some code proposed by Tobias but:

'' generic read port buffer data
Public Sub rp()
   dim  start as date = Now
   dim buffers as string = ''
  Do
    Wait 0.1
    Read #SComm, buffers, Lof(SComm)
    dataread &= buffers
  Loop Until DateDiff(start, Now, gb.Millisecond) > 500
End

now i have the problem of locking, as Tobias said I not even sure how Read
behaves when Lof is zero or if the read are just triggered at same time the
rp was invoqued!
so then reading would block.

i dont know how to use the SComm.Blocking = False to make manual polling,


Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com


El lun., 6 de ago. de 2018 a la(s) 09:59, PICCORO McKAY Lenz (
mckaygerhard at gmail.com) escribió:

> El lun., 6 de ago. de 2018 a la(s) 09:52, Hans Lehmann (
> hans at gambas-buch.de) escribió:
>
>> have a look at the chapters and the projects... under
>> https://www.gambas-buch.de/doku.php?id=k24:k24.1:k24.1.5:start!
>>
> THANKS HANS! now reading...
>  isend this mail to the list.. maybe you send too quickly and forgett to
> do!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180806/28cfe88a/attachment-0001.html>


More information about the User mailing list