Skip to content

Commit

Permalink
Mennekes Compact: start heartbeat immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Mar 17, 2024
1 parent d3ae335 commit b86fbfa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion charger/mennekes-compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func NewMennekesCompact(uri, device, comset string, baudrate int, proto modbus.P
}

func (wb *MennekesCompact) heartbeat(timeout time.Duration) {
for range time.Tick(timeout) {
for ; true; <-time.Tick(timeout) {
if _, err := wb.conn.WriteSingleRegister(mennekesRegHeartbeat, mennekesHeartbeatToken); err != nil {
wb.log.ERROR.Println("heartbeat:", err)
}
Expand Down

5 comments on commit b86fbfa

@malud
Copy link

@malud malud commented on b86fbfa Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andig thanks for moving forward with these issues.

But :-) , this creates a tick(er) with every iteration. Intended?

@andig
Copy link
Member Author

@andig andig commented on b86fbfa Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it?

@malud
Copy link

@malud malud commented on b86fbfa Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess yes:
https://go.dev/play/p/OGhKfodD77O (for true;)
https://go.dev/play/p/59oWgDDwYx8 (for range)

For exact behaviour you have to execute the binary via gc trace option but the difference is already there (increase i to 1000) makes no difference for range.

@malud
Copy link

@malud malud commented on b86fbfa Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just use #12984 😊 ✌️

@andig
Copy link
Member Author

@andig andig commented on b86fbfa Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...only that changes five other things and make this heartbeat different from any other implemented. That is not the way to go. Thanks for the GC reproducer, fixed in master.

Please sign in to comment.