HA-I05.01
Part description
Current development revision.
This document describes the communication protocol between the USB/CAN converter HA-B02 and the control PC computer program ha_iod.
All numerical values are decimal unless explicitly stated otherwise.
Contents
Transport layer
- The messages between ha_iod and HA-B02 are exchanged over a USB-serial link, running at 19200 bps, 8 data bits, no parity, 1 stop bit ("8N1").
- No method for flow-control is used.
Data format
- Data is transmitted using ASCII characters ranging from 33-160.
- Control characters are to be interpreted as such, and are always the first character of a transmitted datagram.
Datagrams are terminated by the character sequence cursor-return, line-feed (\n).
Numerical data is transmitted as two byte characters. Their ASCII codes are calculated on encoding by adding the value of ! (33) to the upper and lower four bit of the byte to be transmitted. The first byte transmitted represents the upper four bit of the data byte, the second byte transmitted therefore represents the lower four bit of the data byte.
- The elements of one datagram, that is control character and each two-byte ASCII encoded character, are separated by space characters (ASCII value 32).
Datagrams
Data needs to be transmitted in different directions between different parts of the stack. In the following section, "CAN" means the CAN bus and its attached devices, so a message "to CAN" is a packet of data that needs to be sent out through the CAN bus. On the other hand, a message "to HA-B02" is a message that needs to be interpreted by the HA-B02 controller itself, and does not have to be forwarded to CAN (but may trigger other actions on the CAN bus).
In the following format specifications, capital letters are placeholders for data explained in the respective description, small letters are control characters and transmitted as-is. Numerical values given here are transmitted as their ASCII representation.
ha_iod to CAN
m |
HH |
LL |
NN |
DD |
DD |
DD |
DD |
DD |
DD |
DD |
DD |
r |
HH |
LL |
NN |
DD |
DD |
DD |
DD |
DD |
DD |
DD |
DD |
If m is used as control character, a standard CAN message is to be sent.
If r is used as control character, the remote transmit request (RTR) bit is to be set on the outgoing message.
- H Upper 8 bit of 16 bit CANID (including bus identifier)
- L Lower 8 bit of 16 bit CANID
- N Amount of data bytes to transmit (0..8)
D 8 bytes of data in two-digit representation. Unused bytes are padded with 0 characters.
CAN to ha_iod
n |
HH |
LL |
NN |
DD |
DD |
DD |
DD |
DD |
DD |
DD |
DD |
e |
HH |
LL |
NN |
DD |
DD |
DD |
DD |
DD |
DD |
DD |
DD |
If n is used as control character, a standard CAN message has been received.
If e is used as control character, the remote transmit request (RTR) bit was set on the incoming message.
- H Upper 8 bit of 16 bit CANID (including bus identifier)
- L Lower 8 bit of 16 bit CANID
- N Amount of data bytes to transmit (0..8)
D 8 bytes of data in two-digit representation. Unused bytes are padded with 0 characters.
Control messages
CAN controller reset
a |
b |
Reset and re-configure the CAN controller for either bus A or B.
CAN bus power switching
p |
BB |
PP |
- BB is the bus number, encoded as described in the general section
- PP is the power state to switch to, either 0 or 1, encoded as above
HA-B02 response codes:
p:OK:NN with NN being the number of milliseconds it took the relay to throw (tested value for freshly bought relays is 5-6 ms).
p:ERR:HW in case of relay timeout or other hardware errors.
p:ERR:INV in case of an invalid argument to this command
HA-B02 identification
i |
The control character i can be sent from ha_iod to HA-B02 to request hardware and firmware version information. The response string will be prefixed with the character i as well.
For reference, the current response to this command is the following:
inz@thiemo.net:HA-B02.01:HA-P04.01:dev
The response string is terminated with the two-character sequence cursor-return, line-feed.
Reserved
The following control characters are reserved for testing purposes and should not be used in regular operations:
t |
Sends a test CAN message in development build. Later to be used for entering a test mode. |
THIS DATA IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DATA, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
All product and brand names mentioned on there pages and in the source code are registered names and/or trademarks of the respective owner and are mentioned for identification purposes only.
For a full copyright notice, please see this link. For imprint and contact information, please see http://www.thiemo.net/.