If more than one packet has arrived in the mean time, process them all.
This commit is contained in:
parent
6c65a26ddf
commit
0dfd7b8024
1 changed files with 28 additions and 19 deletions
|
@ -446,33 +446,42 @@ bool FGGeneric::process() {
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
} else if ( get_direction() == SG_IO_IN ) {
|
} else if ( get_direction() == SG_IO_IN ) {
|
||||||
|
if ( io->get_type() == sgFileType ) {
|
||||||
if (!binary_mode) {
|
if (!binary_mode) {
|
||||||
if ( (length = io->readline( buf, FG_MAX_MSG_SIZE )) > 0 ) {
|
length = io->readline( buf, FG_MAX_MSG_SIZE );
|
||||||
|
if ( length > 0 ) {
|
||||||
parse_message();
|
parse_message();
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_IO, SG_ALERT, "Error reading data." );
|
SG_LOG( SG_IO, SG_ALERT, "Error reading data." );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( (length = io->read( buf, binary_record_length )) > 0 ) {
|
length = io->read( buf, binary_record_length );
|
||||||
if (length != binary_record_length) {
|
if ( length == binary_record_length ) {
|
||||||
|
parse_message();
|
||||||
|
} else {
|
||||||
SG_LOG( SG_IO, SG_ALERT,
|
SG_LOG( SG_IO, SG_ALERT,
|
||||||
"Generic protocol: Received binary "
|
"Generic protocol: Received binary "
|
||||||
"record of unexpected size, expected: "
|
"record of unexpected size, expected: "
|
||||||
<< binary_record_length << "received: "
|
<< binary_record_length << " but received: "
|
||||||
<< length);
|
<< length);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_IO, SG_DEBUG,
|
do {
|
||||||
"Generic protocol: received record of " << length <<
|
if (!binary_mode) {
|
||||||
" bytes.");
|
length = io->readline( buf, FG_MAX_MSG_SIZE );
|
||||||
|
if ( length > 0 ) {
|
||||||
parse_message();
|
parse_message();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_IO, SG_INFO,
|
length = io->read( buf, binary_record_length );
|
||||||
"Generic protocol: Error reading data." );
|
if ( length == binary_record_length ) {
|
||||||
return false;
|
parse_message();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} while ( length == binary_record_length );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
error_out:
|
error_out:
|
||||||
|
|
Loading…
Reference in a new issue