From aa6f1b45d19b318435b272c278d674030594408e Mon Sep 17 00:00:00 2001 From: Andrey Egorov Date: Mon, 22 Jul 2024 20:24:30 +0300 Subject: [PATCH] Logs. --- api/modem/at/at.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/api/modem/at/at.go b/api/modem/at/at.go index 99caab2..e6f25d9 100644 --- a/api/modem/at/at.go +++ b/api/modem/at/at.go @@ -87,24 +87,27 @@ func (p *atPort) Disconnect() error { func (p *atPort) makeReq(msg string) (string, error) { // Write p.port.ResetInputBuffer() - log.Println("Write...") // DEBUG - if written, err := p.port.Write([]byte(msg)); err != nil { + if _, err := p.port.Write([]byte(msg)); err != nil { return "", fmt.Errorf("serial port write: %w", err) - } else { - log.Println("Written:", written) // DEBUG } // Read - log.Println("Read...") // DEBUG readLen, err := p.port.Read(p.inputBuf) if err != nil { return "", fmt.Errorf("port read: %w", err) } - log.Println("Read: ", readLen, string(p.inputBuf[:readLen])) // DEBUG return string(p.inputBuf[:readLen]), nil } -func (p *atPort) Request(cmdType CmdType, cmd string) (string, error) { +func (p *atPort) Request(cmdType CmdType, cmd string) (outStr string, outErr error) { + defer func() { + if outErr != nil { + return + } + + log.Println("GOT:", outStr, "BYTE:", []byte(outStr)) + }() + msg := "AT" // Make command // By default it just will be AT check cmd