You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
})
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 :\
The text was updated successfully, but these errors were encountered:
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'})
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.
I've tried it with npx as well, so:
but nothing is written to console.
So I've tried a really basic example of a listener in javascript:
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 :\
The text was updated successfully, but these errors were encountered: