Compare commits

..

No commits in common. "28a555fa2bb5e0abdaed28f68452882a1762f7d2" and "5458c3ba86ae518c79dd97d57fea317975e3ffe0" have entirely different histories.

3 changed files with 12 additions and 19 deletions

View File

@ -66,7 +66,7 @@ has been used.
Username for HTTP Basic Authentication (default "pingvin") Username for HTTP Basic Authentication (default "pingvin")
``` ```
On first run, the daemon generates `~/.config/enervent-ctrl/configuration.yaml` with default values. On first run, the daemon generates `~/.config/enervent-ctrl/configuration.yaml` with default values.
Configuration options are the same as with CLI flags. CLI flags take precedence over the config file. Configuration options are the same as with CLI flags. CLI flags take precedenence over the config file.
- `serial_address:` Path to RS-485 serial device - `serial_address:` Path to RS-485 serial device
- `port:` TCP port for the REST API to listen on - `port:` TCP port for the REST API to listen on
- `ssl_certificate:` Path to SSL certificate for HTTPS - `ssl_certificate:` Path to SSL certificate for HTTPS

View File

@ -25,7 +25,7 @@ import (
var static embed.FS var static embed.FS
var ( var (
version = "0.1.1" version = "0.1.0"
device pingvin.Pingvin device pingvin.Pingvin
config Conf config Conf
usernamehash [32]byte usernamehash [32]byte
@ -155,7 +155,7 @@ func initDefaultConfig(confpath string) {
} }
} }
// Read configuration. CLI flags take precedence over configuration file // Read configuration. CLI flags take presedence over configuration file
func configure() { func configure() {
log.Println("Reading configuration") log.Println("Reading configuration")
parseConfigFile() parseConfigFile()

View File

@ -32,7 +32,6 @@ type Pingvin struct {
buslock *sync.Mutex buslock *sync.Mutex
handler *modbus.RTUClientHandler handler *modbus.RTUClientHandler
modbusclient modbus.Client modbusclient modbus.Client
firstReadDone bool
Debug PingvinLogger Debug PingvinLogger
} }
@ -311,18 +310,12 @@ func (p *Pingvin) updateRegisters() {
if len(results) > 0 { if len(results) > 0 {
break break
} else if retries == 4 { } else if retries == 4 {
log.Printf("ERROR: updateRegisters: max retries reached, giving up. client.ReadHoldingRegisters: %v", err) log.Fatal("updateRegisters: client.ReadHoldingRegisters: ", err)
log.Printf("ERROR: error occurred when reading registers %d - %d", k, k+r-1)
if !p.firstReadDone {
panic("FATAL: Error on initial read")
}
return
} else if err != nil { } else if err != nil {
log.Printf("WARNING: updateRegisters: client.ReadHoldingRegisters attempt %d: %s", retries, err) log.Printf("WARNING: updateRegisters: client.ReadHoldingRegisters attempt %d: %s", retries, err)
} }
time.Sleep(200 * time.Millisecond) time.Sleep(100 * time.Millisecond)
} }
p.firstReadDone = true
// The values represent 16 bit integers, but modbus works with bytes // The values represent 16 bit integers, but modbus works with bytes
// Each even byte of the returned []byte is the 8 MSBs of a new 16-bit // Each even byte of the returned []byte is the 8 MSBs of a new 16-bit
// value, so for each even byte in the reponse slice we bitshift the byte // value, so for each even byte in the reponse slice we bitshift the byte