Skip to content

Commit 9e2353d

Browse files
committed
fix5
1 parent 82c501c commit 9e2353d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

controller/rpc_client.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55
"encoding/json"
6+
"fmt"
67
"log"
78
"math"
89
"strconv"
@@ -30,7 +31,7 @@ func main() {
3031

3132
for {
3233

33-
var temperature float64
34+
temperature := ""
3435

3536
for _, module := range config.Config.Modules {
3637
log.Printf(" [x] Requesting on {%s, %s, %s}", module.Name, module.Type, module.RoutingKey)
@@ -46,12 +47,13 @@ func main() {
4647

4748
if module.Name == "raspberrypi-0" {
4849
var obj Dht11
49-
err = json.Unmarshal([]byte(res), &obj)
50+
jsonString := string(fmt.Sprintf("`%s`", res))
51+
err = json.Unmarshal([]byte(jsonString), &obj)
5052
if err != nil {
5153
log.Fatalf("error: %v", err)
5254
}
5355

54-
temperature = obj.T
56+
temperature = strconv.Itoa(int(math.Round(obj.T)))
5557
}
5658

5759
if module.Name == "raspberrypi-1" {
@@ -60,7 +62,7 @@ func main() {
6062
"tm1637",
6163
[]string{
6264
"temperature",
63-
strconv.Itoa(int(math.Round(temperature))),
65+
temperature,
6466
},
6567
)
6668
failOnError(err, "Failed to handle RPC request: tm1637")

modules/raspberrypi5/devices/dht11/app/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
dhtDevice = _device(_board)
1313

1414
try:
15+
1516
d = dict();
1617

1718
d['t'] = dhtDevice.temperature

0 commit comments

Comments
 (0)