Page 132 of 133 FirstFirst ... 3282122130131132133 LastLast
Results 1,311 to 1,320 of 1322

Thread: [HowTo] Companion App - UDP Streaming

  1. #1311
    WMD Member cjorgens79's Avatar
    Join Date
    Apr 2012
    Location
    Perth
    Posts
    959
    Platform
    PC
    Quote Originally Posted by Killg0re NL View Post
    i am working on an Arduino ESP32 (WiFi) Solution for the PS4.

    i got ABS, TCS, ESP, Light, Track/Ambient/Engine-Temperature, Fuel Capacity and Gear working, but i can't seem to get grip on the fuelLevel, RPM and Speed.

    Are there any other players still working on Arduino and dashboard options?
    especially on a completer WiFi solution. (so NOT feeded through an Windows application)
    Fuel level is the ratio (0 - 1) fill of the tank, so just multiply with total fuel capacity.
    Speed is in meters per sec, so just multiply it out to km/h or mph
    RPM is just rpm, nothing to change with that. If you are getting weird values then check that you have all the prior fields mapped correctly and that your structure padding is correct.
    Motherboard: Asrock Z170-Extreme 4 Processor: Intel i7-6700K Memory: 16 GB Ripjaws 2133 MHz Video Card: MSI 980TI Gaming OS: Win10 x64 Storage: Samsung 850 EVO 256 GB SSD Wheel: Logitech G27 Other: Oculus Rift DK2, pCars Dash
    The following user likes this Post: Killg0re NL


  2. #1312
    Superkart Pilot Killg0re NL's Avatar
    Join Date
    Sep 2017
    Location
    Netherlands
    Posts
    173
    Platform
    PS4 Pro
    Quote Originally Posted by cjorgens79 View Post
    Fuel level is the ratio (0 - 1) fill of the tank, so just multiply with total fuel capacity.
    i'll start with this one...

    Quote Originally Posted by cjorgens79 View Post
    If you are getting weird values then check that you have all the prior fields mapped correctly and that your structure padding is correct.
    But this seems to be the main problem, cause, i get 89L as a capacity, (packetbuffer 111)

    float FuelLevel; // 13 // 116
    The amount of fuel should be in packetbuffer 116, so displaying this should get me a value ranging from 0 to 1 so:
    But i get value's from 0 to 220

    FuelLevel = (bitRead(packetBuffer[116], 0)) * (FuelCapacity);
    should have gotten me the actual fuel Level.

    But it seems my knowledge stops here....

    And whats with the different FuelLevels? such as:

    packetBuffer[116]; // FuelLevel 1st
    packetBuffer[117]; // FuelLevel 2nd
    packetBuffer[118]; // FuelLevel 3rd
    packetBuffer[119]; // FuelLevel 4th
    Last edited by Killg0re NL; 28-12-2018 at 13:00.

  3. #1313
    WMD Member cjorgens79's Avatar
    Join Date
    Apr 2012
    Location
    Perth
    Posts
    959
    Platform
    PC
    Quote Originally Posted by Killg0re NL View Post
    But this seems to be the main problem, cause, i get 89L as a capacity, (packetbuffer 111)

    The amount of fuel should be in packetbuffer 116, so displaying this should get me a value ranging from 0 to 1 so:
    But i get value's from 0 to 220

    should have gotten me the actual fuel Level.

    But it seems my knowledge stops here....

    And whats with the different FuelLevels? such as:
    89L sounds right, that is an 8 bit value so you cant really go wrong reading that one.
    Fuel level is a FLOAT (which is 32 bit, hence 4 bytes), so you need to actually read it as a float. Your language should have a function to read as float and that will give you the value you expect. You will get a floating point value between 0 and 1 and everything in between (eg 0.3345) would be a valid result.
    Motherboard: Asrock Z170-Extreme 4 Processor: Intel i7-6700K Memory: 16 GB Ripjaws 2133 MHz Video Card: MSI 980TI Gaming OS: Win10 x64 Storage: Samsung 850 EVO 256 GB SSD Wheel: Logitech G27 Other: Oculus Rift DK2, pCars Dash

  4. #1314
    Superkart Pilot Killg0re NL's Avatar
    Join Date
    Sep 2017
    Location
    Netherlands
    Posts
    173
    Platform
    PS4 Pro
    FuelLevel = (bitRead(packetBuffer[116], 0) << 24 | bitRead(packetBuffer[117], 0) & 0xff << 16 | bitRead(packetBuffer[118], 0) & 0xff << 8 | bitRead(packetBuffer[119], 0) & 0xff << 0);
    Serial.print("Fuel level : "); Serial.print(FuelLevel); Serial.print(" / "); Serial.print(FuelCapacity); Serial.println(" L "); Serial.println(" ");
    Still stuck at this... grrr any one got a clue what i am missing here?
    Thought when i get one float, setting working, it opens the road to other data, but the road remains closed for now...

    ps, with this code i am expecting a value ranging from 0 to 1. (so not multiplied by the fuelcapacity yet)

    Is there a way i can check if the packetbuffers are ok?

    ie. when i put in 10 Litres of fuel what should i expect on the 1, 2, 3 and 4th fuel Byte? :
    Serial.print("Packetbuffer 116: "); Serial.println(packetBuffer[116]);
    Serial.print("Packetbuffer 117: "); Serial.println(packetBuffer[117]);
    Serial.print("Packetbuffer 118: "); Serial.println(packetBuffer[118]);
    Serial.print("Packetbuffer 119: "); Serial.println(packetBuffer[119]);
    Last edited by Killg0re NL; 01-01-2019 at 19:44. Reason: typo

  5. #1315
    WMD Member cjorgens79's Avatar
    Join Date
    Apr 2012
    Location
    Perth
    Posts
    959
    Platform
    PC
    Quote Originally Posted by Killg0re NL View Post
    Still stuck at this... grrr any one got a clue what i am missing here?
    Thought when i get one float, setting working, it opens the road to other data, but the road remains closed for now...

    ps, with this code i am expecting a value ranging from 0 to 1. (so not multiplied by the fuelcapacity yet)

    Is there a way i can check if the packetbuffers are ok?

    ie. when i put in 10 Litres of fuel what should i expect on the 1, 2, 3 and 4th fuel Byte? :
    Your issue is that you still aren't reading it as a float. What you have shown in your example is reading it as an int32 which is not the same as a float (which is also 32 bit). If the language you are using does not have specific readers for float values (or sometimes called Single), then it is possible to extract out each byte (like you have attempted) and convert it to a float. The 32 bits contain a sign, exponent and mantissa that need to be decoded into the resulting float value. https://blog.penjee.com/binary-numbe...nt-conversion/

    Most languages will have the ability to directly read data from a byte stream/buffer as a float, int32, etc as required, so its possibly there is an easy way for you to do it if you use the right functions in whatever language it is you are using.
    Motherboard: Asrock Z170-Extreme 4 Processor: Intel i7-6700K Memory: 16 GB Ripjaws 2133 MHz Video Card: MSI 980TI Gaming OS: Win10 x64 Storage: Samsung 850 EVO 256 GB SSD Wheel: Logitech G27 Other: Oculus Rift DK2, pCars Dash
    The following 2 users likes this Post: Killg0re NL, Maskmagog


  6. #1316
    Superkart Pilot Killg0re NL's Avatar
    Join Date
    Sep 2017
    Location
    Netherlands
    Posts
    173
    Platform
    PS4 Pro
    Sorted in the mean time:

    I got the Corvette C7R as a car
    FuelCapacity is 89L, and i got 40L in the tuning setup.
    After starting the practise session i turned the engine of. (the ingame fuellevel is 40L)

    This is what i get from serial printing the next:
    Code:
    Fuel level (FL)       : 111110111001100001011001010110
    Fuel level            : 40.00
    119         : 111110
    118         : 11100110
    117         : 10110
    116         : 1010110

    This is the used code for reading the packets 119, 118, 117 and 116:
    Code:
    uint32_t FL=0;
    for (uint8_t i=119; i>115; i--) {
      FL=FL<<8;
      FL=FL+packetBuffer[i]; 
    }
      FuelLevel = FL;
      memcpy(&FuelLevel, &FL, 4);
      FuelLevel = FuelLevel * FuelCapacity;
    The FuelLevel is declared as:
    Code:
    float FuelLevel;                     // 13  // 116
    Last edited by Killg0re NL; 10-01-2019 at 18:48. Reason: Got the fuel level sorted
    The following user likes this Post: Maskmagog


  7. #1317
    WMD Member cjorgens79's Avatar
    Join Date
    Apr 2012
    Location
    Perth
    Posts
    959
    Platform
    PC
    Quote Originally Posted by Killg0re NL View Post
    Sorted in the mean time:

    I got the Corvette C7R as a car
    FuelCapacity is 89L, and i got 40L in the tuning setup.
    After starting the practise session i turned the engine of. (the ingame fuellevel is 40L)

    This is what i get from serial printing the next:
    Code:
    Fuel level (FL)       : 111110111001100001011001010110
    Fuel level            : 40.00
    119         : 111110
    118         : 11100110
    117         : 10110
    116         : 1010110

    This is the used code for reading the packets 119, 118, 117 and 116:
    Code:
    uint32_t FL=0;
    for (uint8_t i=119; i>115; i--) {
      FL=FL<<8;
      FL=FL+packetBuffer[i]; 
    }
      FuelLevel = FL;
      memcpy(&FuelLevel, &FL, 4);
      FuelLevel = FuelLevel * FuelCapacity;
    The FuelLevel is declared as:
    Code:
    float FuelLevel;                     // 13  // 116
    That is certainly a novel way of converting to a float. Glad to hear you got it sorted.
    Motherboard: Asrock Z170-Extreme 4 Processor: Intel i7-6700K Memory: 16 GB Ripjaws 2133 MHz Video Card: MSI 980TI Gaming OS: Win10 x64 Storage: Samsung 850 EVO 256 GB SSD Wheel: Logitech G27 Other: Oculus Rift DK2, pCars Dash

  8. #1318
    Superkart Pilot Maskmagog's Avatar
    Join Date
    Sep 2017
    Location
    Sweden
    Posts
    742
    Platform
    XBOX1 X

    How to get sTrackLength?

    I'm trying to get my console leaderboard project (see signature) to use UDP v1 as well as UDP 2.
    I'm getting almost every data I need, except for sTrackLength. I need sTrackLength to tell a few tracks apart, because of bugs in the UDP (same in v2).

    It seems TrackLength was moved around during development, and it's hard to know what the correct place for it is. Right now, my code looks like this, at the end of Telemetry packet:

    Code:
                AmbientTemperature = binaryReader.ReadSByte();
                TrackTemperature = binaryReader.ReadSByte();
                RainDensity = binaryReader.ReadByte();
                WindSpeed = binaryReader.ReadSByte();
                WindDirectionX = binaryReader.ReadSByte();
                WindDirectionY = binaryReader.ReadSByte();
    
                for (int i = 0; i < 16; i++)
                {
                    ParticipantInfo[i, 0] = Convert.ToDouble(binaryReader.ReadInt16());  //WorldPosition 
                    ParticipantInfo[i, 1] = Convert.ToDouble(binaryReader.ReadInt16());  //WorldPosition
                    ParticipantInfo[i, 2] = Convert.ToDouble(binaryReader.ReadInt16());  //WorldPosition
                    ParticipantInfo[i, 3] = Convert.ToDouble(binaryReader.ReadUInt16());  //sCurrentLapDistance
                    ParticipantInfo[i, 4] = Convert.ToDouble(binaryReader.ReadByte()) - 128;  //sRacePosition
                    ParticipantInfo[i, 5] = Convert.ToDouble(binaryReader.ReadByte());  //sLapsCompleted
                    ParticipantInfo[i, 6] = Convert.ToDouble(binaryReader.ReadByte());  //sCurrentLap
                    byte Sector_ALL = binaryReader.ReadByte();
                    var Sector_Extracted = Sector_ALL & 7;
    		ParticipantInfo[i, 7] = Convert.ToDouble(Sector_Extracted);   //sSector
                    ParticipantInfo[i, 8] = Convert.ToDouble(binaryReader.ReadSingle());  //sLastSectorTime
                }
    
    
                TrackLength = binaryReader.ReadSingle();
                //Console.WriteLine("Tracklength from PCarsUDP: " + TrackLength);
                Wings[0] = binaryReader.ReadByte();
                Wings[1] = binaryReader.ReadByte();
                DPad = binaryReader.ReadByte();
    I haven't tried all data, but for example sAmbientTemperature, sSector and sLastSectorTime works. At least for player index = 0, which is all I use.
    Getting crazy, so any help is much appreciated!


    EDIT: I'm using it to read data from Xbox, if that matters.
    Last edited by Maskmagog; 22-01-2019 at 15:33. Reason: Added info about xbox
    Thrustmaster TX, Ferrari 599XX Alcantara rim, T3PA-Pro, Firmware 54, Xbox One X, public OS, 28" 4K monitor
    Don't miss Yorkie065's excellent videos: Ep26-LiveTrack pt1. Ep 27-LiveTrack pt2.
    Project CALC - cross-platform PC2 leaderboards per car - Xbox/PS4/PC - Forum thread

  9. #1319
    Superkart Pilot Maskmagog's Avatar
    Join Date
    Sep 2017
    Location
    Sweden
    Posts
    742
    Platform
    XBOX1 X
    Finally seem to have figured it out. Should use 56 instead of 16 in the for-loop above.
    Thrustmaster TX, Ferrari 599XX Alcantara rim, T3PA-Pro, Firmware 54, Xbox One X, public OS, 28" 4K monitor
    Don't miss Yorkie065's excellent videos: Ep26-LiveTrack pt1. Ep 27-LiveTrack pt2.
    Project CALC - cross-platform PC2 leaderboards per car - Xbox/PS4/PC - Forum thread

  10. #1320
    Superkart Pilot Killg0re NL's Avatar
    Join Date
    Sep 2017
    Location
    Netherlands
    Posts
    173
    Platform
    PS4 Pro
    Quote Originally Posted by Killg0re NL View Post
    This is the used code for reading the packets 119, 118, 117 and 116:
    Code:
    uint32_t FL=0;
    for (uint8_t i=119; i>115; i--) {
      FL=FL<<8;
      FL=FL+packetBuffer[i]; 
    }
      FuelLevel = FL;
      memcpy(&FuelLevel, &FL, 4);
      FuelLevel = FuelLevel * FuelCapacity;
    The FuelLevel is declared as:
    Code:
    float FuelLevel;                     // 13  // 116
    Any idea why this only works when the protocol is on Project Cars 1, on the UPD protocol Project Cars 2, it doesn't work

    for the record, i got the packet who is used in PC2 32-35 (instead off 115-118)
    Code:
    uint32_t FL=0;
    for (uint8_t i=36; i>32; i--) {
      FL=FL<<8;
      FL=FL+packetBuffer[i]; 
    }
      FuelLevel = FL;
      memcpy(&FuelLevel, &FL, 4);
      FuelLevel = FuelLevel * FuelCapacity;

    And 2nd question, i use carFlags awell:
    Code:
    // (Type#9) Car Flags (to be used with 'mCarFlags')
    enum
    {
      CAR_HEADLIGHT         = (1<<0),
      CAR_ENGINE_ACTIVE     = (1<<1),
      CAR_ENGINE_WARNING    = (1<<2),
      CAR_SPEED_LIMITER     = (1<<3),
      CAR_ABS               = (1<<4),
      CAR_HANDBRAKE         = (1<<5),
      CAR_STABILITY	        = (1<<6),
      CAR_TRACTION_CONTROL	= (1<<7),
    };
    But with UDP on project Cars 2, TCS (Bit 7) isn't working either ?? what am i missing here???

Similar Threads

  1. Game Companion 2.4
    By N0body Of The Goat in forum PC - Technical Help & Support
    Replies: 0
    Last Post: 06-11-2015, 08:17
  2. [complete] The Complete Career Track/Session List
    By Kingdeuce86 in forum Project CARS on Playstation 4
    Replies: 6
    Last Post: 02-10-2015, 12:12
  3. [APPROVED BY MS] Companion App
    By inthebagbud in forum Project CARS on Xbox One
    Replies: 87
    Last Post: 30-09-2015, 10:20
  4. Headset Companion App settings
    By Equation in forum Project CARS on Playstation 4
    Replies: 14
    Last Post: 14-07-2015, 04:19
  5. there needs to be a iOS/Android/WP companion app for Project cars
    By madmax2069 in forum Feature Suggestions
    Replies: 5
    Last Post: 15-06-2015, 03:33

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •