summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreeHugger Robot2017-03-27 18:42:36 -0500
committerAndroid (Google) Code Review2017-03-27 18:42:36 -0500
commit2f592d271ed31bb7177556e413b32e4d1afb6dc6 (patch)
tree11b2d88bc2cbd127dcdc18f6e0ef53be94b1c2a0 /obd2-lib
parent5af2df953e06656bd74690dcc6738c09223e0c1b (diff)
parent3a3850c37c5548373650f4b78e916da86d1a5266 (diff)
downloadplatform-packages-services-car-2f592d271ed31bb7177556e413b32e4d1afb6dc6.tar.gz
platform-packages-services-car-2f592d271ed31bb7177556e413b32e4d1afb6dc6.tar.xz
platform-packages-services-car-2f592d271ed31bb7177556e413b32e4d1afb6dc6.zip
Merge "Rework the way diagnostic events are serialized to JSON, and deserialized:"
Diffstat (limited to 'obd2-lib')
-rw-r--r--obd2-lib/src/com/android/car/obd2/Obd2LiveFrameGenerator.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/obd2-lib/src/com/android/car/obd2/Obd2LiveFrameGenerator.java b/obd2-lib/src/com/android/car/obd2/Obd2LiveFrameGenerator.java
index 5fb45391..121b54aa 100644
--- a/obd2-lib/src/com/android/car/obd2/Obd2LiveFrameGenerator.java
+++ b/obd2-lib/src/com/android/car/obd2/Obd2LiveFrameGenerator.java
@@ -27,6 +27,7 @@ import java.util.Optional;
27import java.util.Set; 27import java.util.Set;
28 28
29public class Obd2LiveFrameGenerator { 29public class Obd2LiveFrameGenerator {
30 public static final int FRAME_TYPE_LIVE = 1;
30 public static final String TAG = Obd2LiveFrameGenerator.class.getSimpleName(); 31 public static final String TAG = Obd2LiveFrameGenerator.class.getSimpleName();
31 32
32 private final Obd2Connection mConnection; 33 private final Obd2Connection mConnection;
@@ -63,6 +64,7 @@ public class Obd2LiveFrameGenerator {
63 64
64 public JsonWriter generate(JsonWriter jsonWriter, long timestamp) throws IOException { 65 public JsonWriter generate(JsonWriter jsonWriter, long timestamp) throws IOException {
65 jsonWriter.beginObject(); 66 jsonWriter.beginObject();
67 jsonWriter.name("type").value(FRAME_TYPE_LIVE);
66 jsonWriter.name("timestamp").value(timestamp); 68 jsonWriter.name("timestamp").value(timestamp);
67 jsonWriter.name("intValues").beginArray(); 69 jsonWriter.name("intValues").beginArray();
68 for (LiveFrameCommand<Integer> command : mIntegerCommands) { 70 for (LiveFrameCommand<Integer> command : mIntegerCommands) {
@@ -75,8 +77,11 @@ public class Obd2LiveFrameGenerator {
75 jsonWriter.endObject(); 77 jsonWriter.endObject();
76 } 78 }
77 } catch (IOException | InterruptedException e) { 79 } catch (IOException | InterruptedException e) {
78 Log.w(TAG, String.format("unable to retrieve OBD2 pid %d due to exception: %s", 80 Log.w(
79 command.getPid(), e)); 81 TAG,
82 String.format(
83 "unable to retrieve OBD2 pid %d due to exception: %s",
84 command.getPid(), e));
80 // skip this entry 85 // skip this entry
81 } 86 }
82 } 87 }
@@ -93,8 +98,11 @@ public class Obd2LiveFrameGenerator {
93 jsonWriter.endObject(); 98 jsonWriter.endObject();
94 } 99 }
95 } catch (IOException | InterruptedException e) { 100 } catch (IOException | InterruptedException e) {
96 Log.w(TAG, String.format("unable to retrieve OBD2 pid %d due to exception: %s", 101 Log.w(
97 command.getPid(), e)); 102 TAG,
103 String.format(
104 "unable to retrieve OBD2 pid %d due to exception: %s",
105 command.getPid(), e));
98 // skip this entry 106 // skip this entry
99 } 107 }
100 } 108 }