Temporarily disable prints in the peripheral pkg - need to add a different log
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user