SerialPortFR.readContinues

Read data while available by parts, sleep between checks.

Sleep time calculates from baud rate and count of bits in one byte.

------|--------|-----|------------|-----|------------> t
    call       |     |            |     |
readContinues  |     |            |     |
      |        |     |            |     |
      |        |<---------data receive---------->|
      |        |=== =====   ======|     |   |== =| data stream
      |        |     |  |   |     |     |
      |<--timeout--->|  |   |     |     |
      |        |<-1->|  |<2>|     |<-3->|
      |        |                  |     |
      |        |<---readedData--->|     |
      |                               return
      |<-------readAll work time------->|

(1) if readedData.length > 0 then continue reading
    else if expectAnything throw TimeoutException
    else return readedData (empty)
(2) silent time, if silent < frameGap then continue reading
(3) else if silent > frameGap then stop reading
    and return readedData

Params: buf = buffer for reading startTimeout = timeout for first byte recive frameGap = detect new data frame by silence period expectAnything = function throw exception if no data before startTimeout

Returns: slice of buf with readed data

Throws: PortClosedException ReadException TimeoutException

See_Also: SerialPort.read

class SerialPortFR
void[]
readContinues
(
void[] buf
,
Duration startTimeout = 1.seconds
,
Duration frameGap = 50.msecs
,
bool expectAnything = true
)

Meta