modemd: the thox modem network daemon

The network on thox is managed by modemd.

Todo

Interfaces, etc.

Todo

What I expect from this program:

  • Interfaces, usually linked to a physical device, with a predictable address such as ccsl (for ComputerCraft modem on left side) or ccslw2 (for ComputerCraft modem on second port of left side wired bus).

    With support for:

    • ComputerCraft modems (cc).

    • OpenComputers modems (oc).

    • Skynet modems (sn).

    • Rednoot modems (rn).

  • Opening and closing ports.

  • Sending and receiving messages on said ports.

  • Message monitoring (independent from the subsystems).

  • Subsystems which catch received messages and prevent sending messages on higher-level subsytems.

    For a good exercise of the daemon’s design, try implementing the following subsystems:

    • Rednet.

    • OneOS protocols.

    • OPUS OS protocols.

    • LyqydNET.

    • Other port protocols.

modemd RPC bindings

os.rpc.modem.list()

List detected modems on all buses.

Returns

A list of strings representing the modems.

Return type

sequence

os.rpc.modem.open_(modem_name)

Open a context to the given modem.

Parameters

modem_name (string) – The name of the modem to open.

Returns

A context to the modem.

Return type

context

os.rpc.modem.modem.get_port_(port)

Get a port.

Todo

The interest of having a context by port is to emit messages on every ports, so that programs interested in messages for a specific port only get events considering that specific port.

Parameters

port (any) – The port identifier, as a string or number depending on the modem type.

os.rpc.modem.modem.list_open_ports()

List opened ports.

Returns

The list of opened ports.

Return type

sequence

os.rpc.modem.modem_port.get_status()

Get the status of the current port.

Returns

true if the port is opened, false otherwise.

Return type

bool

os.rpc.modem.modem_port.set_status(is_open)

Set the status of the current port.

Parameters

is_open (bool) – Should the port be opened?

os.rpc.modem.modem_port.emit(payload, src_port)

Emit a non-adressed message to the given port.

Parameters
  • payload (any) – The payload.

  • src_port (any) – The source port to display.

os.rpc.modem.modem_port.send(address, payload, src_port)

Emit an adressed message to the given port. Note that all modem types do not support this method.

Parameters
  • address (any) – Address of the host to which the message should be adressed.

  • payload (any) – The payload.

  • src_port (any) – The source port to display.

Todo

Develop and explain the modemd API.