Logs.
This commit is contained in:
parent
14e2a2329e
commit
aa6f1b45d1
@ -87,24 +87,27 @@ func (p *atPort) Disconnect() error {
|
|||||||
func (p *atPort) makeReq(msg string) (string, error) {
|
func (p *atPort) makeReq(msg string) (string, error) {
|
||||||
// Write
|
// Write
|
||||||
p.port.ResetInputBuffer()
|
p.port.ResetInputBuffer()
|
||||||
log.Println("Write...") // DEBUG
|
if _, err := p.port.Write([]byte(msg)); err != nil {
|
||||||
if written, err := p.port.Write([]byte(msg)); err != nil {
|
|
||||||
return "", fmt.Errorf("serial port write: %w", err)
|
return "", fmt.Errorf("serial port write: %w", err)
|
||||||
} else {
|
|
||||||
log.Println("Written:", written) // DEBUG
|
|
||||||
}
|
}
|
||||||
// Read
|
// Read
|
||||||
log.Println("Read...") // DEBUG
|
|
||||||
readLen, err := p.port.Read(p.inputBuf)
|
readLen, err := p.port.Read(p.inputBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("port read: %w", err)
|
return "", fmt.Errorf("port read: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Read: ", readLen, string(p.inputBuf[:readLen])) // DEBUG
|
|
||||||
return string(p.inputBuf[:readLen]), nil
|
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"
|
msg := "AT"
|
||||||
// Make command
|
// Make command
|
||||||
// By default it just will be AT check cmd
|
// By default it just will be AT check cmd
|
||||||
|
Loading…
Reference in New Issue
Block a user