Skip to content

Commit

Permalink
Merge pull request #103 from nasa/v1.2.1
Browse files Browse the repository at this point in the history
V1.2.1
  • Loading branch information
teubert authored May 3, 2017
2 parents 9ba5c14 + 2209885 commit 2bd6eec
Show file tree
Hide file tree
Showing 40 changed files with 192 additions and 96 deletions.
2 changes: 1 addition & 1 deletion C/monitorExample/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
// Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
// National Aeronautics and Space Administration. All Rights Reserved.
//
// DISCLAIMERS
Expand Down
2 changes: 1 addition & 1 deletion C/playbackExample/src/chrome.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
//
//DISCLAIMERS
Expand Down
2 changes: 1 addition & 1 deletion C/playbackExample/src/chrome.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
//
//DISCLAIMERS
Expand Down
2 changes: 1 addition & 1 deletion C/playbackExample/src/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
//
//DISCLAIMERS
Expand Down
2 changes: 1 addition & 1 deletion C/playbackExample/src/playback.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
//
//DISCLAIMERS
Expand Down
2 changes: 1 addition & 1 deletion C/playbackExample/src/playback.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
//
//DISCLAIMERS
Expand Down
42 changes: 30 additions & 12 deletions C/src/xplaneConnect.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
//
//DISCLAIMERS
Expand Down Expand Up @@ -38,6 +38,7 @@
// CONTRIBUTORS
// CT: Christopher Teubert ([email protected])
// JW: Jason Watkins ([email protected])

#include "xplaneConnect.h"

#include <math.h>
Expand All @@ -46,12 +47,18 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#ifdef _WIN32
#include <time.h>
#else
#include <sys/time.h>
#endif

int sendUDP(XPCSocket sock, char buffer[], int len);
int readUDP(XPCSocket sock, char buffer[], int len);
int sendDREFRequest(XPCSocket sock, const char* drefs[], unsigned char count);
int getDREFResponse(XPCSocket sock, float* values[], unsigned char count, int sizes[]);

