remove/deactivate debug output

master
Florian Thienel 3 years ago
parent b3a794b7b0
commit a505f4320c

@ -4,13 +4,13 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"log"
"strings" "strings"
"time" "time"
) )
const ( const (
readBufferSize = 1024 readBufferSize = 1024
atSendingQueueTimeout = 500 * time.Millisecond
) )
func New(device io.ReadWriter) *COM { func New(device io.ReadWriter) *COM {
@ -23,8 +23,8 @@ func New(device io.ReadWriter) *COM {
} }
go func() { go func() {
log.Print("entering COM loop") // log.Print("entering COM loop")
defer log.Print("exiting COM loop") // defer log.Print("exiting COM loop")
defer close(result.closed) defer close(result.closed)
var commandCancelled <-chan struct{} var commandCancelled <-chan struct{}
@ -37,7 +37,6 @@ func New(device io.ReadWriter) *COM {
select { select {
case line, valid := <-lines: case line, valid := <-lines:
if !valid { if !valid {
log.Print("lines channel closed")
return return
} }
// log.Printf("rx: %s", line) // log.Printf("rx: %s", line)
@ -102,8 +101,8 @@ type COM struct {
func readLoop(r io.Reader) <-chan string { func readLoop(r io.Reader) <-chan string {
lines := make(chan string, 1) lines := make(chan string, 1)
go func() { go func() {
log.Print("entering read loop") // log.Print("entering read loop")
defer log.Print("exiting read loop") // defer log.Print("exiting read loop")
buf := make([]byte, readBufferSize) buf := make([]byte, readBufferSize)
currentLine := make([]byte, 0, readBufferSize) currentLine := make([]byte, 0, readBufferSize)
@ -116,7 +115,7 @@ func readLoop(r io.Reader) <-chan string {
close(lines) close(lines)
return return
} else if err != nil { } else if err != nil {
log.Printf("read error: %v", err) // log.Printf("read error: %v", err)
if len(currentLine) > 0 { if len(currentLine) > 0 {
lines <- string(currentLine) lines <- string(currentLine)
} }
@ -166,7 +165,6 @@ func (c *COM) newIndication(line string) *indication {
for _, config := range c.indications { for _, config := range c.indications {
result := config.NewIfMatches(line) result := config.NewIfMatches(line)
if result != nil { if result != nil {
log.Printf("%s is an indication", config.prefix)
return result return result
} }
} }
@ -180,7 +178,7 @@ func (c *COM) ClearSyntaxErrors(ctx context.Context) error {
return nil return nil
} }
if err.Error() == "+CME ERROR: 35" { if err.Error() == "+CME ERROR: 35" {
log.Printf(".") // log.Printf(".")
time.Sleep(200) time.Sleep(200)
} else { } else {
return err return err
@ -202,7 +200,7 @@ func (c *COM) AT(ctx context.Context, request string) ([]string, error) {
case c.commands <- cmd: case c.commands <- cmd:
case <-ctx.Done(): case <-ctx.Done():
return nil, ctx.Err() return nil, ctx.Err()
case <-time.After(500 * time.Millisecond): case <-time.After(atSendingQueueTimeout):
return nil, fmt.Errorf("AT sending queue timeout") return nil, fmt.Errorf("AT sending queue timeout")
} }
@ -254,14 +252,12 @@ type indication struct {
} }
func (ind *indication) AddLine(line string) { func (ind *indication) AddLine(line string) {
log.Printf("%s add line %s, actual: %d, expected %d", ind.config.prefix, line, len(ind.lines), ind.config.trailingLines)
if ind.Complete() { if ind.Complete() {
return return
} }
ind.lines = append(ind.lines, line) ind.lines = append(ind.lines, line)
if ind.Complete() { if ind.Complete() {
log.Printf("%s is complete, actual: %d, expected %d\n%v", ind.config.prefix, len(ind.lines), ind.config.trailingLines, strings.Join(ind.lines, "\n"))
go func() { go func() {
ind.config.handler(ind.lines) ind.config.handler(ind.lines)
}() }()

@ -13,7 +13,6 @@ UDH: User Data Header
Restrictions: Restrictions:
Store/forward control information is not supported yet. Store/forward control information is not supported yet.
Only ISO8859-1 supported as text encoding.
*/ */
package sds package sds

@ -2,7 +2,6 @@ package sds
import ( import (
"fmt" "fmt"
"log"
"time" "time"
"github.com/ftl/tetra-pei/tetra" "github.com/ftl/tetra-pei/tetra"
@ -114,7 +113,7 @@ func (s *Stack) WithResponseCallback(callback ResponseCallback) *Stack {
func (s *Stack) Put(part IncomingMessage) error { func (s *Stack) Put(part IncomingMessage) error {
switch payload := part.Payload.(type) { switch payload := part.Payload.(type) {
case Status: case Status:
log.Print("incoming status") // log.Print("incoming status")
if s.statusCallback == nil { if s.statusCallback == nil {
return nil return nil
} }
@ -124,7 +123,7 @@ func (s *Stack) Put(part IncomingMessage) error {
Value: payload, Value: payload,
}) })
case SimpleTextMessage: case SimpleTextMessage:
log.Print("incoming simple text message") // log.Print("incoming simple text message")
if s.messageCallback == nil { if s.messageCallback == nil {
return nil return nil
} }
@ -137,7 +136,7 @@ func (s *Stack) Put(part IncomingMessage) error {
message.SetPart(1, payload.Text) message.SetPart(1, payload.Text)
s.messageCallback(message) s.messageCallback(message)
case SDSTransfer: case SDSTransfer:
log.Print("incoming SDS-TRANSFER") // log.Print("incoming SDS-TRANSFER")
return s.putSDSTransfer(part.Header, payload) return s.putSDSTransfer(part.Header, payload)
default: default:
return fmt.Errorf("unexpected message type %T", payload) return fmt.Errorf("unexpected message type %T", payload)

Loading…
Cancel
Save