1
0
Fork 0

Add bi-directional support to the generic protocol

Ticket-Id: https://sourceforge.net/p/flightgear/codetickets/1191/
This commit is contained in:
James Turner 2021-05-19 15:11:55 +01:00
parent d5789b5f74
commit d3956a4af7
2 changed files with 8 additions and 7 deletions

View file

@ -241,11 +241,10 @@ FGGeneric::FGGeneric(vector<string> tokens) : exitOnError(false), initOk(false),
string config = tokens[ configToken ]; string config = tokens[ configToken ];
file_name = config+".xml"; file_name = config+".xml";
direction = tokens[2]; set_direction(tokens[2]);
if (direction != "in" && direction != "out" && direction != "bi") { if (get_direction() == SG_IO_NONE) {
SG_LOG(SG_NETWORK, SG_ALERT, "Unsuported protocol direction: " SG_LOG(SG_NETWORK, SG_ALERT, "Unsuported protocol direction: " << tokens[2]);
<< direction);
return; return;
} }
@ -772,7 +771,8 @@ FGGeneric::reinit()
return; return;
} }
if (direction == "out") { const auto dir = get_direction();
if ((dir == SG_IO_OUT) || (dir == SG_IO_BI)) {
SGPropertyNode *output = root.getNode("generic/output"); SGPropertyNode *output = root.getNode("generic/output");
if (output) { if (output) {
_out_message.clear(); _out_message.clear();
@ -782,7 +782,9 @@ FGGeneric::reinit()
return; return;
} }
} }
} else if (direction == "in") { }
if ((dir == SG_IO_IN) || (dir == SG_IO_BI)) {
SGPropertyNode *input = root.getNode("generic/input"); SGPropertyNode *input = root.getNode("generic/input");
if (input) { if (input) {
_in_message.clear(); _in_message.clear();

View file

@ -76,7 +76,6 @@ protected:
private: private:
string file_name; string file_name;
string direction;
int length; int length;
char buf[ FG_MAX_MSG_SIZE ]; char buf[ FG_MAX_MSG_SIZE ];