I/O

ioRegisterHandler View Source

Registers an I/O packet handler for a given machine ID.

Inputs

A

Machine ID

IX

Callback

B

Expected header length

Notes

The "expected header length" is the length of the packet header at the time you want your callback told about it. The maximum is 4.

Your callback will be called with HL set to the address of the packet header.

Your callback will be called during an interrupt, so make it short and sweet. If you return HL != 0 and BC != 0, we'll assume that HL is a pointer to a buffer to be filled with BC bytes from the rest of the packet. You may set IX to a callback to run when the full packet is read, or to 0 otherwise.

If a handler has already been reserved with this machine ID, it will take precedence.

Your header handler may be called multiple times before the final callback is invoked. This may occur if we have to retry the packet due to a corrupted header.

ioSendPacket View Source

Sends a DBus packet via the I/O port.

Inputs

IX

Callback (or zero)

E

Machine ID

D

Command ID

HL

Buffer (or zero)

BC

Buffer length (or zero)

Outputs

Z

Set if successful, reset if I/O is busy

Notes

This is an asyncronous operation. Your callback will be invoked (outside the context of your thread) when the send is complete. Please keep your callback short and sweet, as it will be called during an interrupt. You are advised to suspend your main thread or use condWait and have your callback resume/notify it.

Attempts to access the buffer memory before the callback is run will end in tears.