From 6417822a751a42b085bcb8f21726f630978fe917 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Thu, 9 Apr 2015 10:24:30 -0700 Subject: [PATCH] Added C test for WYPT command and fixed bugs in parseWYPT and sendWYPT. --- C/src/xplaneConnect.c | 4 ++-- TestScripts/C Tests/main.c | 44 +++++++++++++++++++++++++++++++++----- xpcPlugin/XPCPlugin.cpp | 7 ++++-- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/C/src/xplaneConnect.c b/C/src/xplaneConnect.c index de0991f..7dae28b 100755 --- a/C/src/xplaneConnect.c +++ b/C/src/xplaneConnect.c @@ -453,7 +453,7 @@ short sendWYPT(struct xpcSocket sendfd, WYPT_OP op, float points[], int numPoint { buf[5] = op; buf[6] = numPoints; - size_t len = sizeof(float) * numPoints; + size_t len = sizeof(float) * 3 * numPoints; memcpy(buf + 7, points, len); sendUDP(sendfd, buf, len + 7); return 0; @@ -721,7 +721,7 @@ xpcWypt parseWYPT(const char data[]) { result.op = data[5]; result.numPoints = data[6]; - char* ptr = data[7]; + char* ptr = data + 7; for (size_t i = 0; i < result.numPoints; ++i) { result.points[i].latitude = *((float*)ptr); diff --git a/TestScripts/C Tests/main.c b/TestScripts/C Tests/main.c index 430db3d..4ee58ba 100644 --- a/TestScripts/C Tests/main.c +++ b/TestScripts/C Tests/main.c @@ -435,6 +435,39 @@ short sendPOSITest() // sendPOSI test return 0; } +short sendWYPTTest() +{ + printf("sendWYPT - "); + + // Setup + struct xpcSocket sendPort = openUDP(49064, "127.0.0.1", 49009); + float points[] = + { + 37.5245, -122.06899, 2500, + 37.455397, -122.050037, 2500, + 37.469567, -122.051411, 2500, + 37.479376, -122.060509, 2300, + 37.482237, -122.076130, 2100, + 37.474881, -122.087288, 1900, + 37.467660, -122.079391, 1700, + 37.466298, -122.090549, 1500, + 37.362562, -122.039223, 1000, + 37.361448, -122.034416, 1000, + 37.361994, -122.026348, 1000, + 37.365541, -122.022572, 1000, + 37.373727, -122.024803, 1000, + 37.403869, -122.041283, 50, + 37.418544, -122.049222, 6 + }; + + // Test + sendWYPT(sendPort, xpc_WYPT_ADD, points, 15); + + // Cleanup + closeUDP(sendPort); + return 0; +} + short pauseTest() // pauseSim test { printf("pauseSim - "); @@ -560,16 +593,17 @@ int main(int argc, const char * argv[]) printf("(Linux) \n"); #endif - runTest(openTest); - runTest(closeTest); + runTest(openTest); + runTest(closeTest); runTest(sendReadTest); runTest(sendTEXTTest); - runTest(requestDREFTest); - runTest(sendDREFTest); + runTest(requestDREFTest); + runTest(sendDREFTest); runTest(sendDATATest); runTest(sendCTRLTest); runTest(sendpCTRLTest); - runTest(sendPOSITest); + runTest(sendPOSITest); + runTest(sendWYPTTest); runTest(pauseTest); runTest(connTest); diff --git a/xpcPlugin/XPCPlugin.cpp b/xpcPlugin/XPCPlugin.cpp index d6fee5e..bc8dd29 100755 --- a/xpcPlugin/XPCPlugin.cpp +++ b/xpcPlugin/XPCPlugin.cpp @@ -216,8 +216,6 @@ PLUGIN_API int XPluginEnable(void) sprintf(logmsg,"[EXEC] Debug Enabled (Verbosity: %i)",debugSwitch); updateLog(logmsg,strlen(logmsg)); } - - XPCSetMessage(20, 700, "TEST"); return 1; } @@ -844,6 +842,11 @@ int handleWYPT(char buf[], int len) updateLog(logmsg, strlen(logmsg)); return -1; } + else + { + sprintf(logmsg, "[WYPT] Performing operation %i", wypt.op); + updateLog(logmsg, strlen(logmsg)); + } switch (wypt.op) {