Skip to content

Instantly share code, notes, and snippets.

@BenJuan26
Created April 17, 2020 03:11
Show Gist options
  • Save BenJuan26/bb778810566e8285018aa3e9d4a8f24d to your computer and use it in GitHub Desktop.
Save BenJuan26/bb778810566e8285018aa3e9d4a8f24d to your computer and use it in GitHub Desktop.
func checkStatusAndUpdate() error {
s, err = getSerialPort(getPNPDeviceID())
if err != nil {
return err
}
status, err := elite.GetStatusFromPath(filepath.FromSlash(getLogDir()))
if err != nil {
return err
}
// Only send the data if it has changed.
if status.Timestamp != lastStatus.Timestamp {
infoBytes, err := json.Marshal(status)
if err != nil {
return err
}
_, err = s.Write(infoBytes)
if err != nil {
return err
}
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment