“I want to get the telemetry data from the F1 2023 game for which I am using the package @racehub-io/f1-telemetry-client to get these. But there’s nothing showing in the console.”
const { F1TelemetryClient, constants } = require('f1-telemetry-client');
const { PACKETS } = constants;
/*
* 'port' is optional, defaults to 20777
* 'bigintEnabled' is optional, setting it to false makes the parser skip bigint values,
* defaults to true
* 'forwardAddresses' is optional, it's an array of Address objects to forward unparsed telemetry to. each address object is comprised of a port and an optional ip address
* defaults to undefined
* 'skipParsing' is optional, setting it to true will make the client not parse and emit content. You can consume telemetry data using forwardAddresses instead.
* defaults to false
*/
const client = new F1TelemetryClient({ port: 20777 });
client.on(PACKETS.event, (data) => {
console.log("Event-Daten empfangen");
try {
console.log(data);
} catch (error) {
console.error("Fehler beim Verarbeiten der Daten: ", error);
}
});
client.on(PACKETS.motion, console.log);
client.on(PACKETS.carSetups, console.log);
client.on(PACKETS.lapData, console.log);
client.on(PACKETS.session, console.log);
client.on(PACKETS.participants, console.log);
client.on(PACKETS.carTelemetry, console.log);
client.on(PACKETS.carStatus, console.log);
client.on(PACKETS.finalClassification, console.log);
client.on(PACKETS.lobbyInfo, console.log);
client.on(PACKETS.carDamage, console.log);
client.on(PACKETS.sessionHistory, console.log);
client.on(PACKETS.tyreSets, console.log);
// to start listening:
client.start();