package mindstorm

  1. Overview
  2. Docs

Module Mindstorm_connectSource

Connection to bluetooth and USB devices.

Sourcetype usb
Sourcetype bluetooth
Sourcetype 'a t

Mutable bidirectional connection handle.

Sourceval connect_bluetooth : check_status:bool -> check_status_fn:(Bytes.t -> unit) -> string -> bluetooth t
Sourcemodule USB : sig ... end

Connection to USB devices. See Mindstorm.NXT.USB and Mindstorm.NXT.USB_lwt for more information.

Sourceval send : 'a t -> Bytes.t -> unit

send conn s send "package" s on the connection c. s is supposed to come prefixed with 2 bytes indicating its length (since this is necessary for bluetooth) — they will be stripped for USB.

Sourceval recv : 'a t -> int -> Bytes.t

recv conn n reads a "package" of length n and return it. For bluetooth, the prefix of 2 bytes indicating the length are also read but not returned (and not counted in n). recv checks the status byte using check_status_fn and possibly raise an exception (it is the task of check_status_fn to do that), regardless of the value of check_status (this is to allow to override check_status locally).

Sourceval really_input : 'a t -> Bytes.t -> int -> int -> unit

really_input conn buf ofs len reads len characters from conn and puts them in buf starting at position ofs. It does NOT read the bluetooth prefix bytes, so should not be used for packages but only for additional data.

Sourceval close : 'a t -> unit

Close the connection.

Sourceval want_check_status_by_default : 'a t -> bool

Says whether ~check_status:true was passed to the connection function.

OCaml

Innovation. Community. Security.