Skip to content

Commit

Permalink
fix: add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tonygilkerson committed Mar 20, 2024
1 parent 0622491 commit 1c42f4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
20 changes: 3 additions & 17 deletions charts/serial-gateway/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions cmd/serial/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit 1c42f4d

Please sign in to comment.