From 5d50d970bd4636804a305ef8903e169a2de58c7c Mon Sep 17 00:00:00 2001 From: Chris Teubert Date: Wed, 1 Apr 2015 15:58:01 -0700 Subject: [PATCH] sendCTRL Bug Fixed bug where sendCTRL is sending gear as float. Changed to char as specified in ICD. --- C/src/xplaneConnect.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/C/src/xplaneConnect.c b/C/src/xplaneConnect.c index 4d04972..cf71557 100755 --- a/C/src/xplaneConnect.c +++ b/C/src/xplaneConnect.c @@ -373,7 +373,7 @@ short sendPOSI(struct xpcSocket recfd, short ACNum, short numArgs, float valueAr short sendCTRL(struct xpcSocket recfd, short numArgs, float valueArray[]) { - char message[29] = {0}; + char message[26] = {0}; int i; short position = 5; @@ -396,12 +396,21 @@ short sendCTRL(struct xpcSocket recfd, short numArgs, float valueArray[]) val = valueArray[i]; } - // Float Values - memcpy(&message[position],&val,sizeof(float)); - position += sizeof(float); + if (i==4) // Integer-gear + { + message[position] = (short int) val; + position += 1; + } + else // float + { + // Float Values + memcpy(&message[position],&val,sizeof(float)); + position += sizeof(float); + } + } - sendUDP(recfd, message, 29); + sendUDP(recfd, message, 26); return 0; }