C-like message definition

This section defines the message protocol using C-like declarations of constants and structures. The convention here is that words beginning with c, such as cSETVALUE and cGETVALUE, are character constants. Words beginning with f, such as fUid and fVal, are message field structures. Words beginning with m, such as mSetValue and mGetValue, are message structures.

//---- Message constants
const char cSETVALUE = 'S'; // an fType value
const char cGETVALUE = 'G'; // an fType value
const char cVALUE = 'V'; // an fType value
const char cNOTREADY = 'R'; // an fType value
const char cUNLISTEDUID = 'U'; // an fType value
const char cFAIL = 'X'; // an fType value
const char cNAK = '?'; // an fType value
const char cEOM = '.'; // an fEom value

//---- Message fields
/* fType: Message Type. 1 character, denotes the message type. */
struct fType {
  char data;
};
/* fUid: User ID. 3 ASCII characters, specifies one of the User IDs entered as a control alias in the project. */
struct fUid {
  char data[3];
};

/* fVal: Control Value. 2 ASCII hexadecimal digits, specifies a control value between 0 and 255. */
struct fVal {
  char data[2];
};

/* fEom: End Of Message. 1 character, appears at the end of every message, excepting mNak. */
struct fEom {
  char data = cEOM;
};

//---- Messages
/* mNak: Negative Acknowledge. Response sent to client upon receipt of unintelligible data. This could be due to a communications error or to data out of order. An mNak is not necessarily sent for every byte of bad data. */
struct mNak {
  fType = cNAK;
};

/* mSetValue: Set Control Value. Request sent by a client to set the value of a control identified by a control alias. */
struct mSetValue {
  fType type = cSETVALUE;
  fUid id;
  fVal val;
   fEom eom;
};

/* mGetValue: Get Control Value. Request sent by a client requesting the value of a control identified by a control alias. */
struct mGetValue {
  fType type = cGETVALUE;
  fUid id;
  fEom eom;
}};

/* mValue: Control Value. Response sent to the client acknowledging an mGetValue or mSetValue. Note that it is possible, and normal in some cases, that the val field will not match the val that was sent in the mSetValue. */
struct mValue {
  fType type = cVALUE;
  fUid id;
  fVal val;
  fEom eom;
};

//* mUnlistedUid: Unlisted User ID error. Response indicating the fUid specified in the mSetValue or mGetValue does not match any control aliases in the currently running project. */
struct mUnlistedUid {
  fType type = cUNLISTEDUID;
  fUid id;
  fEom eom;
};
/* mNotReady: Not Ready. This means that there is no project currently compiled and running in MediaMatrix. */
struct mNotReady {
  fType type = cNOTREADY;
  fEom eom;
};

/* mFail: Something Has Failed. This is sent in response to serial port errors, communication time-outs, and other internal errors not covered directly. */
struct mFail { 
  fType type = cFAIL;
  fEom eom;
};

See also

Introduction

Allowing PASHA to be used on a MediaMatrix node

Testing and debugging

PASHA user IDs and control aliases

Message protocol

Getting and setting control values

Message structures quick chart

Serial Control Value to Device Control Value Tables