/* ============================================================================= Abs: Knob Controller <--> Knob User message structures & definitions. Mostly copied from pkcumsgs.h and pkvmsg_p.h Name: knobCtrlUserCommDef.h ============================================================================= */ #ifndef KNOB_CTRL_USER_COMM_DEF_H /* guard macro */ #define KNOB_CTRL_USER_COMM_DEF_H /* guard macro */ #ifdef __cplusplus extern "C" { #endif #include #include "knobCtrlDef.h" /* ** For message structure names and functions, 'TU' means TO USER and ** 'FU' means FROM USER. This is a Controller-centric file. ** ** Function codes for all of the Controller <--> User messages. */ #define FUATTACH 1 /* Attach a point to a knob */ #define FUDETACH 2 /* Detach a point from a knob */ #define FULEGEND 3 /* Update a knob legend */ #define TUACK 4 /* Ack for FUATTACH & FUDETACH */ #define TUTURNS 5 /* An attached knob has been turned */ #define FUHEART 6 /* Check if PC is alive */ #define TUHEART 7 /* Response if alive */ /* Following codes are supported by new Knob Users, but not by SLC * Control System. Users should ignore unsupported messages */ #define TURESTORE 8 /* Hardware restore button pressed */ #define TUUSURP 9 /* Other user has taken over knob */ #define PCPORT 2001 /* Default port number for controller to listen to * Used in network-based protocol (UDP) * Historical, used by VMS * User can override (see knobCtrlUserUdp) */ #define MAX_USER_MSG 50 /* Max length Controller <--> User msg length */ /* ** Common header for fulegend & tuturns message structs. It has the message ** code, knob ID info and the User-assigned sequence number. The sequence ** number is used to check for messages received out of sequence. */ typedef struct { char code; /* Message type code */ char line; /* Line number 0 based */ char box; /* Box number on line */ char knob; /* Relative knob number 0 based */ uint32_t seqnum; /* Sequence number assigned by User */ }cuhead_ts; /* ** Common structure for the attach, detach and legend update messages ** since all must update the knob legend. The legend may be variable ** length with size nbytes. */ typedef struct /* FUATTACH/FUDETACH/FULEGEND msgs */ { cuhead_ts cuhead_s; /* Controller/User Message header */ char offset; /* Starting character offset */ char nbytes; /* # valid bytes in legend */ char legend[LEGEND_SIZE]; /* Chars to write to legend */ }fulegend_ts; /* ** Common structure for the turns, restore, and usurp messages. The turns ** field is only populated for the turns message. ** ** tuturns msg is sent when a knob turn has been detected on an attached knob ** turestore msg is sent when a hardware restore button has been pressed on an attached knob ** tuusurp msg is sent when another user has taken control of an attached knob */ typedef struct /* TUTURNS/TURESTORE/TUUSURP msgs */ { cuhead_ts cuhead_s; /* Controller/User message header */ uint32_t userstat; /* Acknowledgement status */ int16_t turns; /* Turn count since last read */ uint16_t sstatus; /* Status of last send/recv from knob */ }tuturns_ts; /* ** Acknowledge structure for the attach & detach messages. */ typedef struct /* TUACK msg to FUATTACH & FUDETACH */ { cuhead_ts cuhead_s; /* Controller/User message header */ uint32_t userstat; /* Acknowledgement status */ char acode; /* Message code for which this is the ack */ uint16_t sstatus; /* Status of last send/recv from knob */ }tuack_ts; /* ** Heartbeat message sent by any user process to check on this Knob ** Controller's health */ typedef struct /* FUHEART heartbeat check */ { char code; /* Message type code */ }fuheart_ts; /* ** Response to the above message */ typedef struct /* TUHEART ack for FUHEART msg */ { char code; /* Message type code */ uint32_t userstat; /* status */ }tuheart_ts; /* ** Callbacks for communication with Knob Users ** ** For Controller<->User communication, User is the client ** and Ctrl is the server ** ** ctrlio_p is the handle for the controller-side communication (wrt to users). ** It is passed around by the controller software but its comments ** are only accessed by the callbacks ** userio_p is the handle for the user's communication info. ** It is passed around by the controller software but its comments ** are only accessed by the callbacks ** ** We allow the option of different users to controller knobs on the same box. ** Thus, there is a knob-specific data structure to contain user information. ** Also, there are 3 knob-specific callbacks to support this. ** ** ** Routines: ** ** init_ctrlio - Create and return ctrlio_p ** ** init_userio - Create and return userio_p ** ** init_comm - Initialize communication for messages with knob users. ** Return -1 on error, 0 on success ** ** init_knob - Create and return handle to knob's user info (again, passed around ** by controller software but only accessed by callbacks) ** ** knob_assoc - Store user info in knob handle ** ** knob_check_owner - Compare user info passed as argument with current 'owner' of knob. ** (The new user info comes from a recent request and the purpose ** is to not allow a non-owner access to the knob.) ** Return 0 if the users match, -1 if not ** ** write - Send message to knob user ** ** read - Read message from user ** ** write_uint32, write_uint16 - Convert multi-byte word before sending ** ** read_uint32, read_uint16 - Convert multi-byte word after reading */ typedef struct kusercbrec { void *(*init_ctrlio) (void); void *(*init_userio) (void); int (*init_comm) (void *ctrlio_p, void *kuserio_p); void *(*init_knob) (void); void (*knob_assoc) (void *kuserio_p, void *newkuserio_p); int (*knob_check_owner) (void *kuserio_p, void *newkuserio_p); void (*write) (void *ctrlio_p, void *kuserio_p, void *omsg_p, int length); void (*read) (void *ctrlio_p, void *kuserio_p, unsigned char *inmsgbuf_p, int *inmsglen_p); uint32_t (*write_uint32 ) (uint32_t); uint16_t (*write_uint16 ) (uint16_t); uint32_t (*read_uint32 ) (uint32_t); uint16_t (*read_uint16 ) (uint16_t); }kusercb_ts; extern const void *knobCtrlUserCommCbRegistryId; extern kusercb_ts knobUserCommCallbacks; #ifdef __cplusplus }; #endif #endif /* KNOB_CTRL_USER_COMM_DEF_H guard macro */