From efdb27271e6a6ada271db0ea29cf270cb01da78e Mon Sep 17 00:00:00 2001
From: "ucart@co3050-12" <dawehr@iastate.edu>
Date: Mon, 30 Jan 2017 18:55:49 -0600
Subject: [PATCH] Fixed a bug in cb_getcontrol.

I was not copying the float value into the array correctly.
Hopefully I have it right now... will check with eric when he gets back from making tea.
---
 quad/sw/modular_quad_pid/src/callbacks.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/quad/sw/modular_quad_pid/src/callbacks.c b/quad/sw/modular_quad_pid/src/callbacks.c
index 805d05d9b..2081b1dd5 100644
--- a/quad/sw/modular_quad_pid/src/callbacks.c
+++ b/quad/sw/modular_quad_pid/src/callbacks.c
@@ -214,13 +214,10 @@ int cb_getcontrol(modular_structs_t* structs)
 			// Controller value ID
 			resp_data[1] = controller_value_id;
 			// Controller value (4 byte float)
-			resp_data[2] = (controller_value) & 0x000000ff;
-			resp_data[3] = (controller_value >> 8) & 0x000000ff;
-			resp_data[4] = (controller_value >> 16) & 0x000000ff;
-			resp_data[5] = (controller_value >> 24) & 0x000000ff;
+			memcpy(&resp_data[2], &controller_value, sizeof(controller_value));
 			
 			// Send the data
-			send_data(RESPCONTROL_ID, msg_id, resp_data, sizeof(resp_data);
+			send_data(RESPCONTROL_ID, msg_id, resp_data, sizeof(resp_data));
 		}
 
 	}
-- 
GitLab