xplane output: make it more similar to real simulator - no linefeed at end of message, one message per packet, to work around SkyDemons buggy implementation (and maybe others?)

pull/827/merge^2
Adrian Batzill 2023-06-28 09:39:52 +02:00
rodzic a54aaeebf5
commit 93b0fb7b01
2 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -93,6 +93,10 @@ func (conn *networkConnection) Capabilities() uint8 {
}
func (conn *networkConnection) GetDesiredPacketSize() int {
if conn.Capabilities() & (NETWORK_POSITION_FFSIM | NETWORK_AHRS_FFSIM) > 0 {
// Hack: some software doesn't handle X-Plane as a stream correctly, e.g. SkyDemon, and requires each message in a separate packet, or it will crash.
return 1
}
return 1024
}

Wyświetl plik

@ -20,13 +20,13 @@ func convertKnotsToXPlaneSpeed(knots float32) float32 {
func createXPlaneGpsMsg(latDeg float32, lonDeg float32, altMslFt float32, trackDeg float32, speedKt float32) []byte {
// example: XGPS1,-122.298432,47.450756,420.9961,349.7547,57.9145
return []byte(fmt.Sprintf("XGPS1,%.6f,%.6f,%.4f,%.4f,%.4f\n", lonDeg, latDeg, convertFeetToMeters(altMslFt), trackDeg, convertKnotsToXPlaneSpeed(speedKt)))
return []byte(fmt.Sprintf("XGPS1,%.6f,%.6f,%.4f,%.4f,%.4f", lonDeg, latDeg, convertFeetToMeters(altMslFt), trackDeg, convertKnotsToXPlaneSpeed(speedKt)))
}
func createXPlaneAttitudeMsg(headingDeg float32, pitchDeg float32, rollDeg float32) []byte {
// example: XATT1,345.1,-1.1,-12.5,0.1374,0.0954,-0.0444,-17.0,-1.2,-65.0,-0.01,1.63,0.02
// TODO find out what the remaining parameters are for
return []byte(fmt.Sprintf("XATT1,%.1f,%.1f,%.1f,%.4f,%.4f,%.4f,%.1f,%.1f,%.1f,%.2f,%.2f,%.2f\n", headingDeg, pitchDeg, rollDeg, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0))
return []byte(fmt.Sprintf("XATT1,%.1f,%.1f,%.1f,%.4f,%.4f,%.4f,%.1f,%.1f,%.1f,%.2f,%.2f,%.2f", headingDeg, pitchDeg, rollDeg, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0))
}
func createXPlaneTrafficMsg(targetId uint32, latDeg float32, lonDeg float32, altFt int32, hSpeedKt uint32, vSpeedFpm int32, onGround bool, trackDeg uint32, callSign string) []byte {
@ -44,5 +44,5 @@ func createXPlaneTrafficMsg(targetId uint32, latDeg float32, lonDeg float32, alt
regEx, _ := regexp.Compile("[^a-zA-Z0-9]+")
cleanCallSign := regEx.ReplaceAllString(callSign, "")
return []byte(fmt.Sprintf("XTRA1,%d,%.6f,%.6f,%d,%d,%d,%d,%d,%s\n", targetId, latDeg, lonDeg, altFt, vSpeedFpm, airborneValue, trackDeg, hSpeedKt, cleanCallSign))
return []byte(fmt.Sprintf("XTRA1,%d,%.6f,%.6f,%d,%d,%d,%d,%d,%s", targetId, latDeg, lonDeg, altFt, vSpeedFpm, airborneValue, trackDeg, hSpeedKt, cleanCallSign))
}