updated README, avoid gooutinges for TCP handling, force disconnects when client is gone.

This commit is contained in:
Torsten Harenberg
2025-10-26 17:49:59 +01:00
parent 4ed3ce9b10
commit fb72775735
3 changed files with 19 additions and 14 deletions

15
ptc.go
View File

@@ -7,9 +7,6 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/TwiN/go-color"
"github.com/albenik/go-serial/v2"
"github.com/augustoroman/hexdump"
"log"
"math"
"math/bits"
@@ -22,6 +19,10 @@ import (
"sync"
"time"
"github.com/TwiN/go-color"
"github.com/albenik/go-serial/v2"
"github.com/augustoroman/hexdump"
"github.com/howeyc/crc16"
)
@@ -320,7 +321,7 @@ func (p *Modem) modemThread() {
time.Sleep(time.Second)
const chunkSize = 1024
p.wg.Add(1)
for !p.flags.stopmodem {
for !(p.flags.stopmodem && s.Command.Cmd.GetLen() == 0) {
// TX data
if p.getNumFramesNotTransmitted() < MaxFrameNotTX {
@@ -358,7 +359,7 @@ func (p *Modem) modemThread() {
s.Command.Response.Enqueue(ans[2:])
}
}
writeDebug("Answer from modem: "+ans, 1)
writeDebug("Answer from modem: "+hex.EncodeToString([]byte(ans)), 1)
// TODO: Catch errors!
}
@@ -914,7 +915,9 @@ func (p *Modem) read(readsize int) (int, []byte, error) {
writeDebug("ERROR in ReadyToRead: "+err.Error(), 3)
} else {
chunkSize = int(t)
writeDebug(fmt.Sprintf("chunksize: %d", chunkSize), 3)
if chunkSize > 0 {
writeDebug(fmt.Sprintf("chunksize: %d", chunkSize), 3)
}
}
} else {
chunkSize = readsize