Classes | Defines | Typedefs | Functions
avr_controller.h File Reference
#include <netinet/in.h>
#include <inttypes.h>
#include "art_command_protocol.h"
Include dependency graph for avr_controller.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  avr_cmd

Defines

#define avr_offset(field)   ((size_t) (((char *)(&(((struct avr_cmd*)NULL)->field))) - ((char *)NULL)))
#define AVR_POS_ABSURD   7 /* absurdly small position value */

Typedefs

typedef int8_t s08
typedef int16_t s16
typedef uint8_t u08
typedef uint16_t u16
typedef uint32_t u32

Functions

static uint8_t avr_get_com (struct avr_cmd *cmd)
static uint8_t avr_get_diag (struct avr_cmd *status)
static uint8_t avr_get_direction (struct avr_cmd *status)
static int16_t avr_get_dstate (struct avr_cmd *status)
static bool avr_get_estop (struct avr_cmd *status)
static bool avr_get_gen (struct avr_cmd *status)
static int16_t avr_get_istate (struct avr_cmd *status)
static uint8_t avr_get_len (struct avr_cmd *cmd)
static uint8_t avr_get_pos (struct avr_cmd *status)
static bool avr_get_pvld (struct avr_cmd *status)
static int16_t avr_get_pwm (struct avr_cmd *status)
static uint16_t avr_get_rpms (struct avr_cmd *status)
static bool avr_get_rvld (struct avr_cmd *status)
static void avr_set_com_len (struct avr_cmd *cmd, int com, int len)

Define Documentation

#define avr_offset (   field)    ((size_t) (((char *)(&(((struct avr_cmd*)NULL)->field))) - ((char *)NULL)))

Definition at line 161 of file avr_controller.h.

#define AVR_POS_ABSURD   7 /* absurdly small position value */

Definition at line 132 of file avr_controller.h.


Typedef Documentation

typedef int8_t s08

AVR Throttle Controller Command/Protocol Design ===============================================

The Pilot as the master will send COMMAND packets to the slave throttle controller. The throttle controller will respond to each command packet with an ACK/NAK or STATUS (if requested) packet. All values are trasmitted as ASCII characters representing byte values in hexadecimal. Packets are terminated with a carriage return. The packet formats are as follows:

----------------------------------------------------------------------

COMMAND packet

----------------------------------------------------------------------

COM - (4 bit) Command code value. See COMMAND COM/DATA section below. LEN - (4 bit) Length of frame, including COM, LEN, SEQ, DATA, and CSUM.

Note: This value reflects the "byte" packet length--not the ASCII string length. For example, a GOTO command will be 4 bytes in "byte" packet length , even though the ASCII string (excluding CR) is 8 characters.

SEQ - (1 byte) Sequence number. See Protocol Operation section below. DATA - (0-4 bytes) Command/response data in big-endian format. CSUM - (1 bytes) Checksum. See CSUM description below.

----------------------------------------------------------------------

ACK/NAK packet

----------------------------------------------------------------------

The ACK/NAK packet is the same format as the COMMAND packet with a COM code corresponding to an ACK or NAK and no DATA bytes. Note that the throttle controller will not generate it's own SEQ numbers, but will instead echo back the SEQ value of the COMMAND packet. See Protocol Operation below.

----------------------------------------------------------------------

STATUS packet

----------------------------------------------------------------------

The STATUS response packet is the same format as the COMMAND packet with a COM code of STATUS, and the corresponding DATA bytes. Note that the SEQ value provided by the throttle controller will be an echo of the value passed in the COMMAND request from the Pilot. The STATUS request packet from the Pilot will have a zero length DATA field.

STATUS Response Fields: see avr_controller.h

Protocol Operation: As noted above, the Pilot will send packets with unique SEQ values (presumably increasing until rollover) to the throttle controller. All responses from the throttle controller will echo back the SEQ value from the corresponding Pilot COMMAND packet. The throttle will keep track of the the last COMMAND/response exchange. If the Pilot times out waiting for a response from the throttle, the retry packets should re-use the original SEQ value for the COMMAND packet. This way, if the timeout was due to a lost ACK/NAK, the controller will see a duplicate request multiple times. If the re-tried command is a request for STATUS that was previously sent by the throttle, the latest status information is always returned for the retry (i.e. no cached status).

----------------------------------------------------------------------

COMMAND COM/DATA

----------------------------------------------------------------------

See <art/art_command_protocol.h>. The main commands are:

ACK (0) Acknowledges COMMAND from Pilot. NAK (1) Negative acknowledge of COMMAND from Pilot. STATUS (2) STATUS command from Pilot or its response from the controller. DATA bytes as in "avr_controller.h". A STATUS request command from the PILOT will have a zero-length DATA field. GOTO (3) Sets throttle position. DATA byte: target postion.

----------------------------------------------------------------------

CSUM

----------------------------------------------------------------------

The "Simple Wikipedia" checksum algorithm is computed as follows: See

Step 1: Adding all bytes together. Step 2: Drop the Carry Nibble. Step 3: Get the two's complement. This is the checksum byte. To Test the Checksum byte simply add it to the original group of bytes. Drop the carry nibble again giving 00h. Since it is 00h this means the checksum means the bytes were probably not changed.

Note: The CSUM encompasses the COM, LEN, SEQ, and DATA fields.

Author:
Jack O'Quin

Definition at line 124 of file avr_controller.h.

typedef int16_t s16

Definition at line 125 of file avr_controller.h.

typedef uint8_t u08

Definition at line 126 of file avr_controller.h.

typedef uint16_t u16

Definition at line 127 of file avr_controller.h.

typedef uint32_t u32

Definition at line 128 of file avr_controller.h.


Function Documentation

static uint8_t avr_get_com ( struct avr_cmd cmd) [inline, static]

Definition at line 171 of file avr_controller.h.

static uint8_t avr_get_diag ( struct avr_cmd status) [inline, static]

Definition at line 195 of file avr_controller.h.

static uint8_t avr_get_direction ( struct avr_cmd status) [inline, static]

Definition at line 198 of file avr_controller.h.

static int16_t avr_get_dstate ( struct avr_cmd status) [inline, static]

Definition at line 201 of file avr_controller.h.

static bool avr_get_estop ( struct avr_cmd status) [inline, static]

Definition at line 192 of file avr_controller.h.

static bool avr_get_gen ( struct avr_cmd status) [inline, static]

Definition at line 183 of file avr_controller.h.

static int16_t avr_get_istate ( struct avr_cmd status) [inline, static]

Definition at line 204 of file avr_controller.h.

static uint8_t avr_get_len ( struct avr_cmd cmd) [inline, static]

Definition at line 174 of file avr_controller.h.

static uint8_t avr_get_pos ( struct avr_cmd status) [inline, static]

Definition at line 177 of file avr_controller.h.

static bool avr_get_pvld ( struct avr_cmd status) [inline, static]

Definition at line 186 of file avr_controller.h.

static int16_t avr_get_pwm ( struct avr_cmd status) [inline, static]

Definition at line 207 of file avr_controller.h.

static uint16_t avr_get_rpms ( struct avr_cmd status) [inline, static]

Definition at line 180 of file avr_controller.h.

static bool avr_get_rvld ( struct avr_cmd status) [inline, static]

Definition at line 189 of file avr_controller.h.

static void avr_set_com_len ( struct avr_cmd cmd,
int  com,
int  len 
) [inline, static]

Definition at line 168 of file avr_controller.h.



art_servo
Author(s): Austin Robot Technology, Jack O'Quin
autogenerated on Fri Jan 3 2014 11:09:12