System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
inMacros.h
00001 #ifndef INMACROS_H 00002 #define INMACROS_H 00003 00004 /*************** Serial String Input ****************/ 00005 00006 // Compare string to a word in the serial input, shorthand 00007 #define CMP(w, string) if (!strcasecmp(word[w-1], string)) 00008 00009 // Macro linking a serial string to a change function, 2 word command 00010 #define CHANGE_VAR(STR, NAME) \ 00011 CMP(1, STR) { \ 00012 float f = strtof(word[1], &next); \ 00013 if (*next == 0) { \ 00014 if (param->change_##NAME(f)) { \ 00015 op->profileModded=true; \ 00016 parsed=true; \ 00017 } \ 00018 } \ 00019 } 00020 00021 /*************** CAN Message Profile Out ***************/ 00022 #include "outMacros.h" 00023 00024 // Send out an item from the profile 00025 #define CAN_PROFILE(DATA, ID) \ 00026 SEND_CAN_SINGLE(param->DATA, ID); 00027 00028 // Replies for commands that do not return data 00029 #define CAN_SUCCESS \ 00030 msg.data[0]=1; \ 00031 SEND_CAN(1, msg.id) \ 00032 return 1; 00033 00034 #define CAN_FAIL \ 00035 msg.data[0]=0; \ 00036 SEND_CAN(1, msg.id) \ 00037 return 0; 00038 00039 /*********************** CAN Bus Input ******************************/ 00040 00041 template <class Type> 00042 Type CAN_EXTRACT(Type type, CANMessage& msg) { 00043 return *((Type*)((void*)(&msg.data[0]))); 00044 } 00045 00046 #define CAN_CHANGE(NAME, ID) \ 00047 if (msg.id == ID) { \ 00048 if (msg.len == sizeof(param->NAME)) { \ 00049 if (param->change_##NAME(CAN_EXTRACT(param->NAME, msg))) { \ 00050 op->profileModded=true; \ 00051 parsed = true; \ 00052 } \ 00053 } \ 00054 CAN_PROFILE(NAME, ID) \ 00055 } 00056 00057 00058 #endif
Generated on Fri Jul 15 2022 06:07:18 by
1.7.2
