blob: 0806f78308dc70450b29f0a91512964d358e63c2 (
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
|
/*
* RemoteSensor.cpp
*
* Created on: 23 Jul 2019
* Author: David
*/
#include "RemoteSensor.h"
#if SUPPORT_CAN_EXPANSION
#include "CAN/CanMessageGenericConstructor.h"
#include "CanMessageBuffer.h"
constexpr uint32_t RemoteTemperatureTimeoutMillis = 1000;
RemoteSensor::RemoteSensor(unsigned int sensorNum, CanAddress pBoardAddress) noexcept
: TemperatureSensor(sensorNum, "remote"), boardAddress(pBoardAddress)
{
}
GCodeResult RemoteSensor::Configure(GCodeBuffer& gb, const StringRef& reply)
{
bool seen = false;
TryConfigureSensorName(gb, seen);
CanMessageGenericConstructor cons(M308Params);
if (!cons.PopulateFromCommand(gb, reply))
{
return GCodeResult::error;
}
return cons.SendAndGetResponse(CanMessageType::m308, boardAddress, reply);
}
void RemoteSensor::UpdateRemoteTemperature(CanAddress src, const CanSensorReport& report) noexcept
{
if (src == boardAddress)
{
SetResult(report.temperature, (TemperatureError)report.errorCode);
}
}
#endif
// End
|