Changeset 18725
- Timestamp:
- 01/10/17 13:51:37 (8 years ago)
- Location:
- branches/FACT++_lidctrl_usb/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FACT++_lidctrl_usb/src/HeadersLid.h
r18724 r18725 2 2 #define FACT_HeadersLid 3 3 4 namespace Lid CtrlUsb4 namespace Lid 5 5 { 6 7 struct motor_status_t{ 8 float current_mean; 9 float position_mean; 10 int32_t speed; 11 } __attribute__((__packed__)); 12 13 struct mean_var_samples_t { 14 uint32_t mean; 15 uint32_t var; 16 uint16_t samples; 17 }__attribute__((packed)); 18 19 struct message_t { 20 mean_var_samples_t inner_motor_current; 21 mean_var_samples_t outer_motor_current; 22 23 mean_var_samples_t inner_motor_position; 24 mean_var_samples_t outer_motor_position; 25 26 int16_t inner_motor_speed; 27 int16_t outer_motor_speed; 28 29 char current_cmd; 30 uint8_t system_state; 31 }__attribute__((packed)); 32 6 33 namespace State 7 34 { -
branches/FACT++_lidctrl_usb/src/lidctrl.cc
r18724 r18725 24 24 using namespace std; 25 25 26 using namespace Lid CtrlUsb;26 using namespace Lid; 27 27 28 28 #include "DimDescriptionService.h" … … 36 36 State::states_t state; 37 37 State::states_t last_state; 38 struct mean_std_t { 39 uint32_t mean; 40 uint32_t var; 41 uint16_t samples; 42 }__attribute__((packed)); 43 44 struct motor_status_t{ 45 float current_mean; 46 float position_mean; 47 int32_t speed; 48 } __attribute__((__packed__)); 49 50 struct message_t { 51 mean_std_t inner_motor_current; 52 mean_std_t outer_motor_current; 53 54 mean_std_t inner_motor_position; 55 mean_std_t outer_motor_position; 56 57 int16_t inner_motor_speed; 58 int16_t outer_motor_speed; 59 60 char current_cmd; 61 uint8_t system_state; 62 }__attribute__((packed)); 63 64 DimDescribedService fDimInnerMotor; 65 DimDescribedService fDimOuterMotor; 38 39 DimDescribedService fDimInnerMotor; 40 DimDescribedService fDimOuterMotor; 66 41 message_t fLastMessage; 42 67 43 void PrintMessage(const message_t msg) 68 44 { … … 83 59 { 84 60 int complete_msg_size = 6 /*start:*/ + sizeof(message_t) + sizeof(uint16_t)/*chksum*/; // 54 bytes 85 61 86 62 std::copy(fRecievedBytes.begin(), fRecievedBytes.begin()+bytes_received, std::back_inserter(fCollectedBytes)); 87 63 if (fCollectedBytes.size() > 2*complete_msg_size) … … 96 72 message_t msg; 97 73 memcpy(&msg, part.data(), sizeof(message_t)); 98 74 99 75 const uint16_t chk0 = Tools::Fletcher16(part.c_str(), sizeof(message_t)); 100 76 uint16_t chk1; … … 111 87 inner_motor_status.position_mean = (float)(msg.inner_motor_position.mean); 112 88 inner_motor_status.speed = (int32_t)msg.inner_motor_speed; 113 89 114 90 motor_status_t outer_motor_status; 115 91 outer_motor_status.current_mean = (float)(msg.outer_motor_current.mean) * 3.4; … … 122 98 } 123 99 124 last_state = state; 100 last_state = state; 125 101 } 126 102 } … … 157 133 return state; 158 134 } 159 160 161 162 135 }; 163 136 … … 204 177 return T::GetCurrentState(); 205 178 } 206 179 207 180 int Close() 208 181 {
Note:
See TracChangeset
for help on using the changeset viewer.