@@ -41,15 +41,15 @@ auto rain = RainSensor(RAIN_SENSOR_PIN);
41
41
// cin and cout for ArduinoSTL
42
42
namespace std
43
43
{
44
- ohserialstream cout (host);
45
- ihserialstream cin (host);
44
+ ohserialstream cout (host);
45
+ ihserialstream cin (host);
46
46
} // namespace std
47
47
48
- void DispatchCommand (const Command& command)
49
- {
48
+ void DispatchCommand (const Command & command)
49
+ {
50
50
// std::cout << command.RawCommand << "V=" << command.Verb << ", T=" << command.TargetDevice << ", P=" << command.StepPosition << std::endl;
51
51
commandProcessor.HandleCommand (command);
52
- }
52
+ }
53
53
54
54
/*
55
55
* Handles receive data from the host serial interface.
@@ -71,7 +71,7 @@ void HandleSerialCommunications()
71
71
case ' \n ' : // newline - dispatch the command
72
72
case ' \r ' : // carriage return - dispatch the command
73
73
if (hostReceiveBuffer.length () > 1 )
74
- {
74
+ {
75
75
const auto command = Command (hostReceiveBuffer);
76
76
DispatchCommand (command);
77
77
hostReceiveBuffer.clear ();
@@ -81,7 +81,7 @@ void HandleSerialCommunications()
81
81
<< ResponseBuilder::Message
82
82
<< ResponseBuilder::terminator
83
83
<< std::endl; // send response, if there is one.
84
- }
84
+ }
85
85
break ;
86
86
case ' @' : // Start of new command
87
87
hostReceiveBuffer.clear ();
@@ -171,7 +171,10 @@ void loop()
171
171
rain.loop ();
172
172
// Release stepper holding torque if there has been no serial communication for "a long time".
173
173
if (serialInactivityTimer.Expired ())
174
+ {
174
175
stepper.releaseMotor ();
176
+ serialInactivityTimer.Stop ();
177
+ }
175
178
}
176
179
}
177
180
0 commit comments