summaryrefslogtreecommitdiffstats
path: root/openxc.proto
blob: 5b7e78b479b5a40b6c0fb9640af092ee9c7963d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package openxc;

option java_package = "com.openxc";
option java_outer_classname = "BinaryMessages";

message VehicleMessage {
    enum Type { RAW = 1; TRANSLATED = 2; DIAGNOSTIC = 3; CONTROL_COMMAND = 4;
            COMMAND_RESPONSE = 5; }

    optional Type type = 1;
    optional RawMessage raw_message = 2;
    optional TranslatedMessage translated_message = 3;
    optional DiagnosticResponse diagnostic_response = 4;
    optional ControlCommand control_command = 5;
    optional CommandResponse command_response = 6;
}

message RawMessage {
    optional int32 bus = 1;
    optional uint32 message_id = 2;
    optional bytes data = 3;
}

message ControlCommand {
    enum Type { VERSION = 1; DEVICE_ID = 2; DIAGNOSTIC = 3; }

    optional Type type = 1;
    optional DiagnosticRequest diagnostic_request = 2;
}

message CommandResponse {
    optional ControlCommand.Type type = 1;
    optional string message = 2;
}

message DiagnosticRequest {
    enum DecodedType { NONE = 1; OBD2 = 2; }

    optional int32 bus = 1;
    optional uint32 message_id = 2;
    optional uint32 mode = 3;
    optional uint32 pid = 4;
    // TODO we are capping this at 8 bytes for now - need to change when we
    // support multi-frame responses
    optional bytes payload = 5;
    optional bool multiple_responses = 6;
    optional double frequency = 7;
    optional string name = 8;
    optional DecodedType decoded_type = 9;
}

message DiagnosticResponse {
    optional int32 bus = 1;
    optional uint32 message_id = 2;
    optional uint32 mode = 3;
    optional uint32 pid = 4;
    optional bool success = 5;
    optional uint32 negative_response_code = 6;
    // TODO we are capping this at 8 bytes for now - need to change when we
    // support multi-frame responses
    optional bytes payload = 7;
    optional double value = 8;
}

message DynamicField {
    enum Type { STRING = 1; NUM = 2; BOOL = 3; }

    optional Type type = 1;
    optional string string_value = 2;
    optional double numeric_value = 3;
    optional bool boolean_value = 4;
}

message TranslatedMessage {
    enum Type { STRING = 1; NUM = 2; BOOL = 3;
        EVENTED_STRING = 4; EVENTED_NUM = 5; EVENTED_BOOL = 6;}

    optional Type type = 1;
    optional string name = 2;
    optional DynamicField value = 3;
    optional DynamicField event = 4;
}

// TODO we should also consider having an enum type, having each specific
// message defined as a protobuf