@@ -61,13 +61,17 @@ func (p *PortProxy) Close() error {
61
61
// Monitor opens a communication port. It returns a PortProxy to communicate with the port and a PortDescriptor
62
62
// that describes the available configuration settings.
63
63
func Monitor (ctx context.Context , req * rpc.MonitorRequest ) (* PortProxy , * pluggableMonitor.PortDescriptor , error ) {
64
- pme , release := commands .GetPackageManagerExplorer (req )
64
+ openReq := req .GetOpenRequest ()
65
+ if openReq == nil {
66
+ return nil , nil , & arduino.InvalidInstanceError {}
67
+ }
68
+ pme , release := commands .GetPackageManagerExplorer (openReq )
65
69
if pme == nil {
66
70
return nil , nil , & arduino.InvalidInstanceError {}
67
71
}
68
72
defer release ()
69
73
70
- m , boardSettings , err := findMonitorAndSettingsForProtocolAndBoard (pme , req .GetPort ().GetProtocol (), req .GetFqbn ())
74
+ m , boardSettings , err := findMonitorAndSettingsForProtocolAndBoard (pme , openReq .GetPort ().GetProtocol (), openReq .GetFqbn ())
71
75
if err != nil {
72
76
return nil , nil , err
73
77
}
@@ -83,7 +87,7 @@ func Monitor(ctx context.Context, req *rpc.MonitorRequest) (*PortProxy, *pluggab
83
87
}
84
88
85
89
// Apply user-requested settings
86
- if portConfig := req .GetPortConfiguration (); portConfig != nil {
90
+ if portConfig := openReq .GetPortConfiguration (); portConfig != nil {
87
91
for _ , setting := range portConfig .Settings {
88
92
boardSettings .Remove (setting .SettingId ) // Remove board settings overridden by the user
89
93
if err := m .Configure (setting .SettingId , setting .Value ); err != nil {
@@ -96,13 +100,13 @@ func Monitor(ctx context.Context, req *rpc.MonitorRequest) (*PortProxy, *pluggab
96
100
m .Configure (setting , value )
97
101
}
98
102
99
- monIO , err := m .Open (req .GetPort ().GetAddress (), req .GetPort ().GetProtocol ())
103
+ monIO , err := m .Open (openReq .GetPort ().GetAddress (), openReq .GetPort ().GetProtocol ())
100
104
if err != nil {
101
105
m .Quit ()
102
106
return nil , nil , & arduino.FailedMonitorError {Cause : err }
103
107
}
104
108
105
- logrus .Infof ("Port %s successfully opened" , req .GetPort ().GetAddress ())
109
+ logrus .Infof ("Port %s successfully opened" , openReq .GetPort ().GetAddress ())
106
110
return & PortProxy {
107
111
rw : monIO ,
108
112
changeSettingsCB : m .Configure ,
0 commit comments