forked from jamesryancoleman/grpc-modbus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevice.proto
More file actions
135 lines (110 loc) · 2.95 KB
/
Copy pathdevice.proto
File metadata and controls
135 lines (110 loc) · 2.95 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
syntax = "proto3";
package devctl;
option go_package = "github.com/jamesryancoleman/bos/services/device";
// import "google/protobuf/empty.proto";
message Header {
string Src = 1;
string Dst = 2;
}
message GetRequest {
optional Header Header = 1;
string Key = 2;
}
message GetResponse {
optional Header Header = 1;
string Key = 2;
string Value = 3;
optional Dtype Dtype = 4;
optional GetError Error = 5;
optional string ErrorMsg = 6;
}
message SetRequest {
optional Header Header = 1;
string Key = 2;
string Value = 3;
}
message SetResponse {
optional Header Header = 1;
bool Ok = 2;
optional string Key = 3;
optional string Value = 4;
optional SetError Error = 5;
optional string ErrorMsg = 6;
}
message GetMultipleRequest {
Header Header = 1;
repeated string Keys = 2;
}
message GetMultipleResponse {
Header Header = 1;
repeated GetResponse Responses = 2;
}
message SetMultipleRequest {
Header Header = 1;
repeated SetRequest Requests = 2;
}
message SetMultipleResponse {
Header Header = 1;
repeated SetResponse Responses = 2;
}
// the GetSetRun service provides the fundamental driver functionality for Setting
// values, getting them, and running commands.
service GetSetRun {
// rpc for getting a value from a driver
rpc Get(GetRequest) returns (GetResponse);
// rpc for setting a value on a driver
rpc Set(SetRequest) returns (SetResponse);
// rpc for getting multiple values from a driver
rpc GetMultiple(GetMultipleRequest) returns (GetMultipleResponse);
// rpc for setting multiple response
rpc SetMultiple(SetMultipleRequest) returns (SetMultipleResponse);
}
enum GetError {
GET_ERROR_NONE = 0;
GET_ERROR_UNSPECIFIED = 1;
GET_ERROR_KEY_DOES_NOT_EXIST = 2;
GET_ERROR_TIMEOUT = 3;
GET_ERROR_COULD_NOT_RESOLVE_DRIVER = 4;
}
enum SetError {
SET_ERROR_NONE = 0;
SET_ERROR_UNSPECIFIED = 1;
SET_ERROR_KEY_DOES_NOT_EXIST = 2;
SET_ERROR_TIMEOUT = 3;
SET_ERROR_COULD_NOT_RESOLVE_DRIVER = 4;
SET_ERROR_INVALID_VALUE_TYPE = 5;
}
enum Dtype {
DOUBLE = 0; // float64
FLOAT = 1; // float32
INT32 = 2; // int32
INT64 = 3; // int64
UINT32 = 4;
UINT64 = 5;
SINT32 = 6;
SINT64 = 7;
FIXED32 = 8;
FIXED64 = 9;
SFIXED32 = 10;
SFIXED64 = 11;
BOOL = 12;
STRING = 13;
BYTES = 14;
}
/*
For python compiling:
python -m grpc_tools.protoc -I=. \
--python_out=. \
--pyi_out=. \
--grpc_python_out=. \
device.proto
For Go compiling:
protoc -I=. \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
./device.proto &&
protoc --proto_path=. \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
./device.proto
*/