The online racing simulator
OutGauge in VB. Patch Z25
(6 posts, started )
OutGauge in VB. Patch Z25
Hi, I'm searching the forum, but I don't find how to use the new form.

I found an example for VB but it is old (like I had)

Private Type OutGaugePacket
Time(0 To 3) As Byte 'unsigned int Time; // time in milliseconds (to check order)
Car(0 To 3) As Byte 'char Car[4]; // Car name
Flags(0 To 1) As Byte 'word Flags; // Combination of OG_FLAGS, see below
Gear As Byte 'byte Gear; // Reverse:0, Neutral:1, First:2...
SpareB As Byte 'byte SpareB;
Speed As Single 'float Speed; // M/S
RPM As Single 'float RPM; // RPM
Turbo As Single 'float Turbo; // BAR
EngTemp As Single 'float EngTemp; // C
Fuel As Single 'float Fuel; // 0 to 1
OilPress As Single 'float OilPress; // BAR
Spare1 As Single 'float Spare1;
Spare2 As Single 'float Spare2;
Spare3 As Single 'float Spare3;
Throttle As Single 'float Throttle; // 0 to 1
Brake As Single 'float Brake; // 0 to 1
Clutch As Single 'float Clutch; // 0 to 1
Display1(0 To 15) As Byte 'char Display1[16]; // Usually Fuel
Display2(0 To 15) As Byte 'char Display2[16]; // Usually Settings
ID As Long 'int ID; // (optional ID - if specified in cfg.txt)
End Type

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

I ask for help, I don't has so many knowledge on programming, but I can work on a working example. So, anybody can to recode this part of code? I know that it is easy for a programmer, but near to impossible to me

I want to do a shiftligth LED, and a vibratory motor to brake when ABS will jump. I have communication with a microcontroller via serial port. But I need to extract data from LFS, I was do for the last patch but I have to redo this part
Probably the question was too general, I try to be more specific.

To define the variable (or constant?) "DL_SHIFT" and "DL_HANDBRAKE" how do I Have To?

I do not understand because it is bit 0, bit 1, bit 2 .... etc.

Bit 0 is = 1, Bit 1 = 2, Bit 3 = 4, Bit 4 = 8 ... ?

I define like
Private Const DL_SHIFT = 1

But ever is one, don't change.

If I put on the Private Type OtuGaugePacket (in the example above) like
DL_SHIFT as Single

or
DL_SHIFT as Boolean

then says that the variable is not defined.
Quote from Napalm Candy :To define the variable (or constant?) "DL_SHIFT" and "DL_HANDBRAKE" how do I Have To?

Quote from Napalm Candy :If I put on the Private Type OtuGaugePacket (in the example above) like
DL_SHIFT as Single

or
DL_SHIFT as Boolean

then says that the variable is not defined.

I take it you mean, OG_SHIFTLIGHT and OG_HANDBRAKE. Because DL_SHIFT and DL_HANDBRAKE is not defined in the code you posted.

Quote from Napalm Candy :I do not understand because it is bit 0, bit 1, bit 2 .... etc.

Bit 0 is = 1, Bit 1 = 2, Bit 3 = 4, Bit 4 = 8 ... ?

That's correct.

Quote from Napalm Candy :I define like
Private Const DL_SHIFT = 1

But ever is one, don't change.

Why are you redefining OG_SHIFTLIGHT (It's value is 1) to DL_SHIFT?

If you want to combine two values, do an OR.
Because the code that I posted on first post is how work before patch Z25, now has changed. And that is what be in the insim.txt

// OutGauge - EXTERNAL DASHBOARD SUPPORT
// ========

// The user's car in multiplayer or the viewed car in single player or
// single player replay can output information to a dashboard system
// while viewed from an internal view.

// This can be controlled by 5 lines in the cfg.txt file :

// OutGauge Mode 0 :0-off 1-driving 2-driving+replay
// OutGauge Delay 1 :minimum delay between packets (100ths of a sec)
// OutGauge IP 0.0.0.0 :IP address to send the UDP packet
// OutGauge Port 0 :IP port
// OutGauge ID 0 :if not zero, adds an identifier to the packet

// 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
};

//////
#endif

#5 - Stuff
Hola Napalm! I'll post here to keep things where everyone can see them. To go along with the rest of this post, I updated my OutGauge example that now works, I think.. Updates include functions that convert from the byte arrays in the packet to usable data and a function to check if a bit is set.

All the OG_* (now mostly DL_*) are just saying which bits they are. They are used like booleans in that 0 = false and 1 = true, just in the simplest format possible to save space. The trick is checking which bits are 0 or 1 and that is done with bitwise operations. Read up on that and it will become clear. If not, let me know..

Hope it helps..
Thank you for your time, I will check now

OutGauge in VB. Patch Z25
(6 posts, started )
FGED GREDG RDFGDR GSFDG