2 Commits
Author SHA1 Message Date
esilva 0d0567c070 rename project 2026-07-08 22:54:56 +01:00
esilva f569f46499 Bump the BeamNG SDK and report the title for the window 2026-07-06 23:42:08 +01:00
9 changed files with 19 additions and 12 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ import (
// rootCmd represents the base command when called without any subcommands // rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "bngmock", Use: "telemetrymockserver",
Short: "CLI for a BeamNG OG mockserver", Short: "CLI for mocking and recording data from different sources. Primarily for simracing",
Long: ``, Long: ``,
} }
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/ESilva15/BeamNGMockOg/mockserver" "github.com/ESilva15/TelemetryMockserver/mockserver"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/ESilva15/BeamNGMockOg/mockserver" "github.com/ESilva15/TelemetryMockserver/mockserver"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
+2 -2
View File
@@ -1,9 +1,9 @@
module github.com/ESilva15/BeamNGMockOg module github.com/ESilva15/TelemetryMockserver
go 1.23.2 go 1.23.2
require ( require (
github.com/ESilva15/gobngsdk v1.1.1 github.com/ESilva15/gobngsdk v1.1.3
github.com/spf13/cobra v1.10.1 github.com/spf13/cobra v1.10.1
) )
+2 -2
View File
@@ -1,5 +1,5 @@
github.com/ESilva15/gobngsdk v1.1.1 h1:MyKUjIqG77lYcUY6cnZpnnxPoxS/FdAYwGoi6InXan0= github.com/ESilva15/gobngsdk v1.1.3 h1:CFaz2KjHKnBLrQuEN1QHOd1761cWM/rmTwLpSLrgbe4=
github.com/ESilva15/gobngsdk v1.1.1/go.mod h1:cKLaZRgM0tGGXDvosaSjHnxeyC5Y6rg7zCLqEUJnOzw= github.com/ESilva15/gobngsdk v1.1.3/go.mod h1:cKLaZRgM0tGGXDvosaSjHnxeyC5Y6rg7zCLqEUJnOzw=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+1 -1
View File
@@ -1,6 +1,6 @@
package main package main
import "github.com/ESilva15/BeamNGMockOg/cmd" import "github.com/ESilva15/TelemetryMockserver/cmd"
func main() { func main() {
cmd.Execute() cmd.Execute()
+3
View File
@@ -89,6 +89,9 @@ func (r *Recorder) view(ctx context.Context) {
case viewData := <-r.viewCh: case viewData := <-r.viewCh:
buf.Reset() buf.Reset()
buf.WriteString("\x1b[2J\x1b[H") buf.WriteString("\x1b[2J\x1b[H")
fmt.Fprintf(&buf, "\x1b]0;%s - Recording ", ProgramName)
stringifyRecordingProgress(&buf, nBytes)
fmt.Fprintf(&buf, "\x07")
stringifyRecordingProgress(&buf, nBytes) stringifyRecordingProgress(&buf, nBytes)
fmt.Fprintf(&buf, "\n\n") fmt.Fprintf(&buf, "\n\n")
+5 -3
View File
@@ -48,7 +48,7 @@ func NewReplayer(address string, port int, fp string) (*Replayer, error) {
replayer := &Replayer{ replayer := &Replayer{
DataSourcePath: fp, DataSourcePath: fp,
SDK: bngsdk.BeamNGSDK{ SDK: bngsdk.BeamNGSDK{
Data: &bngsdk.Outgauge{}, Data: bngsdk.Outgauge{},
Buffer: make([]byte, unsafe.Sizeof(bngsdk.Outgauge{})), Buffer: make([]byte, unsafe.Sizeof(bngsdk.Outgauge{})),
}, },
Socket: udp, Socket: udp,
@@ -79,18 +79,20 @@ func (r *Replayer) renderToTerminal(ctx context.Context) {
return return
case data := <-r.dataViewCh: case data := <-r.dataViewCh:
// Reset to the start of the terminal // Reset to the start of the terminal
percent := int(float64(data.SizeRead) / float64(fileInfo.Size()) * 100)
buf.Reset() buf.Reset()
buf.WriteString("\x1b[2J\x1b[H") buf.WriteString("\x1b[2J\x1b[H")
fmt.Fprintf(&buf, "\x1b]0;%s - Replaying %d%%\x07", ProgramName, percent)
bytesReader.Reset(data.SDK.Buffer) bytesReader.Reset(data.SDK.Buffer)
err := binary.Read(&bytesReader, binary.LittleEndian, r.SDK.Data) err := binary.Read(&bytesReader, binary.LittleEndian, &r.SDK.Data)
if err != nil { if err != nil {
fmt.Fprintf(&buf, "FAILED TO PARSE DATA\nError: %+v", err) fmt.Fprintf(&buf, "FAILED TO PARSE DATA\nError: %+v", err)
_, _ = buf.WriteTo(os.Stdout) _, _ = buf.WriteTo(os.Stdout)
continue continue
} }
percent := int(float64(data.SizeRead) / float64(fileInfo.Size()) * 100)
fmt.Fprintf(&buf, "Replayed: %d%%\n", percent) fmt.Fprintf(&buf, "Replayed: %d%%\n", percent)
stringifyOutgaugeData(&buf, data.SDK) stringifyOutgaugeData(&buf, data.SDK)
+2
View File
@@ -5,6 +5,8 @@ import (
"net" "net"
) )
const ProgramName = "TelemetryMockerserver"
type Transport interface { type Transport interface {
Send(data []byte) error Send(data []byte) error
Close() error Close() error