The online racing simulator
Searching in All forums
(6 results)
ID_0815
S2 licensed
Yes, I change to 1,2,4,8,16.... and it works as it should. Thanks a lot for this tip.

Well, learning by doing .
I did a lot of bit operations exercises at school but this mistake it quite a beginner fault...
ID_0815
S2 licensed
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 .
Great
ID_0815
S2 licensed
yes, that was my mistake.
When I press the "Pit Limiter" now, it works. Okay, the ABS and TC lamps goes on but that a problem that I can fix

Thanks a lot David
DashLights OutGauge Problem (Language C)
ID_0815
S2 licensed
Hello,

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);

if((aktuellesPacket.DashLights & 1) == 1)printf("\nSHIFT!");
if(aktuellesPacket.DashLights & 4) printf("\t\tPit Speed Limiter");
if(aktuellesPacket.DashLights & 3) printf("\tHandbrake\n");
if(aktuellesPacket.DashLights & 11) printf("ABS");
if(aktuellesPacket.DashLights & 8) printf("\t\tTC");
if(aktuellesPacket.DashLights & 2) printf("\t\t\tFull Beam\n");
if(aktuellesPacket.DashLights & 9) printf("Indicator Left");
if(aktuellesPacket.DashLights & 7) printf("\tIndicator Right");
if(aktuellesPacket.DashLights & 8) printf("\t\tHazard Lights\n");
if(aktuellesPacket.DashLights & 9) printf("Oil Pressure");
if(aktuellesPacket.DashLights & 10) printf("\tBattery");
.
.
.

ID_0815
S2 licensed
At the replies of today:

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;


#define OG_SHIFTLIGHT 1
#define OG_FULLBEAM 2
#define OG_HANDBRAKE 4
#define OG_PITSPEED 8
#define OG_TC 16
#define OG_HEADLIGHTS 32
#define OG_SIGNAL_L 64
#define OG_SIGNAL_R 128
#define OG_REDLINE 256
#define OG_OILWARN 512
#define OG_1 1024
#define OG_2 2048
#define OG_3 4096
#define OG_4 8192
#define OG_KM 16384
#define OG_BAR 32768

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.

Sorry for my bad english
ID
Last edited by ID_0815, .
Confirm Penalty Button
ID_0815
S2 licensed
Hi LFS-Team.

I have a small improvement suggestion:

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
Last edited by ID_0815, .
FGED GREDG RDFGDR GSFDG