Git Product home page Git Product logo

f1-22-udp's People

Contributors

primegoose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

f1-22-udp's Issues

Get own cars data

Hello!

I would like to ONLY get my own car data such as speed, RPM etc, and not the other cars. How would I approach this?

No data

I surely must be doing something wrong, but I can't see it... hoping for a bit of guidance!

I'm trying to run this, straight out of the sample. it's saved as f1.js and I'm starting it using "node f1.js" and it seems to start just fine and prints "started watching telemetry data" to the console, but that's it... nothing else. I've also tried specifying the port and IP address but that doesn't seem to make any difference either.

const { F122UDP } = require("f1-22-udp")
/*
*   'port' is optional, defaults to 20777
*   'address' is optional, defaults to localhost, in certain cases you may need to set address explicitly
*/

//const f122 = new F122UDP( { port: 20777 }, { address: '192.168.100.159'})

const f122 = new F122UDP()
f122.start();
// motion 0

console.log('started watching telemetry data');

f122.on('motion', function (data) {
    console.log(data);
})

f122.on("event", data => {
    console.log(data);
}) 

f122.on("carTelemetry", data => {
    console.log(data);
}) 

I've tried it with npx as well, so:

PS C:\git\f1-22-telemetry> npx f1-22-udp --log 1 2 3 4 5 6 7 8 9 10 11
using set of log args: Set(11) { '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' }
loging..

but nothing is written to console.

So I've tried a really basic example of a listener in javascript:

const dgram = require('dgram');
const server = dgram.createSocket('udp4');

server.on('error', (err) => {
    console.log(`Server error:\n${err.stack}`);
    server.close();
});
  
server.on('message', (msg, rinfo) => {
    console.log(`Server received: ${msg} from ${rinfo.address}:${rinfo.port}`);
});

server.on('listening', () => {
    const address = server.address();
    console.log(`Server listening ${address.address}:${address.port}`);
});
  
server.bind(20777); // Bind server to port 20777

and this works... whenever I'm driving the car, the console is filled with data. It's not stuff I can read though, I assume that's normal because I'm just outputting stuff without dealing with whatever encoding its in? Anyway, it proves that the game is sending data to the right IP/port and my PC is receiving it:
Server received: �m��v�C�X��A5�BUTNи\� from 192.168.100.184:55280

I'm not sure what's up with running the sample code though. It seems to be not receiving anything :\

Error: Cannot find module 'node:dgram'

Hi, love the work!

I have tried installing the f1 22 version and got the following error.

Error: Cannot find module 'node:dgram'
Require stack:

  • D:\sites\F1\f1-22\node_modules\f1-22-udp\build\src\F1_22_UDP.js
  • D:\sites\F1\f1-22\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object. (D:\sites\F1\f1-22\node_modules\f1-22-udp\build\src\F1_22_UDP.js:5:22)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    'D:\sites\F1\f1-22\node_modules\f1-22-udp\build\src\F1_22_UDP.js',
    'D:\sites\F1\f1-22\index.js'
    ]
    }

I am using the default code to just launch the listener.

const { F122UDP } = require("f1-22-udp")
/*
*   'port' is optional, defaults to 20777
*   'address' is optional, defaults to localhost, in certain cases you may need to set address explicitly
*/

const f122 = new F122UDP()
f122.start();
// motion 0
f122.on('motion', function (data) {
    console.log(data);
})

f122.on("event", data => {
    console.log(data);
}) 

Thanks for any help.

Kind Regards

Rob

LapData Event/Packet won't parse

Hey guys.

I have been using the UDP Library since last years game for a Discord RPC Client, and it worked like a charm back then.

This year, I also am using the UDP Library for the RPC Client of this years game, however, as I noticed, the LapData event is not entered when on-track during either a race or qualifying/practice sessions.

I am testing the entire app while I play and code at the same time to build the client, and as I ran a debugging session, I noticed that the execution of the code is halted during the time it reaches my instance of the parser with the LapData event specified, however, it simply won't enter at all.

The node version I am running is 14.15.3, NPM is running an older version, 7.19.0.

