diff --git a/C/src/xplaneConnect.c b/C/src/xplaneConnect.c index 2ba2572..03a8361 100644 --- a/C/src/xplaneConnect.c +++ b/C/src/xplaneConnect.c @@ -571,9 +571,8 @@ short parseRequest(const char my_message[], float *resultArray[], short arraySiz int i, j; short count = my_message[5]; short place = 6; - float *tmp; - float data[10]; - tmp = malloc(sizeof(float)); + float tmp; + float data[25]; for (i=0; i + + + + + + + + + + diff --git a/TestScripts/C Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/TestScripts/C Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index fe2b454..498e2db 100644 --- a/TestScripts/C Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/TestScripts/C Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -2,4 +2,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TestScripts/C Tests/main.c b/TestScripts/C Tests/main.c index 8803b67..4f8eec6 100644 --- a/TestScripts/C Tests/main.c +++ b/TestScripts/C Tests/main.c @@ -44,6 +44,7 @@ short closeTest() // closeUDP test printf("closeUDP - "); struct xpcSocket sendPort = openUDP( 49063, "127.0.0.1", 49009 ); closeUDP(sendPort); + sendPort = openUDP( 49063, "127.0.0.1", 49009 ); return 0; } @@ -240,41 +241,47 @@ short sendCTRLTest() // sendCTRL test float *recDATA[100]; short DREFSizes[100]; struct xpcSocket sendPort, recvPort; + short result; // Setup for (i = 0; i < 100; i++) { recDATA[i] = (float *) malloc(40*sizeof(float)); memset(DREFArray[i],0,100); } - sendPort = openUDP( 49067, "127.0.0.1", 49009 ); + sendPort = openUDP( 49066, "127.0.0.1", 49009 ); recvPort = openUDP( 49008, "127.0.0.1", 49009 ); - strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status"); - for (i=0;i<1;i++) { + strcpy(DREFArray[0],"sim/cockpit2/controls/yoke_pitch_ratio"); + strcpy(DREFArray[1],"sim/cockpit2/controls/yoke_roll_ratio"); + strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio"); + strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro"); + strcpy(DREFArray[4],"sim/cockpit/switches/gear_handle_status"); + strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqsts"); + for (i=0;i<5;i++) { DREFSizes[i] = (int) strlen(DREFArray[i]); } CTRL[3] = 0.8; // Throttle // Execute sendCTRL(sendPort, 4, CTRL); + result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test // Close closeUDP(sendPort); closeUDP(recvPort); - // Test - - // if (requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes) < 0)// Request 1 value - // { - // return -1; - // } - // if (DREFSizes[0] != 1) - // { - // return -2; - // } - // if (*recDATA[0] != value) - // { - // return -3; - // } + // Tests + if ( result < 0 )// Request 1 value + { + return -6; + } + for (i=0;i<6-1;i++) + { + if (abs(recDATA[i][0]-CTRL[i])>1e-4) + { + return -i; + } + } + return 0; } @@ -289,16 +296,23 @@ short sendPOSITest() // sendPOSI test float *recDATA[100]; short DREFSizes[100]; struct xpcSocket sendPort, recvPort; + short result; // Setup for (i = 0; i < 100; i++) { recDATA[i] = (float *) malloc(40*sizeof(float)); memset(DREFArray[i],0,100); } - sendPort = openUDP( 49067, "127.0.0.1", 49009 ); + sendPort = openUDP( 49063, "127.0.0.1", 49009 ); recvPort = openUDP( 49008, "127.0.0.1", 49009 ); - strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status"); - for (i=0;i<1;i++) { + strcpy(DREFArray[0],"sim/flightmodel/position/latitude"); + strcpy(DREFArray[1],"sim/flightmodel/position/longitude"); + strcpy(DREFArray[2],"sim/flightmodel/position/y_agl"); + strcpy(DREFArray[3],"sim/flightmodel/position/phi"); + strcpy(DREFArray[4],"sim/flightmodel/position/theta"); + strcpy(DREFArray[5],"sim/flightmodel/position/psi"); + strcpy(DREFArray[6],"sim/cockpit/switches/gear_handle_status"); + for (i=0;i<7;i++) { DREFSizes[i] = (int) strlen(DREFArray[i]); } POSI[0] = 37.524; // Lat @@ -311,12 +325,29 @@ short sendPOSITest() // sendPOSI test // Execution sendPOSI( sendPort, 0, 7, POSI ); + result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 7, recDATA, DREFSizes); // Test // Close closeUDP(sendPort); closeUDP(recvPort); - // Test + // Tests + if ( result < 0 )// Request 1 value + { + return -7; + } + for (i=0;i<7-1;i++) + { + if (i==2) + { + continue; + } + if (abs(recDATA[i][0]-POSI[i])>1e-4) + { + return -i; + } + } + return 0; } @@ -326,20 +357,65 @@ short pauseTest() // pauseSim test printf("pauseSim - "); // Initialize + int i; // Iterator + char DREFArray[100][100]; + float *recDATA[100]; + short DREFSizes[100],RECSizes[100]; struct xpcSocket sendPort, recvPort; + short result; // Setup - sendPort = openUDP( 49067, "127.0.0.1", 49009 ); + for (i = 0; i < 100; i++) { + recDATA[i] = (float *) malloc(40*sizeof(float)); + memset(DREFArray[i],0,100); + } + + // Setup + sendPort = openUDP( 49064, "127.0.0.1", 49009 ); recvPort = openUDP( 49008, "127.0.0.1", 49009 ); + strcpy(DREFArray[0],"sim/operation/override/override_planepath"); + for (i=0;i<1;i++) { + DREFSizes[i] = (int) strlen(DREFArray[i]); + } // Execute pauseSim(sendPort, 1); + result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test // Close closeUDP(sendPort); closeUDP(recvPort); // Test + if (result < 0) { + return -1; + } + if (recDATA[0][0] != 1) + { + return -2; + } + + // Reopen + sendPort = openUDP( 49064, "127.0.0.1", 49009 ); + recvPort = openUDP( 49008, "127.0.0.1", 49009 ); + + // Execute 2 + pauseSim(sendPort, 0); + result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test + + // Close 2 + closeUDP(sendPort); + closeUDP(recvPort); + + // Test 2 + if (result < 0) + { + return -3; + } + if (recDATA[0][0] != 0) + { + return -4; + } return 0; } @@ -389,7 +465,7 @@ short connTest() // setConn test int main(int argc, const char * argv[]) { - printf("XPC Tests-cpp "); + printf("XPC Tests-c "); #ifdef _WIN32 printf("(Windows)\n"); diff --git a/TestScripts/CPP Tests/main.cpp b/TestScripts/CPP Tests/main.cpp index 7c756f3..f01e249 100644 --- a/TestScripts/CPP Tests/main.cpp +++ b/TestScripts/CPP Tests/main.cpp @@ -48,6 +48,7 @@ void test2() // closeUDP test std::cout << "closeUDP - "; struct xpcSocket sendPort = openUDP( 49063, "127.0.0.1", 49009 ); closeUDP(sendPort); + sendPort = openUDP( 49063, "127.0.0.1", 49009 ); } void test3() // send/read Test @@ -239,82 +240,112 @@ void test7() // sendCTRL test float *recDATA[100]; short DREFSizes[100]; struct xpcSocket sendPort, recvPort; + short result; // Setup for (i = 0; i < 100; i++) { recDATA[i] = (float *) malloc(40*sizeof(float)); memset(DREFArray[i],0,100); } - sendPort = openUDP( 49067, "127.0.0.1", 49009 ); + sendPort = openUDP( 49066, "127.0.0.1", 49009 ); recvPort = openUDP( 49008, "127.0.0.1", 49009 ); - strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status"); - for (i=0;i<1;i++) { - DREFSizes[i] = (int) strlen(DREFArray[i]); - } - CTRL[3] = 0.8; // Throttle + strcpy(DREFArray[0],"sim/cockpit2/controls/yoke_pitch_ratio"); + strcpy(DREFArray[1],"sim/cockpit2/controls/yoke_roll_ratio"); + strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio"); + strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro"); + strcpy(DREFArray[4],"sim/cockpit/switches/gear_handle_status"); + strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqsts"); + for (i=0;i<5;i++) { + DREFSizes[i] = (int) strlen(DREFArray[i]); + } + CTRL[3] = 0.8; // Throttle // Execute - sendCTRL(sendPort, 4, CTRL); + sendCTRL(sendPort, 4, CTRL); + result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes); // Test // Close - closeUDP(sendPort); - closeUDP(recvPort); + closeUDP(sendPort); + closeUDP(recvPort); - // Test - -// if (requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, DREFSizes) < 0)// Request 1 value -// { -// throw 1; -// } -// if (DREFSizes[0] != 1) -// { -// throw 2; -// } -// if (*recDATA[0] != value) -// { -// throw 3; -// } + // Tests + if ( result < 0 )// Request 1 value + { + throw -6; + } + for (i=0;i<6-1;i++) + { + if (abs(recDATA[i][0]-CTRL[i])>1e-4) + { + throw -i; + } + } } void test8() // sendPOSI test { std::cout << "sendPOSI - "; - // Initialization - int i; // Iterator - char DREFArray[100][100]; - float POSI[8] = {0.0}; - float *recDATA[100]; - short DREFSizes[100]; - struct xpcSocket sendPort, recvPort; + // Initialize + int i; // Iterator + char DREFArray[100][100]; + float *recDATA[100]; + short DREFSizes[100],RECSizes[100]; + struct xpcSocket sendPort, recvPort; + short result; // Setup - for (i = 0; i < 100; i++) { - recDATA[i] = (float *) malloc(40*sizeof(float)); - memset(DREFArray[i],0,100); - } - sendPort = openUDP( 49067, "127.0.0.1", 49009 ); - recvPort = openUDP( 49008, "127.0.0.1", 49009 ); - strcpy(DREFArray[0],"sim/cockpit/switches/gear_handle_status"); - for (i=0;i<1;i++) { - DREFSizes[i] = (int) strlen(DREFArray[i]); - } - POSI[0] = 37.524; // Lat - POSI[1] = -122.06899; // Lon - POSI[2] = 2500; // Alt - POSI[3] = 0; // Pitch - POSI[4] = 0; // Roll - POSI[5] = 0; // Heading - POSI[6] = 1; // Gear + for (i = 0; i < 100; i++) { + recDATA[i] = (float *) malloc(40*sizeof(float)); + memset(DREFArray[i],0,100); + } - // Execution - sendPOSI( sendPort, 0, 7, POSI ); + // Setup + sendPort = openUDP( 49064, "127.0.0.1", 49009 ); + recvPort = openUDP( 49008, "127.0.0.1", 49009 ); + strcpy(DREFArray[0],"sim/operation/override/override_planepath"); + for (i=0;i<1;i++) { + DREFSizes[i] = (int) strlen(DREFArray[i]); + } + + // Execute + pauseSim(sendPort, 1); + result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test // Close - closeUDP(sendPort); - closeUDP(recvPort); + closeUDP(sendPort); + closeUDP(recvPort); // Test + if (result < 0) { + throw -1; + } + if (recDATA[0][0] != 1) + { + throw -2; + } + + // Reopen + sendPort = openUDP( 49064, "127.0.0.1", 49009 ); + recvPort = openUDP( 49008, "127.0.0.1", 49009 ); + + // Execute 2 + pauseSim(sendPort, 0); + result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 1, recDATA, RECSizes); // Test + + // Close 2 + closeUDP(sendPort); + closeUDP(recvPort); + + // Test 2 + if (result < 0) + { + throw -3; + } + if (recDATA[0][0] != 0) + { + throw -4; + } } void test9() // pauseSim test diff --git a/TestScripts/Cpp Tests.xcodeproj/project.xcworkspace/xcuserdata/cteubert.xcuserdatad/UserInterfaceState.xcuserstate b/TestScripts/Cpp Tests.xcodeproj/project.xcworkspace/xcuserdata/cteubert.xcuserdatad/UserInterfaceState.xcuserstate index 1f798ca..96f1af1 100644 Binary files a/TestScripts/Cpp Tests.xcodeproj/project.xcworkspace/xcuserdata/cteubert.xcuserdatad/UserInterfaceState.xcuserstate and b/TestScripts/Cpp Tests.xcodeproj/project.xcworkspace/xcuserdata/cteubert.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist deleted file mode 100644 index fe2b454..0000000 --- a/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcschemes/XPC Tests.xcscheme b/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcschemes/XPC Tests.xcscheme deleted file mode 100644 index 294af46..0000000 --- a/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcschemes/XPC Tests.xcscheme +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcschemes/xcschememanagement.plist b/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index e8d4ac3..0000000 --- a/TestScripts/Cpp Tests.xcodeproj/xcuserdata/cteubert.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - XPC Tests.xcscheme - - orderHint - 0 - - - SuppressBuildableAutocreation - - BE9C6BAA1A253FA100EBE08A - - primary - - - - -