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 (
|
import (
|
||||||
"esdi/peripheral/communication/constvar"
|
"esdi/peripheral/communication/constvar"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IdentificationPacket struct {
|
type IdentificationPacket struct {
|
||||||
@@ -14,12 +13,12 @@ type IdentificationPacket struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pkt *IdentificationPacket) Validate() bool {
|
func (pkt *IdentificationPacket) Validate() bool {
|
||||||
fmt.Println("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓")
|
// fmt.Println("↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓")
|
||||||
fmt.Println(pkt.StartMarker)
|
// fmt.Println(pkt.StartMarker)
|
||||||
fmt.Println(pkt.PktType.String())
|
// fmt.Println(pkt.PktType.String())
|
||||||
fmt.Println(string(pkt.Name[:]))
|
// fmt.Println(string(pkt.Name[:]))
|
||||||
fmt.Println(pkt.EndMarker)
|
// fmt.Println(pkt.EndMarker)
|
||||||
fmt.Println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑")
|
// fmt.Println("↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑")
|
||||||
|
|
||||||
// Change this to return an error and add a validation against available
|
// Change this to return an error and add a validation against available
|
||||||
// device ids
|
// device ids
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (wt *WalkieTalkie) ReadFramedData(size int, packet any) error {
|
|||||||
b := make([]byte, 1)
|
b := make([]byte, 1)
|
||||||
_, err := wt.Serial.Read(b)
|
_, err := wt.Serial.Read(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("dev read:", err.Error())
|
// fmt.Fprintf(os.Stderr, "dev read: %s\n", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ func (wt *WalkieTalkie) sendPacket(cmd types.Command, data any) error {
|
|||||||
|
|
||||||
// Send the payload
|
// Send the payload
|
||||||
serializedPacket := packet.Serialize()
|
serializedPacket := packet.Serialize()
|
||||||
fmt.Println(serializedPacket)
|
// fmt.Fprintf(os.Stderr, "%+v", serializedPacket)
|
||||||
|
|
||||||
_, err = wt.Serial.Write(serializedPacket)
|
_, err = wt.Serial.Write(serializedPacket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -177,8 +177,7 @@ func (wt *WalkieTalkie) readPacket(resp packets.Packet) error {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
func (wt *WalkieTalkie) SendCommand(cmd types.Command, payload any,
|
func (wt *WalkieTalkie) SendCommand(cmd types.Command, payload any,
|
||||||
responseBody packets.Packet,
|
responseBody packets.Packet) error {
|
||||||
) error {
|
|
||||||
// Prepare the header
|
// Prepare the header
|
||||||
// header := header{
|
// header := header{
|
||||||
// StartByte: constvar.StartOfText,
|
// StartByte: constvar.StartOfText,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
pack "esdi/peripheral/communication/packets"
|
pack "esdi/peripheral/communication/packets"
|
||||||
"esdi/peripheral/devices"
|
"esdi/peripheral/devices"
|
||||||
"esdi/peripheral/types"
|
"esdi/peripheral/types"
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tarm/serial"
|
"github.com/tarm/serial"
|
||||||
@@ -83,8 +82,8 @@ func (p *PeripheralDevice) Probe() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PeripheralDevice) SendCommand(cmd types.Command, payload []byte) error {
|
func (p *PeripheralDevice) SendCommand(cmd types.Command, payload []byte) error {
|
||||||
fmt.Println("Send command:", cmd)
|
// fmt.Fprintf(os.Stderr, "Send command: %+v\n", cmd)
|
||||||
fmt.Println("With payload:", payload)
|
// fmt.Fprintf(os.Stderr, "With payload: %+v\n", payload)
|
||||||
|
|
||||||
var ack pack.AckPacket
|
var ack pack.AckPacket
|
||||||
err := p.WT.SendCommand(cmd, payload, &ack)
|
err := p.WT.SendCommand(cmd, payload, &ack)
|
||||||
@@ -92,9 +91,9 @@ func (p *PeripheralDevice) SendCommand(cmd types.Command, payload []byte) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ack.AckByte == 0x06 {
|
// if ack.AckByte == 0x06 {
|
||||||
fmt.Println("Succesfully received ack")
|
// fmt.Fprintf(os.Stderr, "Succesfully received ack")
|
||||||
}
|
// }
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,23 +58,21 @@ func (clerk *PeripheralDeviceClerk) FindDevices() error {
|
|||||||
|
|
||||||
err := newDevice.Probe()
|
err := newDevice.Probe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(p, err.Error())
|
// fmt.Fprintf(os.Stderr, "%+v - %s\n", p, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for the device on our device list - we need its API
|
// Look for the device on our device list - we need its API
|
||||||
newDevice.DeviceAPI = clerk.FindDeviceAPI(newDevice.ID)
|
newDevice.DeviceAPI = clerk.FindDeviceAPI(newDevice.ID)
|
||||||
if newDevice.DeviceAPI == nil {
|
// if newDevice.DeviceAPI == nil {
|
||||||
fmt.Printf("Failed to acquire API for device: [%2d] %s\n",
|
// fmt.Printf("Failed to acquire API for device: [%2d] %s\n",
|
||||||
newDevice.ID, newDevice.Name)
|
// newDevice.ID, newDevice.Name)
|
||||||
}
|
// }
|
||||||
|
|
||||||
clerk.addDevice(newDevice)
|
clerk.addDevice(newDevice)
|
||||||
fmt.Println(p, string(newDevice.Name[:]))
|
// fmt.Println(p, string(newDevice.Name[:]))
|
||||||
}
|
}
|
||||||
|
|
||||||
// go clerk.clerkBackgroundJob()
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,9 +98,9 @@ func (clerk *PeripheralDeviceClerk) ListDeviceAPI(ID uint8) error {
|
|||||||
return fmt.Errorf("device with ID %d not found", ID)
|
return fmt.Errorf("device with ID %d not found", ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range dev.DeviceAPI.API {
|
// for _, f := range dev.DeviceAPI.API {
|
||||||
fmt.Printf("%s\t%s\n", f.Name, f.Desc)
|
// fmt.Printf("%s\t%s\n", f.Name, f.Desc)
|
||||||
}
|
// }
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user