From 4ce12f07e852e2d90ef3a4172b7c713f81e29f37 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 14 Jan 2026 22:53:37 +0000 Subject: [PATCH] Temporarily disable prints in the peripheral pkg - need to add a different log --- .../communication/packets/identification.go | 13 ++++++------ peripheral/communication/walkieTalkie.go | 7 +++---- peripheral/device.go | 11 +++++----- peripheral/peripheral.go | 20 +++++++++---------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/peripheral/communication/packets/identification.go b/peripheral/communication/packets/identification.go index 7c27ffa..9e16124 100644 --- a/peripheral/communication/packets/identification.go +++ b/peripheral/communication/packets/identification.go @@ -2,7 +2,6 @@ package packets import ( "esdi/peripheral/communication/constvar" - "fmt" ) type IdentificationPacket struct { @@ -14,12 +13,12 @@ type IdentificationPacket struct { } func (pkt *IdentificationPacket) Validate() bool { - fmt.Println("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓") - fmt.Println(pkt.StartMarker) - fmt.Println(pkt.PktType.String()) - fmt.Println(string(pkt.Name[:])) - fmt.Println(pkt.EndMarker) - fmt.Println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑") + // fmt.Println("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓") + // fmt.Println(pkt.StartMarker) + // fmt.Println(pkt.PktType.String()) + // fmt.Println(string(pkt.Name[:])) + // fmt.Println(pkt.EndMarker) + // fmt.Println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑") // Change this to return an error and add a validation against available // device ids diff --git a/peripheral/communication/walkieTalkie.go b/peripheral/communication/walkieTalkie.go index 18fe223..e5503b6 100644 --- a/peripheral/communication/walkieTalkie.go +++ b/peripheral/communication/walkieTalkie.go @@ -26,7 +26,7 @@ func (wt *WalkieTalkie) ReadFramedData(size int, packet any) error { b := make([]byte, 1) _, err := wt.Serial.Read(b) if err != nil { - fmt.Println("dev read:", err.Error()) + // fmt.Fprintf(os.Stderr, "dev read: %s\n", err.Error()) return err } @@ -119,7 +119,7 @@ func (wt *WalkieTalkie) sendPacket(cmd types.Command, data any) error { // Send the payload serializedPacket := packet.Serialize() - fmt.Println(serializedPacket) + // fmt.Fprintf(os.Stderr, "%+v", serializedPacket) _, err = wt.Serial.Write(serializedPacket) if err != nil { @@ -177,8 +177,7 @@ func (wt *WalkieTalkie) readPacket(resp packets.Packet) error { // } func (wt *WalkieTalkie) SendCommand(cmd types.Command, payload any, - responseBody packets.Packet, -) error { + responseBody packets.Packet) error { // Prepare the header // header := header{ // StartByte: constvar.StartOfText, diff --git a/peripheral/device.go b/peripheral/device.go index 6c4b555..1cf75c7 100644 --- a/peripheral/device.go +++ b/peripheral/device.go @@ -5,7 +5,6 @@ import ( pack "esdi/peripheral/communication/packets" "esdi/peripheral/devices" "esdi/peripheral/types" - "fmt" "time" "github.com/tarm/serial" @@ -83,8 +82,8 @@ func (p *PeripheralDevice) Probe() error { } func (p *PeripheralDevice) SendCommand(cmd types.Command, payload []byte) error { - fmt.Println("Send command:", cmd) - fmt.Println("With payload:", payload) + // fmt.Fprintf(os.Stderr, "Send command: %+v\n", cmd) + // fmt.Fprintf(os.Stderr, "With payload: %+v\n", payload) var ack pack.AckPacket err := p.WT.SendCommand(cmd, payload, &ack) @@ -92,9 +91,9 @@ func (p *PeripheralDevice) SendCommand(cmd types.Command, payload []byte) error return err } - if ack.AckByte == 0x06 { - fmt.Println("Succesfully received ack") - } + // if ack.AckByte == 0x06 { + // fmt.Fprintf(os.Stderr, "Succesfully received ack") + // } return nil } diff --git a/peripheral/peripheral.go b/peripheral/peripheral.go index 8d90d3e..e9d6f25 100644 --- a/peripheral/peripheral.go +++ b/peripheral/peripheral.go @@ -58,23 +58,21 @@ func (clerk *PeripheralDeviceClerk) FindDevices() error { err := newDevice.Probe() if err != nil { - fmt.Println(p, err.Error()) + // fmt.Fprintf(os.Stderr, "%+v - %s\n", p, err.Error()) continue } // Look for the device on our device list - we need its API newDevice.DeviceAPI = clerk.FindDeviceAPI(newDevice.ID) - if newDevice.DeviceAPI == nil { - fmt.Printf("Failed to acquire API for device: [%2d] %s\n", - newDevice.ID, newDevice.Name) - } + // if newDevice.DeviceAPI == nil { + // fmt.Printf("Failed to acquire API for device: [%2d] %s\n", + // newDevice.ID, newDevice.Name) + // } clerk.addDevice(newDevice) - fmt.Println(p, string(newDevice.Name[:])) + // fmt.Println(p, string(newDevice.Name[:])) } - // go clerk.clerkBackgroundJob() - return nil } @@ -100,9 +98,9 @@ func (clerk *PeripheralDeviceClerk) ListDeviceAPI(ID uint8) error { return fmt.Errorf("device with ID %d not found", ID) } - for _, f := range dev.DeviceAPI.API { - fmt.Printf("%s\t%s\n", f.Name, f.Desc) - } + // for _, f := range dev.DeviceAPI.API { + // fmt.Printf("%s\t%s\n", f.Name, f.Desc) + // } return nil }