void printError(char *functionName, char *format, ...)
{
va_list args;
Expand Down Expand Up @@ -306,8 +313,9 @@ int sendDATA(XPCSocket sock, float data[][9], int rows)
// 5 byte header + 134 rows * 9 values * 4 bytes per value => 4829 byte max length.
char buffer[4829] = "DATA";
int len = 5 + rows * 9 * sizeof(float);
unsigned short step = 9 * sizeof(float);
for (int i=0;i<rows;i++)
unsigned short step = 9 * sizeof(float);
int i; // iterator
for (i = 0; i < rows; i++)
{
buffer[5 + i * step] = (char)data[i][0];
memcpy(&buffer[9 + i*step], &data[i][1], 8 * sizeof(float));
Expand All @@ -328,14 +336,14 @@ int readDATA(XPCSocket sock, float data[][9], int rows)
// shouldn't be trying to read nearly this much data at once anyway.
if (rows > 134)
{
printError("sendDATA", "Too many rows.");
printError("readDATA", "Too many rows.");
// Read as much as we can anyway
rows = 134;
}

// Read data
char buffer[4829] = { 0 };
int result = readUDP(sock, buffer, 5120);
int result = readUDP(sock, buffer, 4829);
if (result <= 0)
{
printError("readDATA", "Failed to read from socket.");
Expand All @@ -346,12 +354,17 @@ int readDATA(XPCSocket sock, float data[][9], int rows)
if (readRows > rows)
{
printError("readDATA", "Read more rows than will fit in dataRef.");
// Copy as much data as we can anyway
}
else if (readRows < rows)
{
printError("readDATA", "Read fewer rows than expected.");
// Copy as much data as we read anyway
rows = readRows;
}

// Parse data
for (int i = 0; i < rows; ++i)
int i; // iterator
for (i = 0; i < rows; ++i)
{
data[i][0] = buffer[5 + i * 36];
memcpy(&data[i][1], &buffer[9 + i * 36], 8 * sizeof(float));
Expand All @@ -376,7 +389,8 @@ int sendDREFs(XPCSocket sock, const char* drefs[], float* values[], int sizes[],
// Max size is technically unlimited.
unsigned char buffer[65536] = "DREF";
int pos = 5;
for (int i = 0; i < count; ++i)
int i; // Iterator
for (i = 0; i < count; ++i)
{
int drefLen = strnlen(drefs[i], 256);
if (pos + drefLen + sizes[i] * 4 + 2 > 65536)
Expand Down Expand Up @@ -422,7 +436,8 @@ int sendDREFRequest(XPCSocket sock, const char* drefs[], unsigned char count)
unsigned char buffer[65536] = "GETD";
buffer[5] = count;
int len = 6;
for (int i = 0; i < count; ++i)
int i; // iterator
for (i = 0; i < count; ++i)
{
size_t drefLen = strnlen(drefs[i], 256);
if (drefLen > 255)
Expand Down Expand Up @@ -470,7 +485,8 @@ int getDREFResponse(XPCSocket sock, float* values[], unsigned char count, int si
}

int cur = 6;
for (int i = 0; i < count; ++i)
int i; // Iterator
for (i = 0; i < count; ++i)
{
int l = buffer[cur++];
if (l > sizes[i])
Expand Down Expand Up @@ -571,7 +587,8 @@ int sendPOSI(XPCSocket sock, float values[], int size, char ac)
// 5 byte header + up to 7 values * 5 bytes each
unsigned char buffer[40] = "POSI";
buffer[5] = ac;
for (int i = 0; i < 7; i++)
int i; // iterator
for (i = 0; i < 7; i++)
{
float val = -998;

Expand Down Expand Up @@ -650,7 +667,8 @@ int sendCTRL(XPCSocket sock, float values[], int size, char ac)
// 5 byte header + 5 float values * 4 + 2 byte values
unsigned char buffer[31] = "CTRL";
int cur = 5;
for (int i = 0; i < 6; i++)
int i; // iterator
for (i = 0; i < 6; i++)
{
float val = -998;

Expand Down
2 changes: 1 addition & 1 deletion C/src/xplaneConnect.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
//
//DISCLAIMERS
Expand Down
2 changes: 1 addition & 1 deletion Java/src/ViewType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//NOTICES:
// Copyright ã 2013-2015 United States Government as represented by the Administrator of the
// Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
// National Aeronautics and Space Administration. All Rights Reserved.
//
// DISCLAIMERS
Expand Down
2 changes: 1 addition & 1 deletion Java/src/WaypointOp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//NOTICES:
// Copyright ã 2013-2015 United States Government as represented by the Administrator of the
// Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
// National Aeronautics and Space Administration. All Rights Reserved.
//
// DISCLAIMERS
Expand Down
2 changes: 1 addition & 1 deletion Java/src/XPlaneConnect.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//NOTICES:
// Copyright ã 2013-2015 United States Government as represented by the Administrator of the
// Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
// National Aeronautics and Space Administration. All Rights Reserved.
//
// DISCLAIMERS
Expand Down
4 changes: 2 additions & 2 deletions MATLAB/+XPlaneConnect/readDATA.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[readDATA] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal((length(clients) < 2),1), '[readDATA] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
socket = openUDP();
else
Expand All @@ -46,7 +46,7 @@
end

%% Get data
result.raw = socket.readDATA();
result.raw = socket.readData();

%% Format data
rows = (length(result.raw) - 5) / 9;
Expand Down
2 changes: 1 addition & 1 deletion MATLAB/+XPlaneConnect/selectDATA.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function selectDATA( rows, socket )
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[selectDATA] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal((length(clients) < 2),1), '[selectDATA] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
socket = openUDP();
else
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ against the "develop" branch. Pull requests will be evaluated and integrated int
the next official release.

###Notices
Copyright ©2013-2015 United States Government as represented by the Administrator
Copyright ©2013-2016 United States Government as represented by the Administrator
of the National Aeronautics and Space Administration. All Rights Reserved.

No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
Expand Down
10 changes: 5 additions & 5 deletions TestScripts/C Tests.win/CTests.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -44,26 +44,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions TestScripts/C Tests.win/CTests.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@
<ClInclude Include="..\C Tests\Test.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\C Tests\ViewTests.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
Loading

0 comments on commit 2bd6eec

Please sign in to comment.