Switch raw data field to uint64 to fit all values and update benchmark.
authorChristopher Peplin <chris.peplin@rhubarbtech.com>
Sat, 5 Oct 2013 20:25:51 +0000 (16:25 -0400)
committerChristopher Peplin <chris.peplin@rhubarbtech.com>
Tue, 7 Jan 2014 18:18:10 +0000 (13:18 -0500)
benchmark/proto/compare_sizes.py
gen/cpp/openxc.pb
gen/cpp/openxc.pb.c
gen/cpp/openxc.pb.h
gen/java/openxc/Openxc.java
gen/python/openxc_pb2.py
openxc.proto

index f31a2e4..e4ae669 100755 (executable)
@@ -35,11 +35,9 @@ for trace_file in sys.argv[1:]:
             # but most of ours are full 64+11 bits
             total_raw_can_size += 10
             total_raw_json_size += len(json.dumps(json_message))
-            binary_message = openxc_pb2.RawMessage()
-            binary_message.message_id = json_message['id']
-            binary_message.data = int(json_message['data'], 0)
             message.type = openxc_pb2.VehicleMessage.RAW
-            message.raw_message = binary_message
+            message.raw_message.message_id = json_message['id']
+            message.raw_message.data = int(json_message['data'], 0)
             total_raw_binary_size += len(message.SerializeToString())
         else:
             message.type = openxc_pb2.VehicleMessage.TRANSLATED
