Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
SerialSourceCreate a module using Connection.t
let module DaytimeSerial = (val Serial.make connection)Create a connection. Returns a connection Lwt_result.t.
Serial.connect ~port ~baud_rate >>= function
| Ok connection ->
Lwt_io.printl "Awaiting input. Enter 'quit' when done..." >>= fun () ->
Serial.io_loop connection (Some "quit")
| Error _ -> Lwt.return () (* TODO: handle exception *)Create a connection. May raise an exception (e.g. port not found).
Serial.connect_exn ~port ~baud_rate >>= fun connection ->
Lwt_io.printl "Awaiting input. Enter 'quit' when done..." >>= fun () ->
Serial.io_loop connection (Some "quit")Enters a loop reading from serial -> stdout, stdin -> serial. Optionally exit loop when $TERMINATOR is entered.
io_loop connection (Some "done!")Unlike write_line, write does not terminate the string with a newline
val wait_for_line :
Serial__.Connection.t ->
string ->
timeout_s:float option ->
Serial__.Wait_for.t Lwt.tWaits for a keyword with optional timeout.
wait_for_line connection "wait for me!" ~timeout_s:(Some 8.)
wait_for_line connection "wait for me!" ~timeout_s:NoneReturns either Received or TimedOut.
wait_for_line connection "ok" ~timeout_s:(Some 5.) >>= function
| Received -> Lwt_io.printlf "ok received for %S" c
| TimedOut -> Lwt_io.printlf "didn't hear back in time for %S" c