Well, I still have problems with the ShowLights. There are not doing what the game itself does. For Example, when I pull the handbrake during driving, 3 or 4 flags goes on. A really curios behaviour .
Well, I going to bed and think about it. Tomorrow I going to check my code and read books about 4 Byte bit operations. I guess, there I have a understanding problem .
I try to write a C-program to get the LFS-UDP-Packets of LFS to put them to my UART Interface.
All variables like Gear or Brake etc. works fine. I got them from the packet per 'memcpy' and I print there out to console.
But the "dash lights lamps" are always 'on' immaterial what I do (see attachment picture and source code).
I try to make a simple bit operations for each flags.
I mean, bit operations are quite simple like ( x & 1). That's it but it doesn't work.
Could you tell me, where is my mistake? Thanks in advance.
Here is my source code:
typedef struct OutGaugePack { unsigned Time; // time in milliseconds (to check order) char Car[4]; // Car name WORD Flags; // Info (see OG_x below) byte Gear; // Reverse:0, Neutral:1, First:2... byte SpareB; float Speed; // M/S float RPM; // RPM float Turbo; // BAR float EngTemp; // C float Fuel; // 0 to 1 float OilPressure; // BAR float OilTemp; // C unsigned DashLights; // Dash lights available (see DL_x below) unsigned ShowLights; // Dash lights currently switched on float Throttle; // 0 to 1 float Brake; // 0 to 1 float Clutch; // 0 to 1 char Display1[16]; // Usually Fuel char Display2[16]; // Usually Settings //int ID; // optional - only if OutGauge ID is specified }LFSPACKET; . . LFSPACKET aktuellesPacket; . . memcpy(&aktuellesPacket,&buffer,sizeof(LFSPACKET)); . . /* Works fine --------------------------------- */ printf("Clutch : %3.1f \%\n", (aktuellesPacket.Clutch*100));
/* Doesn't work -------------------------------- */ printf("\n\nFLAGS shown as HEX = %x", aktuellesPacket.DashLights);
Since Z25 is out there are a few of changes at the sending UDP-Packet for any OutGauge-Device.
I read it at the <lfs_directory\docs\InSim.txt>
Z25:
// Each update sends the following UDP packet :
struct OutGaugePack { unsigned Time; // time in milliseconds (to check order) char Car[4]; // Car name word Flags; // Info (see OG_x below) byte Gear; // Reverse:0, Neutral:1, First:2... byte SpareB; float Speed; // M/S float RPM; // RPM float Turbo; // BAR float EngTemp; // C float Fuel; // 0 to 1 float OilPressure; // BAR float OilTemp; // C unsigned DashLights; // Dash lights available (see DL_x below) unsigned ShowLights; // Dash lights currently switched on float Throttle; // 0 to 1 float Brake; // 0 to 1 float Clutch; // 0 to 1 char Display1[16];// Usually Fuel char Display2[16];// Usually Settings int ID; // optional - only if OutGauge ID is specified };
// OG_x - bits for OutGaugePack Flags
#define OG_TURBO 8192 // show turbo gauge #define OG_KM 16384 // if not set - user prefers MILES #define OG_BAR 32768 // if not set - user prefers PSI
// DL_x - bits for OutGaugePack DashLights and ShowLights
enum { DL_SHIFT, // bit 0 - shift light DL_FULLBEAM, // bit 1 - full beam DL_HANDBRAKE, // bit 2 - handbrake DL_PITSPEED, // bit 3 - pit speed limiter DL_TC, // bit 4 - TC active or switched off DL_SIGNAL_L, // bit 5 - left turn signal DL_SIGNAL_R, // bit 6 - right turn signal DL_SIGNAL_ANY, // bit 7 - shared turn signal DL_OILWARN, // bit 8 - oil pressure warning DL_BATTERY, // bit 9 - battery warning DL_ABS, // bit 10 - ABS active or switched off DL_SPARE, // bit 11 DL_NUM };
Here the old version (Z and below):
typedef struct { unsigned int Time; // time in milliseconds (to check order) char Car[4]; // Car name short Flags; // Combination of OG_FLAGS, see below BYTE Gear; // Reverse:0, Neutral:1, First:2... BYTE SpareB; float Speed; // M/S float RPM; // RPM float Turbo; // BAR float EngTemp; // C float Fuel; // 0 to 1 float OilPress; // BAR float Spare1; float Spare2; float Spare3; float Throttle; // 0 to 1 float Brake; // 0 to 1 float Clutch; // 0 to 1 char Display1[16]; // Usually Fuel char Display2[16]; // Usually Settings int ID; // (optional ID - if specified in cfg.txt) } OGPACKET;
This means, you have to change the source code of the GI.exe or any other OutGauge-Software (if it allowed) to the new order of the UDP-Packet. I guess, that's the reason why the software not function as it should.
I try to build a UDP-Server for Z25 to use my AVR-USB-Board but it is not so easy for me at the moment.
Please install (for example at control Menu) a "confirm penalty" button to switch away the messages "30 seconds penalty for jump-start", "Drive Through Penalty" etc.
Because the message is all over the screen like the yellow flag and it is sometimes annoying (especially 30 or 45 sec penalty messages) to see these until the race is over.
It would be nice when the message get small and 'jump' to to middle-top of screen (for example above the virtual mirror) after you confirm that.
Thanks a lot
ID
Edit: Of course, I read the "Suggested improvements log" thread but I didn't find it there