Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No data #15

Closed
davelee212 opened this issue Nov 14, 2023 · 2 comments
Closed

No data #15

davelee212 opened this issue Nov 14, 2023 · 2 comments

Comments

@davelee212
Copy link

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 :\

Copy link

Please star this repository to motivate developers! ⭐

@davelee212
Copy link
Author

I was having a read through previous issues and had a look at the code that papiricoh suggested adding to support UDP broadcast data in the issue he raised about Implementation of Broadcast Packet Reception in F1 2022 UDP Parser.

Although I'm not using UDP broadcast (my playstation is configured with my laptop's wifi card adapter - and this is the only active NIC) changing

changing line 20 in F1_22_UDP.js from

const ADDRESS = 'localhost';

to

const ADDRESS = '0.0.0.0';

resolved the issue for me. I couldn't understand why, as I had tried passing 0.0.0.0 as the IP address to listen on in previous testing. It led me to look at little further into what I was doing and realised that I wasn't correctly passing the params for port and IP address in.

This works for me:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant