TRX control through the modem using rigctl
This commit is contained in:
40
ptc.go
40
ptc.go
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/TwiN/go-color"
|
||||
"github.com/albenik/go-serial/v2"
|
||||
"github.com/augustoroman/hexdump"
|
||||
"log"
|
||||
"math"
|
||||
"math/bits"
|
||||
@@ -75,11 +76,12 @@ type Modem struct {
|
||||
}
|
||||
|
||||
const (
|
||||
SerialTimeout = 1
|
||||
PactorChannel = 4
|
||||
NMEAChannel = 249
|
||||
MaxSendData = 255
|
||||
MaxFrameNotTX = 2
|
||||
SerialTimeout = 1
|
||||
PactorChannel = 4
|
||||
NMEAChannel = 249
|
||||
TRXControlChannel = 253
|
||||
MaxSendData = 255
|
||||
MaxFrameNotTX = 2
|
||||
)
|
||||
|
||||
// ToPactor states
|
||||
@@ -226,7 +228,9 @@ func (p *Modem) init() (err error) {
|
||||
}
|
||||
writeDebug("Found a "+modem+" modem at "+p.devicePath, 0)
|
||||
s.DeviceType = modem
|
||||
|
||||
writeDebug("Running init commands", 1)
|
||||
|
||||
ct := time.Now()
|
||||
commands := []string{"DD", "RESTART", "MYcall " + p.localAddr, "PTCH " + strconv.Itoa(PactorChannel),
|
||||
"MAXE 35", "REM 0", "CHOB 0", "PD 1",
|
||||
@@ -353,6 +357,22 @@ func (p *Modem) modemThread() {
|
||||
// TODO: Catch errors!
|
||||
}
|
||||
|
||||
// TX TRX control data
|
||||
|
||||
trxcmd, err := s.ToTRX.Dequeue(1024)
|
||||
if err == nil {
|
||||
writeDebug("Write TRX command ("+strconv.Itoa(len(trxcmd))+"): "+hexdump.Dump(trxcmd), 1)
|
||||
_, _, err := p.writeAndGetResponse(string(trxcmd), TRXControlChannel, false, chunkSize)
|
||||
if err != nil {
|
||||
writeDebug("Error when sending TRX Command: "+err.Error(), 0)
|
||||
}
|
||||
/*if len(ans) > 2 {
|
||||
s.FromTRX.Enqueue([]byte(ans[2:]))
|
||||
}*/
|
||||
//s.FromTRX.Enqueue([]byte(ans))
|
||||
//writeDebug("TRX CMD answer from modem: \n"+hexdump.Dump([]byte(ans)), 1)
|
||||
}
|
||||
|
||||
// RX
|
||||
var res []byte
|
||||
|
||||
@@ -371,6 +391,11 @@ func (p *Modem) modemThread() {
|
||||
case 254: //Status update
|
||||
p.chanbusy = int(res[0])&112 == 112 // See PTC-IIIusb manual "STATUS" command
|
||||
writeDebug("PACTOR state: "+strconv.FormatInt(int64(res[0]), 2), 2)
|
||||
case TRXControlChannel:
|
||||
//if !bytes.Equal(res, trxcmd) {
|
||||
s.FromTRX.Enqueue(res)
|
||||
writeDebug("TRX CMD answer:\n"+hexdump.Dump(res), 1)
|
||||
//}
|
||||
default:
|
||||
writeDebug("Channel "+strconv.Itoa(c)+": "+string(res), 1)
|
||||
}
|
||||
@@ -571,6 +596,11 @@ func (p *Modem) checkResponse(resp string, ch int) (n int, data []byte, err erro
|
||||
s.GPSStream.Enqueue("$" + string(bytes.Trim(payload, "\x00"))) //need to remove the trailing NULL byte
|
||||
}
|
||||
}
|
||||
/* if ch == TRXControlChannel {
|
||||
writeDebug("TRX Control channel message: "+string(payload), 1)
|
||||
s.FromTRX.Enqueue(payload)
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
if int(head[1]) == 2 {
|
||||
|
Reference in New Issue
Block a user