gpsd.go includes a mini-gpsd now.

This commit is contained in:
Torsten Harenberg
2025-02-16 17:22:54 +01:00
parent 0c543393d8
commit 561f597231
4 changed files with 429 additions and 14 deletions

17
main.go
View File

@@ -34,6 +34,8 @@ type TCPServer struct {
FromPactor *ByteFIFO
VARAMode bool
DaemonMode bool
GPSdMode bool
DeviceType string
Status uint8
Command struct {
Cmd *StringFIFO
@@ -43,15 +45,18 @@ type TCPServer struct {
Data *ByteFIFO
Response *ByteFIFO
}
GPSStream *StringFIFO // NMEA steam from PTC to gpsd server, see gpsd.go
}
func NewTCPServer(varamode bool, daemonmode bool) *TCPServer {
func NewTCPServer(varamode bool, daemonmode bool, gpsdmode bool) *TCPServer {
return &TCPServer{
Protocol: make(chan string, 1024),
ToPactor: NewByteFIFO(1024),
FromPactor: NewByteFIFO(1024),
VARAMode: varamode,
DaemonMode: daemonmode,
GPSdMode: gpsdmode,
DeviceType: "",
Status: 0,
Command: struct {
Cmd *StringFIFO
@@ -61,6 +66,7 @@ func NewTCPServer(varamode bool, daemonmode bool) *TCPServer {
Data *ByteFIFO
Response *ByteFIFO
}{Data: NewByteFIFO(10240), Response: NewByteFIFO(10240)},
GPSStream: NewStringFIFO(),
}
}
@@ -70,6 +76,7 @@ type Userconfig struct {
Mycall string `yaml:"mycall"`
ServerAddress string `yaml:"server_address"`
DataAddress string `yaml:"data_address"`
GPSdAddress string `yaml:"gpsd_address"`
CmdLineInit string `yaml:"cmdline_init"`
StartwithVaraMode bool `yaml:"vara_mode"`
}
@@ -86,6 +93,7 @@ func configmanage(Config *Userconfig, path string) error {
Mycall: "N0CALL",
ServerAddress: "127.0.0.1:8300",
DataAddress: "127.0.0.1:8301",
GPSdAddress: "",
CmdLineInit: "",
StartwithVaraMode: false}
@@ -150,7 +158,7 @@ func main() {
os.Exit(1)
}
s = NewTCPServer(Config.StartwithVaraMode, daemonMode)
s = NewTCPServer(Config.StartwithVaraMode, daemonMode, Config.GPSdAddress != "")
fmt.Println("Initializing PACTOR modem, please wait...")
m, err := OpenModem(Config.Device, Config.Baudrate, Config.Mycall, "", Config.CmdLineInit)
if err != nil {
@@ -161,6 +169,11 @@ func main() {
go tcpCmdServer(&Config)
go tcpDataServer(&Config)
if Config.GPSdAddress != "" {
go startGPSdTCPServer(Config.GPSdAddress)
go readAndBroadcast()
}
if !daemonMode {
// Initialize the gocui GUI
g, err := gocui.NewGui(gocui.OutputNormal)