-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8aa85f
commit 6e98400
Showing
8 changed files
with
172 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
...require('gts/.prettierrc.json'), | ||
printWidth: 120 | ||
printWidth: 280 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Car Telemetry Packet | ||
|
||
This packet details telemetry for all the cars in the race. It details various values that would be recorded on the car such as speed, throttle application, DRS etc. Note that the rev light configurations are presented separately as well and will mimic real life driver preferences. | ||
|
||
Frequency: Rate as specified in menus | ||
Size: 1347 bytes | ||
Version: 1 | ||
|
||
struct CarTelemetryData | ||
{ | ||
uint16 m_speed; // Speed of car in kilometres per hour | ||
float m_throttle; // Amount of throttle applied (0.0 to 1.0) | ||
float m_steer; // Steering (-1.0 (full lock left) to 1.0 (full lock right)) | ||
float m_brake; // Amount of brake applied (0.0 to 1.0) | ||
uint8 m_clutch; // Amount of clutch applied (0 to 100) | ||
int8 m_gear; // Gear selected (1-8, N=0, R=-1) | ||
uint16 m_engineRPM; // Engine RPM | ||
uint8 m_drs; // 0 = off, 1 = on | ||
uint8 m_revLightsPercent; // Rev lights indicator (percentage) | ||
uint16 m_revLightsBitValue; // Rev lights (bit 0 = leftmost LED, bit 14 = rightmost LED) | ||
uint16 m_brakesTemperature[4]; // Brakes temperature (celsius) | ||
uint8 m_tyresSurfaceTemperature[4]; // Tyres surface temperature (celsius) | ||
uint8 m_tyresInnerTemperature[4]; // Tyres inner temperature (celsius) | ||
uint16 m_engineTemperature; // Engine temperature (celsius) | ||
float m_tyresPressure[4]; // Tyres pressure (PSI) | ||
uint8 m_surfaceType[4]; // Driving surface, see appendices | ||
}; | ||
|
||
struct PacketCarTelemetryData | ||
{ | ||
PacketHeader m_header; // Header | ||
|
||
CarTelemetryData m_carTelemetryData[22]; | ||
|
||
uint8 m_mfdPanelIndex; // Index of MFD panel open - 255 = MFD closed | ||
// Single player, race – 0 = Car setup, 1 = Pits | ||
// 2 = Damage, 3 = Engine, 4 = Temperatures | ||
// May vary depending on game mode | ||
uint8 m_mfdPanelIndexSecondaryPlayer; // See above | ||
int8 m_suggestedGear; // Suggested gear for the player (1-8) | ||
// 0 if no gear suggested | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import {Parser} from 'binary-parser'; | ||
import {F1Parser} from '../../f1.parser'; | ||
|
||
export class CarTelemetryDataParser extends F1Parser { | ||
constructor() { | ||
super(); | ||
this.uint16le('m_speed') | ||
.floatle('m_throttle') | ||
.floatle('m_steer') | ||
.floatle('m_brake') | ||
.uint8('m_clutch') | ||
.int8('m_gear') | ||
.uint16le('m_engineRPM') | ||
.uint8('m_drs') | ||
.uint8('m_revLightsPercent') | ||
.uint16le('m_revLightsBitValue') | ||
.array('m_brakesTemperature', { | ||
length: 4, | ||
type: new Parser().uint16le(''), | ||
}) | ||
.array('m_tyresSurfaceTemperature', { | ||
length: 4, | ||
type: new Parser().uint8(''), | ||
}) | ||
.array('m_tyresInnerTemperature', { | ||
length: 4, | ||
type: new Parser().uint8(''), | ||
}) | ||
.uint16le('m_engineTemperature') | ||
|
||
.array('m_tyresPressure', { | ||
length: 4, | ||
type: new Parser().floatle(''), | ||
}) | ||
.array('m_surfaceType', { | ||
length: 4, | ||
type: new Parser().uint8(''), | ||
}); | ||
} | ||
} | ||
|
||
import {PacketHeaderParser} from '../../PacketHeader/parser'; | ||
import {PacketCarTelemetryData} from '../types'; | ||
|
||
export class PacketCarTelemetryDataParser extends F1Parser { | ||
data: PacketCarTelemetryData; | ||
|
||
constructor(buffer: Buffer, bigintEnabled: boolean) { | ||
super(); | ||
|
||
this.endianess('little') | ||
.nest('m_header', { | ||
type: new PacketHeaderParser(bigintEnabled), | ||
}) | ||
|
||
.array('m_carTelemetryData', { | ||
length: 22, | ||
type: new CarTelemetryDataParser(), | ||
}) | ||
|
||
.uint8('m_mfdPanelIndex') | ||
.uint8('m_mfdPanelIndexSecondaryPlayer') | ||
.int8('m_suggestedGear'); | ||
|
||
this.data = this.fromBuffer(buffer) as PacketCarTelemetryData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {PacketHeader} from '@Type/PacketHeader'; | ||
|
||
export interface CarTelemetryData { | ||
/*uint16*/ m_speed: number; | ||
/*float*/ m_throttle: number; | ||
/*float*/ m_steer: number; | ||
/*float*/ m_brake: number; | ||
/*uint8*/ m_clutch: number; | ||
/*int8*/ m_gear: number; | ||
/*uint16*/ m_engineRPM: number; | ||
/*uint8*/ m_drs: number; | ||
/*uint8*/ m_revLightsPercent: number; | ||
/*uint16*/ m_revLightsBitValue: number; | ||
/*uint16*/ m_brakesTemperature: [number, number, number, number]; | ||
/*uint8*/ m_tyresSurfaceTemperature: [number, number, number, number]; | ||
/*uint8*/ m_tyresInnerTemperature: [number, number, number, number]; | ||
/*uint16*/ m_engineTemperature: number; | ||
/*float*/ m_tyresPressure: [number, number, number, number]; | ||
/*uint8*/ m_surfaceType: [number, number, number, number]; | ||
} | ||
|
||
export interface PacketCarTelemetryData { | ||
m_header: PacketHeader; | ||
m_buttonStatus: number; | ||
m_carTelemetryData: CarTelemetryData[]; | ||
m_mfdPanelIndex: number; | ||
m_mfdPanelIndexSecondaryPlayer: number; | ||
m_suggestedGear: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters