From 1c42f4dc189e3550bc4c7e0a9e989eb3175facd3 Mon Sep 17 00:00:00 2001 From: Tony Gilkerson Date: Tue, 19 Mar 2024 21:34:55 -0400 Subject: [PATCH] fix: add logging --- charts/serial-gateway/Chart.yaml | 20 +++----------------- cmd/serial/main.go | 9 +++++++++ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/charts/serial-gateway/Chart.yaml b/charts/serial-gateway/Chart.yaml index 4f02ef1..6678cc8 100644 --- a/charts/serial-gateway/Chart.yaml +++ b/charts/serial-gateway/Chart.yaml @@ -1,21 +1,7 @@ apiVersion: v2 name: serial-gateway description: A Helm chart for Kubernetes -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. + type: application -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: v1.0.26 -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "v1.0.26" +version: v1.0.27 +appVersion: "v1.0.27" diff --git a/cmd/serial/main.go b/cmd/serial/main.go index 73c0df7..e234a09 100644 --- a/cmd/serial/main.go +++ b/cmd/serial/main.go @@ -160,6 +160,8 @@ func serialServer(port *serial.Port) { var n int var partialMsg string + log.Println("serialServer: read serial port") + n, err = port.Read(buf) if err != nil { log.Panicf("Error trying to read serial port %v\n", err) @@ -168,19 +170,26 @@ func serialServer(port *serial.Port) { // // messages should looks like "msg1|msg2|msg3|" and end in a | // + log.Printf("serialServer: received %v bytes: %v",n,string(buf[:n])) messages := partialMsg + string(buf[:n]) + log.Printf("serialServer: messages, is it partial - initial read? %v",messages) + // prepend the partial message from last time to the message we got this time // if we don't find a | then we still have a partial message // Add to the partial message and keep reading if !strings.HasSuffix(messages, "|") { partialMsg = messages + log.Printf("serialServer: it is partial set, set partialMsg and continue: %v",partialMsg) continue } + log.Printf("serialServer: messages that need split: %v",messages) // // Split msgs := strings.Split(messages, "|") + + log.Printf("serialServer: msgs: %v",msgs) for _, msg := range msgs { switch {