Skip to content

Commit

Permalink
Adds serial port to serial transport
Browse files Browse the repository at this point in the history
Change-type: minor
Signed-off-by: Alex Bucknall <[email protected]>
  • Loading branch information
Bucknalla committed Jul 30, 2024
1 parent 1822dbd commit 9efa3f9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion notecard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const (
I2C = "i2c"
)

const SerialDevice = "/dev/tty.usbmodemNOTE1"

type server struct {
card *notecard.Context
initError error
Expand Down Expand Up @@ -86,7 +88,14 @@ func setupNotecard(protocol string) (*notecard.Context, error) {
}

if protocol == Serial {
card, err := notecard.OpenSerial("/dev/tty.usbmodemNOTE1", 9600)
serialPort := getEnv("NOTECARD_SERIAL_DEVICE", SerialDevice)

baud, err := strconv.Atoi(getEnv("NOTECARD_SERIAL_BAUD", "9600"))
if err != nil {
return nil, fmt.Errorf("error parsing NOTECARD_SERIAL_BAUD: %v", err)
}

card, err := notecard.OpenSerial(serialPort, baud)
if err != nil {
return nil, fmt.Errorf("error opening Notecard: %v", err)
}
Expand Down

0 comments on commit 9efa3f9

Please sign in to comment.