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:
                
                
            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");
.
.
.



 .
.  .
 .
 .
.