Drive Lego Mindstorms bricks from OCaml (LWT version)
type mailbox = [
| `B0
| `B1
| `B2
| `B3
| `B4
| `B5
| `B6
| `B7
| `B8
| `B9

The 10 available mailboxes on the NXT brick.

type remote = [
| `R0
| `R1
| `R2
| `R3
| `R4
| `R5
| `R6
| `R7
| `R8
| `R9

Due to the master-slave relationship, slave devices may not initiate communication with their master, so they store outgoing messages in these mailboxes.

val write : ?check_status:bool -> 'a conn -> mailbox -> string -> unit Lwt.t

write conn box msg writes the message msg to the inbox box on the NXT. This is used to send messages to a currently running program.

  • parameter check_status

    whether to request a status code from the brick. If true (the default for this fonction), the NXT only send a reply when it is able to queue the message without overflowing the queue (this prevent message loss). If false, the message may delete the oldest message in the NXT queue if it is full (the NXT queues are 5 messages long).

val read : 'a conn -> ?remove:bool -> [ mailbox | remote ] -> string Lwt.t

read conn box returns the message from the inbox box on the NXT.

  • parameter remove

    if true, clears the message from the remote inbox. Default: false.