string config = tokens[ configToken ];
file_name = config+".xml";
+ direction = tokens[2];
- if (tokens[2] != "in" && tokens[2] != "out") {
+ if (direction != "in" && direction != "out") {
SG_LOG(SG_GENERAL, SG_ALERT, "Unsuported protocol direction: "
- << tokens[2]);
+ << direction);
}
reinit();
case FG_DOUBLE:
val = _out_message[i].offset +
- _out_message[i].prop->getFloatValue() * _out_message[i].factor;
- snprintf(tmp, 255, _out_message[i].format.c_str(), (float)val);
+ _out_message[i].prop->getDoubleValue() * _out_message[i].factor;
+ snprintf(tmp, 255, _out_message[i].format.c_str(), (double)val);
break;
default: // SG_STRING
case FG_FIXED:
case FG_FLOAT:
- case FG_DOUBLE:
val = _in_message[i].offset + strtod(p1, 0) * _in_message[i].factor;
_in_message[i].prop->setFloatValue((float)val);
break;
+ case FG_DOUBLE:
+ val = _in_message[i].offset + strtod(p1, 0) * _in_message[i].factor;
+ _in_message[i].prop->setDoubleValue(val);
+ break;
+
default: // SG_STRING
_in_message[i].prop->setStringValue(p1);
}
}
}
} else {
- do {
- if (!binary_mode) {
- length = io->readline( buf, FG_MAX_MSG_SIZE );
- if ( length > 0 ) {
- parse_message();
- }
- } else {
- length = io->read( buf, binary_record_length );
- if ( length == binary_record_length ) {
- parse_message();
- } else if ( length > 0 ) {
- SG_LOG( SG_IO, SG_ALERT,
- "Generic protocol: Received binary "
- "record of unexpected size, expected: "
- << binary_record_length << " but received: "
- << length);
- }
+ if (!binary_mode) {
+ while ((length = io->readline( buf, FG_MAX_MSG_SIZE )) > 0 ) {
+ parse_message();
+ }
+ } else {
+ while ((length = io->read( buf, binary_record_length ))
+ == binary_record_length ) {
+ parse_message();
+ }
+
+ if ( length > 0 ) {
+ SG_LOG( SG_IO, SG_ALERT,
+ "Generic protocol: Received binary "
+ "record of unexpected size, expected: "
+ << binary_record_length << " but received: "
+ << length);
}
- } while ( length == binary_record_length );
+ }
}
}
return true;
return;
}
- SGPropertyNode *output = root.getNode("generic/output");
- if (output) {
- read_config(output, _out_message);
- }
-
- SGPropertyNode *input = root.getNode("generic/input");
- if (input) {
- read_config(input, _in_message);
+ if (direction == "out") {
+ SGPropertyNode *output = root.getNode("generic/output");
+ if (output) {
+ _out_message.clear();
+ read_config(output, _out_message);
+ }
+ } else if (direction == "in") {
+ SGPropertyNode *input = root.getNode("generic/input");
+ if (input) {
+ _in_message.clear();
+ read_config(input, _in_message);
+ }
}
}
}
- if (binary_record_length == -1) {
- binary_record_length = record_length;
- } else if (binary_record_length < record_length) {
- SG_LOG(SG_IO, SG_ALERT,
- "generic protocol: Requested binary record length shorter than "
- " requested record representation.");
- binary_record_length = record_length;
+ if( binary_mode ) {
+ if (binary_record_length == -1) {
+ binary_record_length = record_length;
+ } else if (binary_record_length < record_length) {
+ SG_LOG(SG_IO, SG_ALERT,
+ "generic protocol: Requested binary record length shorter than "
+ " requested record representation.");
+ binary_record_length = record_length;
+ }
}
}