diff --git a/bngsdk.go b/bngsdk.go index 53fc560..01322fe 100644 --- a/bngsdk.go +++ b/bngsdk.go @@ -1,3 +1,5 @@ +// Package bngsdk defines an API to interact with the BeamNG outgauge data in +// Go package bngsdk import ( @@ -8,8 +10,10 @@ import ( ) const ( - UDP_IP = "127.0.0.1" - UDP_PORT = 4444 + // UDPIP is the IP of the UDP outgauge server + UDPIP = "127.0.0.1" + // UDPPort is the port of the UDP outgauge server + UDPPort = 4444 ) type BNGSDK struct { @@ -17,7 +21,7 @@ type BNGSDK struct { Conn *net.UDPConn Buffer []byte Data *Outgauge - DataDict map[string]interface{} + DataDict map[string]any } func createUDPConnection(ip string, port int) (*net.UDPConn, *net.UDPAddr, error) { @@ -66,7 +70,7 @@ func (sdk *BNGSDK) ReadData() error { } func (sdk *BNGSDK) Close() { - sdk.Conn.Close() + _ = sdk.Conn.Close() } // Init initializes a BeamNG SDK struct diff --git a/outgauge.go b/outgauge.go index 5d2c00f..1a15ca3 100644 --- a/outgauge.go +++ b/outgauge.go @@ -1,11 +1,13 @@ package bngsdk +// More documentation at https://go.beamng.com/protocols. + /* TODO - OG_x Flags - DL_x Flags */ -// More documentation at https://go.beamng.com/protocols +// Outgauge describes the data served by the BeamNG outgauge server type Outgauge struct { Time uint32 // time in milliseconds (to check order) Car [4]byte // Car name @@ -29,8 +31,9 @@ type Outgauge struct { ID int32 // optional - only if OutGauge ID is specified } -func (o *Outgauge) ToMap() map[string]interface{} { - return map[string]interface{}{ +// ToMap creates a map with the data in the Outgauge struct +func (o *Outgauge) ToMap() map[string]any { + return map[string]any{ "Time": o.Time, // time in milliseconds (to check order) "Car": o.Car, // Car name "Flags": o.Flags, // Info (see OG_x below)