Skip to content

Commit

Permalink
Merge pull request #40 from waynepiekarski/feature/versioning
Browse files Browse the repository at this point in the history
Implement the EXTPLANE-VERSION header for versioning
  • Loading branch information
vranki authored Nov 19, 2018
2 parents 4558c2b + 5d0e5cc commit bbe992b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ scripts/cross-compile-win64-from-lin.sh for instructions.
Launch X-Plane in console and observe the output. You should see something like:
`ExtPlane-Plugin: Listening on port 51000`. All console output from Ext-Plane
will start with `ExtPlane-Plugin`. Open another console and run `telnet localhost 51000`.
Wait until you see line `EXTPLANE 1`. Then try typing the following commands:
Wait until you see line `EXTPLANE 1` and `EXTPLANE-VERSION NNNNN`. Then try typing the following commands:

```
sub sim/cockpit/electrical/night_vision_on
Expand Down Expand Up @@ -287,10 +287,15 @@ Supported settings are:

## Protocol Output ##

* **EXTPLANE {version}** Sent when connected. Version number is currently 1.
* **EXTPLANE {protocol}** Sent when connected. Protocol is currently 1.
* **EXTPLANE-VERSION {version}** Sent when connected. Feature version integer, which is incremented with each new bug fix or feature.
* **u{type} {dataref} {value}** Dataref has changed in value based on accuracy.
* Types may be `i` (int), `f` (float), `d` (double), `ia` (int array), `fa` (float array), or `b` (data).

The value for EXTPLANE-VERSION is defined in extplane-server/tcpserver.h. It is an integer and should be incremented
each time new features are added or bugs are fixed. The client is then able to check if the version is new enough, and can
warn the user if the plugin is out of date.

### Int/Float/Double Datarefs ###

Example output:
Expand Down
5 changes: 4 additions & 1 deletion extplane-plugin/xplaneplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int XPlanePlugin::pluginStart(char * outName, char * outSig, char *outDesc) {
INFO << "Plugin started";
strcpy(outName, "ExtPlane");
strcpy(outSig, "org.vranki.extplaneplugin");
strcpy(outDesc, "Read and write X-Plane datarefs from external programs using TCP sockets.");
strcpy(outDesc, "Read and write X-Plane datarefs from external programs on TCP port " EXTPLANE_PORT_STR " with protocol " EXTPLANE_PROTOCOL_STR " version " EXTPLANE_VERSION_STR);

// Init application and server
app = new QCoreApplication(argc, &argv);
Expand All @@ -53,6 +53,9 @@ int XPlanePlugin::pluginStart(char * outName, char * outSig, char *outDesc) {
server = new TcpServer(this, this);
connect(server, SIGNAL(setFlightLoopInterval(float)), this, SLOT(setFlightLoopInterval(float)));

// Log that we have started
XPLMDebugString ("ExtPlane listening on TCP port " EXTPLANE_PORT_STR " with protocol " EXTPLANE_PROTOCOL_STR " version " EXTPLANE_VERSION_STR "\n");

// Register the nav custom data accessors
XPLMRegisterDataAccessor("extplane/navdata/5km",
xplmType_Data, // The types we support
Expand Down
4 changes: 3 additions & 1 deletion extplane-server/tcpclient.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "tcpclient.h"
#include "tcpserver.h"
#include "datarefs/dataref.h"
#include "datarefs/floatdataref.h"
#include "datarefs/floatarraydataref.h"
Expand All @@ -23,7 +24,8 @@ TcpClient::TcpClient(QObject *parent,

QByteArray block;
QTextStream out(&block, QIODevice::WriteOnly);
out << "EXTPLANE 1\n";
out << "EXTPLANE " << EXTPLANE_PROTOCOL << "\n";
out << "EXTPLANE-VERSION " << EXTPLANE_VERSION << "\n";
out.flush();
_socket->write(block);
}
Expand Down
13 changes: 13 additions & 0 deletions extplane-server/tcpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
/**
* Creates the TCP socket and manages client connections
*/
// TCP port used to listen for connections
#define EXTPLANE_PORT 51000
// Network protocol, currently always 1
#define EXTPLANE_PROTOCOL 1
// Feature revision, every time we add a new feature or bug fix, this should be incremented so that clients can know how old the plugin is
#define EXTPLANE_VERSION 1000

#define EXTPLANE_STRINGIFY(s) __EXTPLANE_STRINGIFY(s)
#define __EXTPLANE_STRINGIFY(s) #s

#define EXTPLANE_PORT_STR EXTPLANE_STRINGIFY(EXTPLANE_PORT)
#define EXTPLANE_PROTOCOL_STR EXTPLANE_STRINGIFY(EXTPLANE_PROTOCOL)
#define EXTPLANE_VERSION_STR EXTPLANE_STRINGIFY(EXTPLANE_VERSION)


class TcpClient;
class DataRefProvider;
Expand Down

0 comments on commit bbe992b

Please sign in to comment.