Skip to content

feat: DAQ Heartbeat#546

Open
nicholasching wants to merge 4 commits intodaqfrom
daq-nick-heartbeat
Open

feat: DAQ Heartbeat#546
nicholasching wants to merge 4 commits intodaqfrom
daq-nick-heartbeat

Conversation

@nicholasching
Copy link

Completed basic heartbeat functionality for DAQ with the following features and design considerations:

Decided to implement heartbeat on separate heartbeat.go file for modularization.

On an interval, currently 3s, send POST request to the server with the following info:

  • timestamp
  • vehicle_ID - currently retrieved from env variable; i was thinking this could be used as a tag to filter data in the future. For example, we can configure the vehicle with different identifiers to differentiate between development, testing, practice, competition, etc, and then filter runs by vehicle_ID
  • session_ID - unique hash generated on each startup of the heartbeat script, allows us to track different test runs and associate CAN frame data w/each run, maybe some sort of list view for runs in the future.
  • CAN connection state for basic debug if the CAN telemetry does not work, but heartbeat does.

If communication fails, nothing happens; we will continue sending on the same regular interval.

Copy link
Contributor

@sokosam sokosam left a comment

Choose a reason for hiding this comment

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

Rest LGTM

can0Active := h.can0 != nil
can1Active := h.can1 != nil
return can0Active, can1Active
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't touched go in a while but can you confirm if this actually checks if the can channels are active? (assuming that this is the goal)

are we certain that if HeartbeatHandler -> can0 : net.Conn is simply initialized that it would mean its active/online?

Again I'm not really sure how this works so just lmk if its right or not.

logger.Error("Failed to send heartbeat", zap.Error(err))
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we name both to Interval? Feels weird to have one be uploadTimer and heartbeatInterval

Suggested change
}
uploadInterval := time.NewTimer(time.Second)
heartbeatInterval := time.NewTicker(3 * time.Second)
defer heartbeatInterval.Stop()
for {
select {
case <-uploadInterval.C:
err = telemetry.Upload()
if err != nil {
fmt.Printf("failed to upload telemetry data: %v\n", err)
}
case <-heartbeatInterval.C:
err = heartbeat.SendHeartbeat()
if err != nil {
logger.Error("Failed to send heartbeat", zap.Error(err))
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments