System Management code

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Committer:
pspatel321
Date:
Wed Feb 11 23:09:57 2015 +0000
Revision:
39:ddf38df9699e
Parent:
38:8efacce315ae
Updated CAN IDs for datalogging.  Changed profile encoding.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pspatel321 38:8efacce315ae 1 #ifndef OUT_MACROS_H
pspatel321 38:8efacce315ae 2 #define OUT_MACROS_H
pspatel321 38:8efacce315ae 3
pspatel321 38:8efacce315ae 4 /******************************* FOR WORKING WITH THE STRING BUFFER ***************************/
pspatel321 38:8efacce315ae 5
pspatel321 38:8efacce315ae 6
pspatel321 38:8efacce315ae 7 // Macros for working with the strings
pspatel321 38:8efacce315ae 8 #define ADD_SPRINTF_LINE temp[max_charsPerLine-1]=0; padCenter(max_charsPerLine, temp, ' '); // Cetner the string, then add newlines, and add to chunk
pspatel321 38:8efacce315ae 9 #define DIVIDER_LINE padCenter(max_charsPerLine, "", 196); // Generate a line full of divider char 196, add to chunk
pspatel321 38:8efacce315ae 10 #define TITLE(string) padCenter(max_charsPerLine, string, 196); // Generate a title line (centered, surrounded by char 196), add to chunk
pspatel321 38:8efacce315ae 11 #define BLANK_LINE padCenter(max_charsPerLine, "", ' '); // Generate a line full of spaces (blank), add to chunk
pspatel321 38:8efacce315ae 12
pspatel321 38:8efacce315ae 13
pspatel321 38:8efacce315ae 14 /********************************** FOR WORKING WITH CAN MESSAGES ******************************/
pspatel321 38:8efacce315ae 15
pspatel321 38:8efacce315ae 16 #define SEND_CAN(LEN, ID) \
pspatel321 38:8efacce315ae 17 msg.len = LEN; \
pspatel321 38:8efacce315ae 18 msg.id = ID; \
pspatel321 38:8efacce315ae 19 msg.type = CANData; \
pspatel321 38:8efacce315ae 20 msg.format = CANStandard; \
pspatel321 38:8efacce315ae 21 if (!can.txWrite(msg)) op->faultCode |= CAN_FAULT;
pspatel321 38:8efacce315ae 22
pspatel321 38:8efacce315ae 23 template <class Type>
pspatel321 38:8efacce315ae 24 void SEND_CAN_SINGLE(Type Data, int ID)
pspatel321 38:8efacce315ae 25 {
pspatel321 38:8efacce315ae 26 CANMessage msg;
pspatel321 38:8efacce315ae 27 *((Type*)((void*)&msg.data[0])) = Data;
pspatel321 38:8efacce315ae 28 SEND_CAN(sizeof(Type), ID)
pspatel321 38:8efacce315ae 29 }
pspatel321 38:8efacce315ae 30 template <class Type>
pspatel321 38:8efacce315ae 31 void SEND_CAN_PAIR(Type Data1, Type Data2, int ID)
pspatel321 38:8efacce315ae 32 {
pspatel321 38:8efacce315ae 33 CANMessage msg;
pspatel321 38:8efacce315ae 34 *((Type*)((void*)&msg.data[0])) = Data1;
pspatel321 38:8efacce315ae 35 *((Type*)((void*)&msg.data[sizeof(Type)])) = Data2;
pspatel321 38:8efacce315ae 36 SEND_CAN(2*sizeof(Type), ID)
pspatel321 38:8efacce315ae 37 }
pspatel321 38:8efacce315ae 38
pspatel321 38:8efacce315ae 39 #define CAN_SINGLE(DATA, ID) SEND_CAN_SINGLE(op->DATA, ID);
pspatel321 38:8efacce315ae 40 #define CAN_PAIR(DATA1, DATA2, ID) SEND_CAN_PAIR(op->DATA1, op->DATA2, ID);
pspatel321 38:8efacce315ae 41
pspatel321 38:8efacce315ae 42 #endif