kopia lustrzana https://github.com/cyoung/stratux
Fix nil pointer dereference when sensor is not connected/initialized and webUI sensor option is disabled.
2017/03/28 13:43:00 wrote settings. 2017/03/28 13:43:01 http: panic serving 192.168.10.12:52012: runtime error: invalid memory address or nil pointer dereference goroutine 83 [running]: net/http.(*conn).serve.func1(0x10ab6ae0, 0x73826140, 0x10d8c708) /root/go-1.5.1/src/net/http/server.go:1287 +0x9c main.handleSettingsSetRequest(0x72ec00b0, 0x10d93580, 0x10db0620) /root/stratux-westphae/main/managementinterface.go:286 +0x1620 net/http.HandlerFunc.ServeHTTP(0x5d2ecc, 0x72ec00b0, 0x10d93580, 0x10db0620) /root/go-1.5.1/src/net/http/server.go:1422 +0x34 net/http.(*ServeMux).ServeHTTP(0x10960dc0, 0x72ec00b0, 0x10d93580, 0x10db0620) /root/go-1.5.1/src/net/http/server.go:1699 +0x164 net/http.serverHandler.ServeHTTP(0x109c4300, 0x72ec00b0, 0x10d93580, 0x10db0620) /root/go-1.5.1/src/net/http/server.go:1862 +0x190 net/http.(*conn).serve(0x10ab6ae0) /root/go-1.5.1/src/net/http/server.go:1361 +0xbfc created by net/http.(*Server).Serve /root/go-1.5.1/src/net/http/server.go:1910 +0x360 2017/03/28 13:43:01 http: panic serving 192.168.10.12:52013: runtime error: invalid memory address or nil pointer dereference goroutine 58 [running]: net/http.(*conn).serve.func1(0x1098b4a0, 0x73826140, 0x10de8228) /root/go-1.5.1/src/net/http/server.go:1287 +0x9c main.handleSettingsSetRequest(0x72ec00b0, 0x10d93680, 0x10db0690) /root/stratux-westphae/main/managementinterface.go:286 +0x1620 net/http.HandlerFunc.ServeHTTP(0x5d2ecc, 0x72ec00b0, 0x10d93680, 0x10db0690) /root/go-1.5.1/src/net/http/server.go:1422 +0x34 net/http.(*ServeMux).ServeHTTP(0x10960dc0, 0x72ec00b0, 0x10d93680, 0x10db0690) /root/go-1.5.1/src/net/http/server.go:1699 +0x164 net/http.serverHandler.ServeHTTP(0x109c4300, 0x72ec00b0, 0x10d93680, 0x10db0690) /root/go-1.5.1/src/net/http/server.go:1862 +0x190 net/http.(*conn).serve(0x1098b4a0) /root/go-1.5.1/src/net/http/server.go:1361 +0xbfc created by net/http.(*Server).Serve /root/go-1.5.1/src/net/http/server.go:1910 +0x360pull/592/head
rodzic
99e61dc343
commit
89b848c3e5
|
|
@ -276,13 +276,13 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) {
|
|||
globalSettings.GPS_Enabled = val.(bool)
|
||||
case "IMU_Sensor_Enabled":
|
||||
globalSettings.IMU_Sensor_Enabled = val.(bool)
|
||||
if !globalSettings.IMU_Sensor_Enabled {
|
||||
if !globalSettings.IMU_Sensor_Enabled && globalStatus.IMUConnected {
|
||||
myIMUReader.Close()
|
||||
globalStatus.IMUConnected = false
|
||||
}
|
||||
case "BMP_Sensor_Enabled":
|
||||
globalSettings.BMP_Sensor_Enabled = val.(bool)
|
||||
if !globalSettings.BMP_Sensor_Enabled {
|
||||
if !globalSettings.BMP_Sensor_Enabled && globalStatus.BMPConnected {
|
||||
myPressureReader.Close()
|
||||
globalStatus.BMPConnected = false
|
||||
}
|
||||
|
|
@ -397,8 +397,8 @@ func handleOrientAHRS(w http.ResponseWriter, r *http.Request) {
|
|||
if r.Method == "POST" {
|
||||
var (
|
||||
action []byte = make([]byte, 1)
|
||||
u int
|
||||
err error
|
||||
u int
|
||||
err error
|
||||
)
|
||||
|
||||
if _, err = r.Body.Read(action); err != nil {
|
||||
|
|
@ -422,7 +422,7 @@ func handleOrientAHRS(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
log.Printf("AHRS Info: sensor orientation: received up direction %d\n", u)
|
||||
|
||||
if f==u || f==-u {
|
||||
if f == u || f == -u {
|
||||
log.Println("AHRS Error: sensor orientation: up and forward axes cannot be the same")
|
||||
http.Error(w, "up and forward axes cannot be the same", http.StatusBadRequest)
|
||||
return
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue