Skip to content

Commit af90803

Browse files
committed
Added oneof clause to MonitorResponse
1 parent f5786b1 commit af90803

File tree

3 files changed

+132
-84
lines changed

3 files changed

+132
-84
lines changed

commands/service_monitor.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (s *arduinoCoreServerImpl) Monitor(stream rpc.ArduinoCoreService_MonitorSer
160160

161161
// Send a message with Success set to true to notify the caller of the port being now active
162162
syncSend := NewSynchronizedSend(stream.Send)
163-
_ = syncSend.Send(&rpc.MonitorResponse{Success: true})
163+
_ = syncSend.Send(&rpc.MonitorResponse{Message: &rpc.MonitorResponse_Success{Success: true}})
164164

165165
ctx, cancel := context.WithCancel(stream.Context())
166166
gracefulCloseInitiated := &atomic.Bool{}
@@ -175,13 +175,13 @@ func (s *arduinoCoreServerImpl) Monitor(stream rpc.ArduinoCoreService_MonitorSer
175175
return
176176
}
177177
if err != nil {
178-
syncSend.Send(&rpc.MonitorResponse{Error: err.Error()})
178+
syncSend.Send(&rpc.MonitorResponse{Message: &rpc.MonitorResponse_Error{Error: err.Error()}})
179179
return
180180
}
181181
if conf := msg.GetUpdatedConfiguration(); conf != nil {
182182
for _, c := range conf.GetSettings() {
183183
if err := monitor.Configure(c.GetSettingId(), c.GetValue()); err != nil {
184-
syncSend.Send(&rpc.MonitorResponse{Error: err.Error()})
184+
syncSend.Send(&rpc.MonitorResponse{Message: &rpc.MonitorResponse_Error{Error: err.Error()}})
185185
}
186186
}
187187
}
@@ -199,7 +199,7 @@ func (s *arduinoCoreServerImpl) Monitor(stream rpc.ArduinoCoreService_MonitorSer
199199
return
200200
}
201201
if err != nil {
202-
syncSend.Send(&rpc.MonitorResponse{Error: err.Error()})
202+
syncSend.Send(&rpc.MonitorResponse{Message: &rpc.MonitorResponse_Error{Error: err.Error()}})
203203
return
204204
}
205205
tx = tx[n:]
@@ -217,10 +217,10 @@ func (s *arduinoCoreServerImpl) Monitor(stream rpc.ArduinoCoreService_MonitorSer
217217
break
218218
}
219219
if err != nil {
220-
syncSend.Send(&rpc.MonitorResponse{Error: err.Error()})
220+
syncSend.Send(&rpc.MonitorResponse{Message: &rpc.MonitorResponse_Error{Error: err.Error()}})
221221
break
222222
}
223-
if err := syncSend.Send(&rpc.MonitorResponse{RxData: buff[:n]}); err != nil {
223+
if err := syncSend.Send(&rpc.MonitorResponse{Message: &rpc.MonitorResponse_RxData{RxData: buff[:n]}}); err != nil {
224224
break
225225
}
226226
}

rpc/cc/arduino/cli/commands/v1/monitor.pb.go

+112-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/cc/arduino/cli/commands/v1/monitor.proto

+14-12
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,24 @@ message MonitorPortOpenRequest {
5151
}
5252

5353
message MonitorPortConfiguration {
54-
// The port configuration parameters to configure
54+
// The port configuration parameters
5555
repeated MonitorPortSetting settings = 1;
5656
}
5757

5858
message MonitorResponse {
59-
// Eventual errors dealing with monitor port
60-
string error = 1;
61-
// Data received from the port
62-
bytes rx_data = 2;
63-
// Settings applied to the port, may be returned after a port is opened (to
64-
// report the default settings) or after a new port_configuration is sent
65-
// (to report the new settings applied)
66-
repeated MonitorPortSetting applied_settings = 3;
67-
// A message with this field set to true is sent as soon as the port is
68-
// succesfully opened
69-
bool success = 4;
59+
oneof message {
60+
// Eventual errors dealing with monitor port
61+
string error = 1;
62+
// Data received from the port
63+
bytes rx_data = 2;
64+
// Settings applied to the port, may be returned after a port is opened (to
65+
// report the default settings) or after a new port_configuration is sent
66+
// (to report the new settings applied)
67+
MonitorPortConfiguration applied_settings = 3;
68+
// A message with this field set to true is sent as soon as the port is
69+
// succesfully opened
70+
bool success = 4;
71+
}
7072
}
7173

7274
message MonitorPortSetting {

0 commit comments

Comments
 (0)