Store diagnostic response payload as a byte array in protobuf.
authorChristopher Peplin <chris.peplin@rhubarbtech.com>
Fri, 17 Jan 2014 19:31:39 +0000 (14:31 -0500)
committerChristopher Peplin <chris.peplin@rhubarbtech.com>
Fri, 17 Jan 2014 19:31:39 +0000 (14:31 -0500)
gen/cpp/openxc.pb
gen/cpp/openxc.pb.c
gen/cpp/openxc.pb.h
gen/java/com/openxc/BinaryMessages.java
gen/python/openxc_pb2.py
openxc.options
openxc.proto

index 2267f21..82bfdd4 100644 (file)
@@ -23,7 +23,7 @@ message_id\18\ 2 \ 1(\r\12
 \ 3pid\18\ 4 \ 1(\r\12\ f
 \asuccess\18\ 5 \ 1(\b\12\1e
 \16negative_response_code\18\ 6 \ 1(\r\12\ f
-\apayload\18\a \ 1(\ 4\ 2
+\apayload\18\a \ 1(\f\ 2
 \11TranslatedMessage\12,
 \ 4type\18\ 1 \ 1(\ e2\1e.openxc.TranslatedMessage.Type\12\f
 \ 4name\18\ 2 \ 1(     \12\14
index da61655..7e2d390 100644 (file)
@@ -1,5 +1,5 @@
 /* Automatically generated nanopb constant definitions */
-/* Generated by nanopb-0.2.5 at Fri Jan 17 14:12:22 2014. */
+/* Generated by nanopb-0.2.5 at Fri Jan 17 14:31:26 2014. */
 
 #include "openxc.pb.h"
 
@@ -26,7 +26,7 @@ const pb_field_t openxc_DiagnosticMessage_fields[8] = {
     PB_FIELD2(  4, UINT32  , OPTIONAL, STATIC  , OTHER, openxc_DiagnosticMessage, pid, mode, 0),
     PB_FIELD2(  5, BOOL    , OPTIONAL, STATIC  , OTHER, openxc_DiagnosticMessage, success, pid, 0),
     PB_FIELD2(  6, UINT32  , OPTIONAL, STATIC  , OTHER, openxc_DiagnosticMessage, negative_response_code, success, 0),
-    PB_FIELD2(  7, UINT64  , OPTIONAL, STATIC  , OTHER, openxc_DiagnosticMessage, payload, negative_response_code, 0),
+    PB_FIELD2(  7, BYTES   , OPTIONAL, STATIC  , OTHER, openxc_DiagnosticMessage, payload, negative_response_code, 0),
     PB_LAST_FIELD
 };
 
index e4619ce..f5f117e 100644 (file)
@@ -1,5 +1,5 @@
 /* Automatically generated nanopb header */
-/* Generated by nanopb-0.2.5 at Fri Jan 17 14:12:22 2014. */
+/* Generated by nanopb-0.2.5 at Fri Jan 17 14:31:26 2014. */
 
 #ifndef _PB_OPENXC_PB_H_
 #define _PB_OPENXC_PB_H_
@@ -25,6 +25,11 @@ typedef enum _openxc_TranslatedMessage_Type {
 } openxc_TranslatedMessage_Type;
 
 /* Struct definitions */
+typedef struct {
+    size_t size;
+    uint8_t bytes[8];
+} openxc_DiagnosticMessage_payload_t;
+
 typedef struct _openxc_DiagnosticMessage {
     bool has_bus;
     int32_t bus;
@@ -39,7 +44,7 @@ typedef struct _openxc_DiagnosticMessage {
     bool has_negative_response_code;
     uint32_t negative_response_code;
     bool has_payload;
-    uint64_t payload;
+    openxc_DiagnosticMessage_payload_t payload;
 } openxc_DiagnosticMessage;
 
 typedef struct _openxc_RawMessage {
@@ -113,7 +118,7 @@ extern const pb_field_t openxc_TranslatedMessage_fields[9];
 /* Maximum encoded size of messages (where known) */
 #define openxc_VehicleMessage_size               373
 #define openxc_RawMessage_size                   28
-#define openxc_DiagnosticMessage_size            48
+#define openxc_DiagnosticMessage_size            47
 #define openxc_TranslatedMessage_size            334
 
 #ifdef __cplusplus
index a22dfe1..749ed5a 100644 (file)
@@ -1500,15 +1500,25 @@ public final class BinaryMessages {
      */
     int getNegativeResponseCode();
 
-    // optional uint64 payload = 7;
+    // optional bytes payload = 7;
     /**
-     * <code>optional uint64 payload = 7;</code>
+     * <code>optional bytes payload = 7;</code>
+     *
+     * <pre>
+     * TODO we are capping this at 8 bytes for now - need to change when we
+     * support multi-frame responses
+     * </pre>
      */
     boolean hasPayload();
     /**
-     * <code>optional uint64 payload = 7;</code>
+     * <code>optional bytes payload = 7;</code>
+     *
+     * <pre>
+     * TODO we are capping this at 8 bytes for now - need to change when we
+     * support multi-frame responses
+     * </pre>
      */
-    long getPayload();
+    com.google.protobuf.ByteString getPayload();
   }
   /**
    * Protobuf type {@code openxc.DiagnosticMessage}
@@ -1591,9 +1601,9 @@ public final class BinaryMessages {
               negativeResponseCode_ = input.readUInt32();
               break;
             }
-            case 56: {
+            case 58: {
               bitField0_ |= 0x00000040;
-              payload_ = input.readUInt64();
+              payload_ = input.readBytes();
               break;
             }
           }
@@ -1732,19 +1742,29 @@ public final class BinaryMessages {
       return negativeResponseCode_;
     }
 
-    // optional uint64 payload = 7;
+    // optional bytes payload = 7;
     public static final int PAYLOAD_FIELD_NUMBER = 7;
-    private long payload_;
+    private com.google.protobuf.ByteString payload_;
     /**
-     * <code>optional uint64 payload = 7;</code>
+     * <code>optional bytes payload = 7;</code>
+     *
+     * <pre>
+     * TODO we are capping this at 8 bytes for now - need to change when we
+     * support multi-frame responses
+     * </pre>
      */
     public boolean hasPayload() {
       return ((bitField0_ & 0x00000040) == 0x00000040);
     }
     /**
-     * <code>optional uint64 payload = 7;</code>
+     * <code>optional bytes payload = 7;</code>
+     *
+     * <pre>
+     * TODO we are capping this at 8 bytes for now - need to change when we
+     * support multi-frame responses
+     * </pre>
      */
-    public long getPayload() {
+    public com.google.protobuf.ByteString getPayload() {
       return payload_;
     }
 
@@ -1755,7 +1775,7 @@ public final class BinaryMessages {
       pid_ = 0;
       success_ = false;
       negativeResponseCode_ = 0;
-      payload_ = 0L;
+      payload_ = com.google.protobuf.ByteString.EMPTY;
     }
     private byte memoizedIsInitialized = -1;
     public final boolean isInitialized() {
@@ -1788,7 +1808,7 @@ public final class BinaryMessages {
         output.writeUInt32(6, negativeResponseCode_);
       }
       if (((bitField0_ & 0x00000040) == 0x00000040)) {
-        output.writeUInt64(7, payload_);
+        output.writeBytes(7, payload_);
       }
       getUnknownFields().writeTo(output);
     }
@@ -1825,7 +1845,7 @@ public final class BinaryMessages {
       }
       if (((bitField0_ & 0x00000040) == 0x00000040)) {
         size += com.google.protobuf.CodedOutputStream
-          .computeUInt64Size(7, payload_);
+          .computeBytesSize(7, payload_);
       }
       size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
@@ -1955,7 +1975,7 @@ public final class BinaryMessages {
         bitField0_ = (bitField0_ & ~0x00000010);
         negativeResponseCode_ = 0;
         bitField0_ = (bitField0_ & ~0x00000020);
-        payload_ = 0L;
+        payload_ = com.google.protobuf.ByteString.EMPTY;
         bitField0_ = (bitField0_ & ~0x00000040);
         return this;
       }
@@ -2275,35 +2295,58 @@ public final class BinaryMessages {
         return this;
       }
 
-      // optional uint64 payload = 7;
-      private long payload_ ;
+      // optional bytes payload = 7;
+      private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY;
       /**
-       * <code>optional uint64 payload = 7;</code>
+       * <code>optional bytes payload = 7;</code>
+       *
+       * <pre>
+       * TODO we are capping this at 8 bytes for now - need to change when we
+       * support multi-frame responses
+       * </pre>
        */
       public boolean hasPayload() {
         return ((bitField0_ & 0x00000040) == 0x00000040);
       }
       /**
-       * <code>optional uint64 payload = 7;</code>
+       * <code>optional bytes payload = 7;</code>
+       *
+       * <pre>
+       * TODO we are capping this at 8 bytes for now - need to change when we
+       * support multi-frame responses
+       * </pre>
        */
-      public long getPayload() {
+      public com.google.protobuf.ByteString getPayload() {
         return payload_;
       }
       /**
-       * <code>optional uint64 payload = 7;</code>
+       * <code>optional bytes payload = 7;</code>
+       *
+       * <pre>
+       * TODO we are capping this at 8 bytes for now - need to change when we
+       * support multi-frame responses
+       * </pre>
        */
-      public Builder setPayload(long value) {
-        bitField0_ |= 0x00000040;
+      public Builder setPayload(com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000040;
         payload_ = value;
         onChanged();
         return this;
       }
       /**
-       * <code>optional uint64 payload = 7;</code>
+       * <code>optional bytes payload = 7;</code>
+       *
+       * <pre>
+       * TODO we are capping this at 8 bytes for now - need to change when we
+       * support multi-frame responses
+       * </pre>
        */
       public Builder clearPayload() {
         bitField0_ = (bitField0_ & ~0x00000040);
-        payload_ = 0L;
+        payload_ = getDefaultInstance().getPayload();
         onChanged();
         return this;
       }
@@ -3673,7 +3716,7 @@ public final class BinaryMessages {
       "iagnosticMessage\022\013\n\003bus\030\001 \001(\005\022\022\n\nmessage" +
       "_id\030\002 \001(\r\022\014\n\004mode\030\003 \001(\r\022\013\n\003pid\030\004 \001(\r\022\017\n\007" +
       "success\030\005 \001(\010\022\036\n\026negative_response_code\030",
-      "\006 \001(\r\022\017\n\007payload\030\007 \001(\004\"\265\002\n\021TranslatedMes" +
+      "\006 \001(\r\022\017\n\007payload\030\007 \001(\014\"\265\002\n\021TranslatedMes" +
       "sage\022,\n\004type\030\001 \001(\0162\036.openxc.TranslatedMe" +
       "ssage.Type\022\014\n\004name\030\002 \001(\t\022\024\n\014string_value" +
       "\030\003 \001(\t\022\025\n\rnumeric_value\030\004 \001(\001\022\025\n\rboolean" +
index 59791cf..6291891 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(\x04\"\x91\x01\n\x11\x44iagnosticMessage\x12\x0b\n\x03\x62us\x18\x01 \x01(\x05\x12\x12\n\nmessage_id\x18\x02 \x01(\r\x12\x0c\n\x04mode\x18\x03 \x01(\r\x12\x0b\n\x03pid\x18\x04 \x01(\r\x12\x0f\n\x07success\x18\x05 \x01(\x08\x12\x1e\n\x16negative_response_code\x18\x06 \x01(\r\x12\x0f\n\x07payload\x18\x07 \x01(\x04\"\xb5\x02\n\x11TranslatedMessage\x12,\n\x04type\x18\x01 \x01(\x0e\x32\x1e.openxc.TranslatedMessage.Type\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x14\n\x0cstring_value\x18\x03 \x01(\t\x12\x15\n\rnumeric_value\x18\x04 \x01(\x01\x12\x15\n\rboolean_value\x18\x05 \x01(\x08\x12\x14\n\x0cstring_event\x18\x06 \x01(\t\x12\x15\n\rnumeric_event\x18\x07 \x01(\x01\x12\x15\n\rboolean_event\x18\x08 \x01(\x08\"\\\n\x04Type\x12\n\n\x06STRING\x10\x01\x12\x07\n\x03NUM\x10\x02\x12\x08\n\x04\x42OOL\x10\x03\x12\x12\n\x0e\x45VENTED_STRING\x10\x04\x12\x0f\n\x0b\x45VENTED_NUM\x10\x05\x12\x10\n\x0c\x45VENTED_BOOL\x10\x06\x42\x1c\n\ncom.openxcB\x0e\x42inaryMessages')
+  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\"\x91\x01\n\x11\x44iagnosticMessage\x12\x0b\n\x03\x62us\x18\x01 \x01(\x05\x12\x12\n\nmessage_id\x18\x02 \x01(\r\x12\x0c\n\x04mode\x18\x03 \x01(\r\x12\x0b\n\x03pid\x18\x04 \x01(\r\x12\x0f\n\x07success\x18\x05 \x01(\x08\x12\x1e\n\x16negative_response_code\x18\x06 \x01(\r\x12\x0f\n\x07payload\x18\x07 \x01(\x0c\"\xb5\x02\n\x11TranslatedMessage\x12,\n\x04type\x18\x01 \x01(\x0e\x32\x1e.openxc.TranslatedMessage.Type\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x14\n\x0cstring_value\x18\x03 \x01(\t\x12\x15\n\rnumeric_value\x18\x04 \x01(\x01\x12\x15\n\rboolean_value\x18\x05 \x01(\x08\x12\x14\n\x0cstring_event\x18\x06 \x01(\t\x12\x15\n\rnumeric_event\x18\x07 \x01(\x01\x12\x15\n\rboolean_event\x18\x08 \x01(\x08\"\\\n\x04Type\x12\n\n\x06STRING\x10\x01\x12\x07\n\x03NUM\x10\x02\x12\x08\n\x04\x42OOL\x10\x03\x12\x12\n\x0e\x45VENTED_STRING\x10\x04\x12\x0f\n\x0b\x45VENTED_NUM\x10\x05\x12\x10\n\x0c\x45VENTED_BOOL\x10\x06\x42\x1c\n\ncom.openxcB\x0e\x42inaryMessages')
 
 
 
@@ -212,8 +212,8 @@ _DIAGNOSTICMESSAGE = _descriptor.Descriptor(
       options=None),
     _descriptor.FieldDescriptor(
       name='payload', full_name='openxc.DiagnosticMessage.payload', index=6,
-      number=7, type=4, cpp_type=4, label=1,
-      has_default_value=False, default_value=0,
+      number=7, type=12, cpp_type=9, label=1,
+      has_default_value=False, default_value="",
       message_type=None, enum_type=None, containing_type=None,
       is_extension=False, extension_scope=None,
       options=None),
index 40ebed9..75caaba 100644 (file)
@@ -1,3 +1,4 @@
 openxc.TranslatedMessage.name max_size:100
 openxc.TranslatedMessage.string_value max_size:100
 openxc.TranslatedMessage.string_event max_size:100
+openxc.DiagnosticMessage.payload max_size:8
index 72cd33f..1b43853 100644 (file)
@@ -24,7 +24,9 @@ message DiagnosticMessage {
     optional uint32 pid = 4;
     optional bool success = 5;
     optional uint32 negative_response_code = 6;
-    optional uint64 payload = 7;
+    // TODO we are capping this at 8 bytes for now - need to change when we
+    // support multi-frame responses
+    optional bytes payload = 7;
 }
 
 message TranslatedMessage {