X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2Fgeneric.cxx;h=423d2be189b28ffec2de641415dc99ab3b1bdcfb;hb=4be1661305609819703015360b79bbb7e4ae87d6;hp=b1e0c204832f2bfa71df9a4e48b74bc4417491d3;hpb=a6db6d89ff41a619569e6433409e8bf62ff98499;p=flightgear.git diff --git a/src/Network/generic.cxx b/src/Network/generic.cxx index b1e0c2048..423d2be18 100644 --- a/src/Network/generic.cxx +++ b/src/Network/generic.cxx @@ -240,8 +240,8 @@ bool FGGeneric::gen_message_ascii() { 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 @@ -378,11 +378,15 @@ bool FGGeneric::parse_message_ascii() { 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); } @@ -463,25 +467,24 @@ bool FGGeneric::process() { } } } 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(); } - } while ( length == binary_record_length ); + + if ( length > 0 ) { + SG_LOG( SG_IO, SG_ALERT, + "Generic protocol: Received binary " + "record of unexpected size, expected: " + << binary_record_length << " but received: " + << length); + } + } } } return true; @@ -688,12 +691,14 @@ FGGeneric::read_config(SGPropertyNode *root, vector<_serial_prot> &msg) } - 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; + } } }