package mindstorm

  1. Overview
  2. Docs

Read and write messages from the 10 message queues. This can be thought as advanced direct commands.

Interesting information concerning this can be found in Sivan Toledo's paper: Analysis of the NXT Bluetooth-Communication Protocol.

type mailbox = [
  1. | `B0
  2. | `B1
  3. | `B2
  4. | `B3
  5. | `B4
  6. | `B5
  7. | `B6
  8. | `B7
  9. | `B8
  10. | `B9
]

The 10 available mailboxes on the NXT brick.

type remote = [
  1. | `R0
  2. | `R1
  3. | `R2
  4. | `R3
  5. | `R4
  6. | `R5
  7. | `R6
  8. | `R7
  9. | `R8
  10. | `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

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

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.

OCaml

Innovation. Community. Security.