+bool FGGeneric::gen_message() {
+ if (binary_mode) {
+ return gen_message_binary();
+ } else {
+ return gen_message_ascii();
+ }
+}
+
+bool FGGeneric::parse_message_binary() {
+ char *p2, *p1 = buf;
+ int32_t tmp32;
+ double val;
+ int i = -1;
+
+ p2 = p1 + FG_MAX_MSG_SIZE;
+ while ((++i < (int)_in_message.size()) && (p1 < p2)) {
+
+ switch (_in_message[i].type) {
+ case FG_INT:
+ if (binary_byte_order == BYTE_ORDER_NEEDS_CONVERSION) {
+ tmp32 = sg_bswap_32(*(int32_t *)p1);
+ } else {
+ tmp32 = *(int32_t *)p1;
+ }
+
+ val = _in_message[i].offset + (double)tmp32 * _in_message[i].factor;
+
+ _in_message[i].prop->setIntValue((int)val);
+ p1 += sizeof(int32_t);
+ break;
+
+ case FG_BOOL:
+ _in_message[i].prop->setBoolValue( p1[0] != 0 );
+ p1 += 1;
+ break;
+
+ case FG_FIXED:
+ if (binary_byte_order == BYTE_ORDER_NEEDS_CONVERSION) {
+ tmp32 = sg_bswap_32(*(int32_t *)p1);
+ } else {
+ tmp32 = *(int32_t *)p1;
+ }
+
+ val = _in_message[i].offset +
+ ((double)tmp32 / 65536.0f) * _in_message[i].factor;
+
+ _in_message[i].prop->setFloatValue(val);
+ p1 += sizeof(int32_t);
+ break;
+
+ case FG_FLOAT:
+ u32 tmpun32;
+ if (binary_byte_order == BYTE_ORDER_NEEDS_CONVERSION) {
+ tmpun32.intVal = sg_bswap_32(*(uint32_t *)p1);
+ } else {
+ tmpun32.floatVal = *(float *)p1;
+ }
+
+ val = _in_message[i].offset +
+ tmpun32.floatVal * _in_message[i].factor;
+
+ _in_message[i].prop->setFloatValue(val);
+ p1 += sizeof(int32_t);
+ break;
+
+ case FG_DOUBLE:
+ u64 tmpun64;
+ if (binary_byte_order == BYTE_ORDER_NEEDS_CONVERSION) {
+ tmpun64.longVal = sg_bswap_64(*(uint64_t *)p1);
+ } else {
+ tmpun64.doubleVal = *(double *)p1;
+ }
+
+ val = _in_message[i].offset +
+ tmpun64.doubleVal * _in_message[i].factor;
+
+ _in_message[i].prop->setDoubleValue(val);
+ p1 += sizeof(int64_t);
+ break;
+
+ default: // SG_STRING
+ SG_LOG( SG_IO, SG_ALERT, "Generic protocol: "
+ "Ignoring unsupported binary input chunk type.");
+ }
+ }
+
+ return true;
+}
+
+bool FGGeneric::parse_message_ascii() {