index 523fc76..27548ab 100644 (file)
@@ -14,7 +14,7 @@ RawMessage\12
 \ 3bus\18\ 1 \ 1(\ 5\12\12
 
 message_id\18\ 2 \ 1(\r\12\f
-\ 4data\18\ 3 \ 1(\12\ 1
+\ 4data\18\ 3 \ 1(\ 4\ 1
 \11TranslatedMessage\12\f
 \ 4name\18\ 1 \ 1(     \12\14
 \fstring_value\18\ 2 \ 1(     \12\17
index a49e1c0..5fb7d1c 100644 (file)
@@ -1,5 +1,5 @@
 /* Automatically generated nanopb constant definitions */
-/* Generated by nanopb-0.2.4-dev at Fri Oct  4 19:24:10 2013. */
+/* Generated by nanopb-0.2.4-dev at Sat Oct  5 16:25:23 2013. */
 
 #include "openxc.pb.h"
 
@@ -15,7 +15,7 @@ const pb_field_t openxc_VehicleMessage_fields[4] = {
 const pb_field_t openxc_RawMessage_fields[4] = {
     PB_FIELD2(  1, INT32   , OPTIONAL, STATIC, FIRST, openxc_RawMessage, bus, bus, 0),
     PB_FIELD2(  2, UINT32  , OPTIONAL, STATIC, OTHER, openxc_RawMessage, message_id, bus, 0),
-    PB_FIELD2(  3, SINT64  , OPTIONAL, STATIC, OTHER, openxc_RawMessage, data, message_id, 0),
+    PB_FIELD2(  3, UINT64  , OPTIONAL, STATIC, OTHER, openxc_RawMessage, data, message_id, 0),
     PB_LAST_FIELD
 };
 
index 8528e65..f4ec09c 100644 (file)
@@ -1,5 +1,5 @@
 /* Automatically generated nanopb header */
-/* Generated by nanopb-0.2.4-dev at Fri Oct  4 19:24:10 2013. */
+/* Generated by nanopb-0.2.4-dev at Sat Oct  5 16:25:23 2013. */
 
 #ifndef _PB_OPENXC_PB_H_
 #define _PB_OPENXC_PB_H_
@@ -22,7 +22,7 @@ typedef struct _openxc_RawMessage {
     bool has_message_id;
     uint32_t message_id;
     bool has_data;
-    int64_t data;
+    uint64_t data;
 } openxc_RawMessage;
 
 typedef struct _openxc_TranslatedMessage {
index 93a4d05..3e1ceba 100644 (file)
@@ -902,13 +902,13 @@ public final class Openxc {
      */
     int getMessageId();
 
-    // optional sint64 data = 3;
+    // optional uint64 data = 3;
     /**
-     * <code>optional sint64 data = 3;</code>
+     * <code>optional uint64 data = 3;</code>
      */
     boolean hasData();
     /**
-     * <code>optional sint64 data = 3;</code>
+     * <code>optional uint64 data = 3;</code>
      */
     long getData();
   }
@@ -975,7 +975,7 @@ public final class Openxc {
             }
             case 24: {
               bitField0_ |= 0x00000004;
-              data_ = input.readSInt64();
+              data_ = input.readUInt64();
               break;
             }
           }
@@ -1050,17 +1050,17 @@ public final class Openxc {
       return messageId_;
     }
 
-    // optional sint64 data = 3;
+    // optional uint64 data = 3;
     public static final int DATA_FIELD_NUMBER = 3;
     private long data_;
     /**
-     * <code>optional sint64 data = 3;</code>
+     * <code>optional uint64 data = 3;</code>
      */
     public boolean hasData() {
       return ((bitField0_ & 0x00000004) == 0x00000004);
     }
     /**
-     * <code>optional sint64 data = 3;</code>
+     * <code>optional uint64 data = 3;</code>
      */
     public long getData() {
       return data_;
@@ -1090,7 +1090,7 @@ public final class Openxc {
         output.writeUInt32(2, messageId_);
       }
       if (((bitField0_ & 0x00000004) == 0x00000004)) {
-        output.writeSInt64(3, data_);
+        output.writeUInt64(3, data_);
       }
       getUnknownFields().writeTo(output);
     }
@@ -1111,7 +1111,7 @@ public final class Openxc {
       }
       if (((bitField0_ & 0x00000004) == 0x00000004)) {
         size += com.google.protobuf.CodedOutputStream
-          .computeSInt64Size(3, data_);
+          .computeUInt64Size(3, data_);
       }
       size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
@@ -1393,22 +1393,22 @@ public final class Openxc {
         return this;
       }
 
-      // optional sint64 data = 3;
+      // optional uint64 data = 3;
       private long data_ ;
       /**
-       * <code>optional sint64 data = 3;</code>
+       * <code>optional uint64 data = 3;</code>
        */
       public boolean hasData() {
         return ((bitField0_ & 0x00000004) == 0x00000004);
       }
       /**
-       * <code>optional sint64 data = 3;</code>
+       * <code>optional uint64 data = 3;</code>
        */
       public long getData() {
         return data_;
       }
       /**
-       * <code>optional sint64 data = 3;</code>
+       * <code>optional uint64 data = 3;</code>
        */
       public Builder setData(long value) {
         bitField0_ |= 0x00000004;
@@ -1417,7 +1417,7 @@ public final class Openxc {
         return this;
       }
       /**
-       * <code>optional sint64 data = 3;</code>
+       * <code>optional uint64 data = 3;</code>
        */
       public Builder clearData() {
         bitField0_ = (bitField0_ & ~0x00000004);
@@ -2574,7 +2574,7 @@ public final class Openxc {
       "ssage\0225\n\022translated_message\030\003 \001(\0132\031.open" +
       "xc.TranslatedMessage\"\037\n\004Type\022\007\n\003RAW\020\001\022\016\n" +
       "\nTRANSLATED\020\002\";\n\nRawMessage\022\013\n\003bus\030\001 \001(\005" +
-      "\022\022\n\nmessage_id\030\002 \001(\r\022\014\n\004data\030\003 \001(\022\"\255\001\n\021T" +
+      "\022\022\n\nmessage_id\030\002 \001(\r\022\014\n\004data\030\003 \001(\004\"\255\001\n\021T" +
       "ranslatedMessage\022\014\n\004name\030\001 \001(\t\022\024\n\014string" +
       "_value\030\002 \001(\t\022\027\n\017numerical_value\030\003 \001(\001\022\025\n" +
       "\rboolean_value\030\004 \001(\010\022\024\n\014string_event\030\005 \001",
index e4c48fb..63edf33 100644 (file)
@@ -13,7 +13,7 @@ from google.protobuf import descriptor_pb2
 DESCRIPTOR = _descriptor.FileDescriptor(
   name='openxc.proto',
   package='openxc',
-  serialized_pb='\n\x0copenxc.proto\x12\x06openxc\"\xbc\x01\n\x0eVehicleMessage\x12)\n\x04type\x18\x01 \x01(\x0e\x32\x1b.openxc.VehicleMessage.Type\x12\'\n\x0braw_message\x18\x02 \x01(\x0b\x32\x12.openxc.RawMessage\x12\x35\n\x12translated_message\x18\x03 \x01(\x0b\x32\x19.openxc.TranslatedMessage\"\x1f\n\x04Type\x12\x07\n\x03RAW\x10\x01\x12\x0e\n\nTRANSLATED\x10\x02\";\n\nRawMessage\x12\x0b\n\x03\x62us\x18\x01 \x01(\x05\x12\x12\n\nmessage_id\x18\x02 \x01(\r\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x12\"\xad\x01\n\x11TranslatedMessage\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0cstring_value\x18\x02 \x01(\t\x12\x17\n\x0fnumerical_value\x18\x03 \x01(\x01\x12\x15\n\rboolean_value\x18\x04 \x01(\x08\x12\x14\n\x0cstring_event\x18\x05 \x01(\t\x12\x17\n\x0fnumerical_event\x18\x06 \x01(\x01\x12\x15\n\rboolean_event\x18\x07 \x01(\x08')
+  serialized_pb='\n\x0copenxc.proto\x12\x06openxc\"\xbc\x01\n\x0eVehicleMessage\x12)\n\x04type\x18\x01 \x01(\x0e\x32\x1b.openxc.VehicleMessage.Type\x12\'\n\x0braw_message\x18\x02 \x01(\x0b\x32\x12.openxc.RawMessage\x12\x35\n\x12translated_message\x18\x03 \x01(\x0b\x32\x19.openxc.TranslatedMessage\"\x1f\n\x04Type\x12\x07\n\x03RAW\x10\x01\x12\x0e\n\nTRANSLATED\x10\x02\";\n\nRawMessage\x12\x0b\n\x03\x62us\x18\x01 \x01(\x05\x12\x12\n\nmessage_id\x18\x02 \x01(\r\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x04\"\xad\x01\n\x11TranslatedMessage\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0cstring_value\x18\x02 \x01(\t\x12\x17\n\x0fnumerical_value\x18\x03 \x01(\x01\x12\x15\n\rboolean_value\x18\x04 \x01(\x08\x12\x14\n\x0cstring_event\x18\x05 \x01(\t\x12\x17\n\x0fnumerical_event\x18\x06 \x01(\x01\x12\x15\n\rboolean_event\x18\x07 \x01(\x08')
 
 
 
@@ -105,7 +105,7 @@ _RAWMESSAGE = _descriptor.Descriptor(
       options=None),
     _descriptor.FieldDescriptor(
       name='data', full_name='openxc.RawMessage.data', index=2,
-      number=3, type=18, cpp_type=2, label=1,
+      number=3, type=4, cpp_type=4, label=1,
       has_default_value=False, default_value=0,
       message_type=None, enum_type=None, containing_type=None,
       is_extension=False, extension_scope=None,
index 0748e75..b3dd3ba 100644 (file)
@@ -12,7 +12,7 @@ message VehicleMessage {
 message RawMessage {
     optional int32 bus = 1;
     optional uint32 message_id = 2;
-    optional sint64 data = 3;
+    optional uint64 data = 3;
 }
 
 message TranslatedMessage {