This document specifies the communication between the host and a controller with the AYAB firmware.
\n\r (10 13)
Each message ends with a Line Ending.
The host waits for a indState(true) message before requesting to start the knitting. On startup, the Arduino continuously checks for the initialization of the machine (carriage passed left hall sensor). When this happens, it sends an indState(true) to tell the host that the machine is ready to knit. After receiving this message, the host sends a reqStart message, which is immediately confirmed with a cnfStart message. When reqStart was successful, the Arduino begins to poll the host for line data with reqLine, the host answers with cnfLine. This reqLine/cnfLine happens each time the carriage moves passed the borders given by the Start/StopNeedle parameters in reqStart. When the host does not have any more lines to send, it marks the last line with the lastLine flag in its last cnfLine message.
To see an example implementation, see the
states of the communication
Message Identifier Format¶
Messages start with a byte that identifies their type. This byte is called “id” or “message id” in the following document. This table lists all the bits of this byte and assigns their purpose:
|Bit||Value||Name||Description and Values|
|5||32||reserved||must be zero|
These are the values that identify the message.
Message definitions (API v4)¶
The length is the total length with id
and parameters. Note that the two characters
\r\n following the message are
not included in the length.
|hardware||0x23||var||A debug string. The id is the character
|host||0x04||1||put the controller into test mode|
The host starts the knitting process.
The controller indicates the success of The reqStart Message.
The controller requests a new line from the host.
More than 256 lines are supported. There are three possibilities for the next line based on the last line:
- the new line is greater than the last line
- the new line is lower than the last line
- the new line is the last line
We choose the line closest to the last line. This is trivial for (3). In case two lines are equally distant from the last line, we choose the smaller line.
This is computed by the function
is tested and can be seen as a reference implementation for other languages.
The host answers The reqLine Message with a line configuration.
This table shows the message content without the first byte that identifies the message:
|0||line number||These are the lowest 8 bit of the line. They must match the line number in The reqLine Message.|
Each bit of the bytes represents a needle position.
For the exact mapping of bits to needles see the table below.
|27||crc8 checksum||This checksum is computed from bytes 0 to 26, including byte 26. The controller may use this checksum to check the result and if the checksum does not match, it can send The reqLine Message anew.|
In the following table, you can see the mapping of bytes to needles.
The host initializes the handshake.
The controller answers The reqInfo Message with the API version.
This is sent when the controller indicates its state.
ready it is
This message ends with a
\r\n like evey message.
It contains debug information from the controller.
This message puts the controller in a test mode instead of a knitting mode.
This messsage confirms whether the controller is in the test mode. If success is indicated, the controller sends The indState Message messages periodically, containing the sensor and position values.