/* ============================================================================ Abs: Knob Controller <--> Knob Box message structures & definitions. Most copied from pkpkmsgs.h and pknmsg_p.h Name: knobCtrlBoxCommDef.h ============================================================================= */ #ifndef KNOB_CTRL_BOX_COMM_DEF_H /* guard macro */ #define KNOB_CTRL_BOX_COMM_DEF_H /* guard macro */ #ifdef __cplusplus extern "C" { #endif #include "knobCtrlDef.h" /* ** For message structure names and functions, 'TK' means TO KNOB and ** 'FK' means FROM KNOB. This is a Controller-centric file. ** ** Function codes for all of the Controller <--> Knob Box messages. */ #define TKRQST_COUNT 0x81 /* To knob request count */ #define FKREPLY_COUNT 0x82 /* From knob count reply */ #define TKLEGEND_UPDATE 0x83 /* To knob legend update */ #define TKRQST_RESET 0x84 /* To knob request status reset */ #define TKSET_COUNT 0x85 /* To knob set counter */ #define TKRQST_STATUS 0x86 /* To knob request status */ #define FKREPLY_STATUS 0x87 /* From knob status reply */ /* Below only supported by Knob Box Pro */ #define TKRQST_INFO 0x88 /* To knob info request */ #define FKREPLY_INFO 0x89 /* From knob info reply */ #define TKACK_RESTORE 0x8A /* To knob acknowledge hardware restore */ #define TKACK_BOOT 0x8B /* To knob acknowledge box just powered up */ /* ** Some standard ASCII chars */ #define CR 0xD #define CTRL_B 2 /* ** ******************************************************** ** Message structures exchanged twixt us and the knobs box. ** ******************************************************** */ typedef struct /* header common to all controller-knobs messages */ { unsigned char ctrl_b; /* control-b ascii code */ unsigned char knobcpu; /* knob which is miranova cpu address */ unsigned char func; /* function code */ }ckhead_ts; typedef struct /* tail common to all controller-knobs messages */ { unsigned char checksum; /* msg checksum */ unsigned char cr; /* ascii carriage return code */ }cktail_ts; /* ** Struct for the 6 to-knob messages differentiated only by ** function code. */ typedef struct /* TKRQST_COUNT, TKRQST_RESET, TKRQST_INFO, */ { /* TKRQST_STATUS, TKACK_RESTORE, TKACK_BOOT msg struct */ ckhead_ts ckhead; /* Controller-knob message header */ cktail_ts tail; /* Controller-knob message tail */ }tkrqst_ts; /* ** Structs for the legend update message. (different for box type due to oversight) ** For boxes that support multiple rows, one message per row */ typedef struct /* TKLEGEND_UPDATE msg struct */ { /* Variable length structure */ ckhead_ts ckhead; /* Controller-knob message header */ char ledset; /* LED set (0-3) in box */ char ledrow; /* LED row, 0 for top row, 1 for bottom row */ char ledindex; /* LED index (0-15) for text start */ char legend[LEGEND_SIZE]; /* max chars to write to LEDs */ cktail_ts tail; /* Message tail */ }tklegend_update_ts; typedef struct /* TKLEGEND_UPDATE msg struct */ { /* Variable length structure */ ckhead_ts ckhead; /* Controller-knob message header */ char ledset; /* LED set (0-3) in box */ char ledindex; /* LED index (0-15) for text start */ char legend[LEGEND_SIZE]; /* max chars to write to LEDs */ cktail_ts tail; /* Message tail */ }tklegend_update_miranova_ts; /* ** Struct to set counter */ typedef struct /* TKSET_COUNT msg struct */ { ckhead_ts ckhead; /* Controller-knob message header */ unsigned char low; /* Low byte of count */ unsigned char hi; /* Hi byte of count */ cktail_ts tail; /* Message tail */ }tkset_count_ts; /* ** Count reply message from knob. */ typedef struct /* FKREPLY_COUNT msg struct */ { ckhead_ts ckhead; /* Controller-knob message header */ unsigned char low; /* Low byte of count */ unsigned char hi; /* Hi byte of count */ unsigned char status; /* Knob box/comm status */ cktail_ts tail; /* Message tail */ }fkreply_count_ts; /* ** Status reply message from knob */ typedef struct /* FKREPLY_STATUS msg struct */ { ckhead_ts ckhead; /* Controller-knob message header */ unsigned char kstatus; /* Knob status byte (see below) */ cktail_ts tail; /* Message tail */ }fkreply_status_ts; /* ** Info reply message from knob; use 0-knob for knobcpu */ typedef struct /* FKRPLY_INFO msg struct */ { ckhead_ts ckhead; /* Controller-knob message header */ unsigned char type; /* Knob box type (see knobCtrlDef.h) */ unsigned char versmajor; /* Knob code major version number */ unsigned char versminor; /* Knob code minor version number */ unsigned char verspatch; /* Knob code patch version number */ cktail_ts tail; /* Message tail */ }fkreply_info_ts; /* * Original Miranova knob status byte bit assignments: * * 0 Poll Bit, 1 = is being polled * 1 Count Overflow * 2 Count Underflow * 3 Checksum Error * 4 Serial Overrun Error * 5 Button Status, 1 = button is pushed * 6 Unknown Message Error * 7 Excessive Count Rate On Encoder Error * * The above bits were not used by the software, though, * so we are repurposing them, when useful: * * 0 Knob box state, 1 = just powered up, 0 power up has been acknowledged by software If not too much trouble, make hw restore bit 1 * 1 Knob hardware restore, 1 = restore button has been pressed, 0 restore has been acknowledged by software * 2 Knob hardware disable button, 1 = disable button is pressed, 0 = disable button is not pressed * 3 Unused * 4 Unused * 5 Unused If not too much trouble, no longer use bit 6 for this * 6 Hardware restore, 1 = restore button has been pressed * 7 Unused */ #define FK_BOOT 0x1 #define FK_RESTORE 0x2 #define FK_DISABLE 0x4 /* * Callbacks for communication with knob boxes * * Callbacks for communication with knob device * void *device is private data for knob device callbacks * init_knob callback initializes it and returns it, then it is * stored in knobdevice_ts struct * * knob_init_comm: One-time communication initialization * Return -1 if error, 0 if success * * knob_init_line: Per-line initialization * Return -1 if error, 0 if success * * knob_init_box: Per-box initialization * Return -1 if error, 0 if success * * knob_write: Send message to box * * knob_write: Read message from box * */ typedef struct knobcbrec { int (*knob_init_comm) (void *ptr); int (*knob_init_line) (line_ts *line_ps, void *lineio); int (*knob_init_box) (line_ts *line_ps, box_ts *box_ps); void (*knob_write) (box_ts *box_ps, unsigned char *bufo_p, int count, uint32_t *iss, short dbg); void (*knob_read) (box_ts *box_ps, unsigned char *inmsgbuf, int elen, int *inmsglen, unsigned char *recvknobcpu, uint32_t *iss); }knobcb_ts; extern knobcb_ts knobCommCallbacks; #ifdef __cplusplus }; #endif #endif /* KNOB_CTRL_BOX_COMM_DEF_H guard macro */