The code I have been using is essentially the same from the client app from last year, with just a little tweak to make place for the F2 game mode too.

The code I used for F1 2021:

f1Client.on("lapData",  (lData) => {
    lapNumber = lData.m_lapData[19].m_currentLapNum;
    console.log(lData);
});

The code I try to run for F1 22:

f1Client.on("lapData", (lData) => {
    if (formulaType === 2) { // F2 check
        lapNumber = lData.m_lapData[21].m_currentLapNum;
    } else {
        lapNumber = lData.m_lapData[19].m_currentLapNum;
    }
    console.log(lData);
});

If there is anything else I should provide or so, please let me know.
I liked how the Library worked last year, and it would be a bummer if something like this is suddenly not even fixable.

With regards
-EnKdev

Getting started

Hello,

I have just started to use your code. Unfortunately with limited experience in NodeJS.
My attempt to use the test script to output telemetry data to the console fails.

I've installed NodeJS 18.6 and NPM 8.13.2 on a Debian 11, installed with 'npm install f1-22-udp'. So i tried to start the example (node example.js) :

import { F122UDP } from "f1-22-udp";
/*
*   'port' is optional, defaults to 20777
*   'address' is optional, defaults to localhost
*/

const f122: F122UDP = new F122UDP();
f122.start();
// motion 0
client.on('motion',function(data) {
    console.log(data);
})

but getting the following error:

file:///opt/f1-22-udp/motion.js:7
const f122: F122UDP = new F122UDP();
      ^^^^

SyntaxError: Missing initializer in const declaration
    at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:483:14)
    at async link (node:internal/modules/esm/module_job:67:21)

Node.js v18.6.0

Thanks in advance.

The speed

I am making a RPC for discord with this and i wanted to ad a m_speed into it, but when i added it it was showing random numbers(i think it was speed of someone else) how do i get MINE speed?

Need advice on implementing in Node.js

Hi, since I am new to programming I keep pushing keys until it just works, here is how I did it on node.js for browser based overlays. It works, but I am worried I am doing it the wrong way because performance is bad and sometimes it's lagging.

So server side index.js looks like this:

//F1 UDP Setup
const { F122UDP } = require("f1-22-udp");
const f122 = new F122UDP()
f122.start();

// Socket setup
const io = socket(server);

io.on("connection", function (socket) {
    console.log("Made socket connection");

    f122.on('lapData', function (data) {
        socket.broadcast.emit("lapData", data);
    })

    f122.on('participants', function (data) {
        socket.broadcast.emit("participants", data);
    })
});

Client side, where the overlays are made with JS/HTML/CSS, tower.js looks like this:

const socket = io();

socket.on("participants", function (data) {
    console.log(data);
});
socket.on("lapData", function (data) {
    console.log(data)
});

This is just an example, imagine there are functions being called instead of console.log.
I need advice on what is the best way to get the telemetry data to client side that is shown in browser because using socket to "re-emit" data from f1-22-udp to client seems redundant and is probably what makes my application lagg. It gets worse when I add more listeners for different events (lapData, participants, session, carStatus...).

Not issues this is a Question/Suggestion/Request

HI, don't know if this is possible or not, i use the trhustmaster SF1000 wheel on xbox that use f1 2020 udp format only and since they don't provide update i would like to know if is possible to have f122 udp format and convert it to f1 2020 format so i can use a app that use f1 22 udp and forward to my wheel f1 2020 converted version

i don't know if big change have been made between f122 and f1 2020 version

so is it possible ? if so are you intesrested to make it ?

Thanks you sorry to post issue can't find a way to contact you

Issues with module declarations

Hello,
I'm currently trying to make a electron application, however there seems to be something wrong with some of the modules.

image

If I try to build I get 12 errors of the same sort, all looking similiar to this:

node_modules/f1-22-udp/build/src/F1_22_UDP.d.ts:13:40 - error TS2307: Cannot find module 'Participants/types' or its corresponding type declarations.

13 import { PacketParticipantsData } from 'Participants/types';

How can I resolve this issue?

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.