The online racing simulator
OutGauge - now available in T6
(165 posts, started )
Packet.Flags and OG_SHIFTLIGHT must be of the same data type. Both should be Integer, I reckon.
Option Explicit

'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 :
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

Private lngTheSocket As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Private Sub Form_Load()
If theSocket.Initilize("MrOutGauge") Then
lngTheSocket = theSocket.ListenTo("UDP", 55)

Print "Listening on port 55"
Else
Print "Could not initlize winsock!?"
End If
End Sub


Private Sub theSocket_Received(lngSocket As Long, Data() As Byte)
If lngSocket = lngTheSocket Then
Dim Packet As OutGaugePacket
Dim Display1 As String
Dim Display2 As String

CopyMemory Packet, Data(0), LenB(Packet)

lblSpeed.Caption = Format(Packet.Speed * 3.6, "##0.0") 'Valor de velocidad
lblFuel.Caption = Format(Packet.Fuel * 100, "#0.#0") & " %" 'Valor de Fuel en %
lblRPM.Caption = Format(Packet.RPM, "####0") 'Valor de RPM
lblTurbo.Caption = Format(Packet.Turbo, "#0.##0") & " BAR" 'Indicador de Turbo

Display1 = Chr(Packet.Display1(0))
Display1 = Display1 & Chr(Packet.Display1(1))
Display1 = Display1 & Chr(Packet.Display1(2))
Display1 = Display1 & Chr(Packet.Display1(3))
Display1 = Display1 & Chr(Packet.Display1(4))
Display1 = Display1 & Chr(Packet.Display1(5))
Display1 = Display1 & Chr(Packet.Display1(6))
Display1 = Display1 & Chr(Packet.Display1(7))
Display1 = Display1 & Chr(Packet.Display1(8))
Display1 = Display1 & Chr(Packet.Display1(9))
Display1 = Display1 & Chr(Packet.Display1(10))
Display1 = Display1 & Chr(Packet.Display1(11))
Display1 = Display1 & Chr(Packet.Display1(12))
Display1 = Display1 & Chr(Packet.Display1(13))
Display1 = Display1 & Chr(Packet.Display1(14))
Display1 = Display1 & Chr(Packet.Display1(15))
lblDisplay1.Caption = Display1 ' Muestra el Display 1

Display2 = Chr(Packet.Display2(0))
Display2 = Display2 & Chr(Packet.Display2(1))
Display2 = Display2 & Chr(Packet.Display2(2))
Display2 = Display2 & Chr(Packet.Display2(3))
Display2 = Display2 & Chr(Packet.Display2(4))
Display2 = Display2 & Chr(Packet.Display2(5))
Display2 = Display2 & Chr(Packet.Display2(6))
Display2 = Display2 & Chr(Packet.Display2(7))
Display2 = Display2 & Chr(Packet.Display2(8))
Display2 = Display2 & Chr(Packet.Display2(9))
Display2 = Display2 & Chr(Packet.Display2(10))
Display2 = Display2 & Chr(Packet.Display2(11))
Display2 = Display2 & Chr(Packet.Display2(12))
Display2 = Display2 & Chr(Packet.Display2(13))
Display2 = Display2 & Chr(Packet.Display2(14))
Display2 = Display2 & Chr(Packet.Display2(15))
lblDisplay2.Caption = Display2 'Muestra el display2

'Indicador de marcha
If Packet.Gear = 0 Then lblGear.Caption = Format("R")
If Packet.Gear = 1 Then lblGear.Caption = Format("N")
If Packet.Gear = 2 Then lblGear.Caption = 1
If Packet.Gear = 3 Then lblGear.Caption = 2
If Packet.Gear = 4 Then lblGear.Caption = 3
If Packet.Gear = 5 Then lblGear.Caption = 4
If Packet.Gear = 6 Then lblGear.Caption = 5
If Packet.Gear = 7 Then lblGear.Caption = 6
If Packet.Gear = 8 Then lblGear.Caption = 7
If Packet.Gear = 9 Then lblGear.Caption = 8

If (Packet.Flags And OG_SHIFTLIGHT) > 0 Then LEDShiftLigth.Visible = True

End If
End Sub

I use the example of Stuff in first page of this thread.

I have tried to change the lines..
Flags(0 To 1) As Byte

to


Flags(0 To 1) As Integer

...AND...

Private Const OG_SHIFTLIGHT As Long = 1

to


Private Const OG_SHIFTLIGHT As Integer = 1

And I have the same error message
That's because Flags is of type word, which is two bytes. Now originally you had defined Flags as a byte array of length 2, which is correct for reading the data, but you can't do bitwise operations with arrays. Instead you have to define Flags as Integer, which in VB6 is also two bytes and therefore what you want.

The only error you have now is that you actually defined an Integer array instead of just an Integer.

So instead of this
Flags(0 To 1) As Integer


it needs to be this
Flags As Integer
Thank you man, now works fine

Only I see a little problem, I can't put Integer for OG_BAR, but becouse I don't know the utility of this flag, I think that I don't use
Private Const OG_BAR As Long = 32768
Oh that's true, VB doesn't have unsigned Integers, so I guess you'd have to take a Long field for OG_BAR then. I think it should be able to make a bitwise AND with Integer and Long fields, the initial problem was just trying to do the operation on the array. Or use the value -32768 for the OG_BAR constant, which should give the same result.
Two questions, what is mean "FullBeam"? I don't know what is this signal. And what is the utility for OG_KM and OG_BAR?

And second question, I cant to work with OG_HEADLIGHTS, don't want to run. But VB6 don't say any error, simply no appear the image.

'Traction Control
Dim TractionControl As Byte
Select Case Packet.Flags And OG_TC
Case 16
TractionControl = True
Case 0
TractionControl = False
End Select
picTC.Visible = TractionControl

'Headlights
Dim HeadLights As Byte
Select Case Packet.Flags And OG_HEADLIGHTS
Case 32
HeadLights = True
Case 0
HeadLights = False
End Select
PicHEADLIGHTS.Visible = HeadLights

First example of TC works fine, and with all other signals, but with Headlights no... what i'm doing wrong?
I can't remember which, but either FullBeam or Headlights doesn't work at the moment (presumably it was put in along with oil pressure and engine temperature to prepare for future patches). Try using FullBeam instead of Headlights, I think FullBeam is the one for flashing the lights, not too sure though
Neither works fullbeam, I have asigned another picture. And OG_BAR and OG_KM what is they function?
Hello!? Bumping this old thread to post an updated OutGauge VB6 example for some. It's just like the one in my first post except for patch Z+, I think, or whenever it was updated.. works in Z28 anyway.
Attached files
VB6 OutGauge Z.zip - 16.3 KB - 422 views
Hey, Any chance you could update this to VB.NET 2008 ??
I could do it easily but I don't have VB6

Thanks if you do!
-David
Quote from Stuff :Hello!? Bumping this old thread to post an updated OutGauge VB6 example for some. It's just like the one in my first post except for patch Z+, I think, or whenever it was updated.. works in Z28 anyway.

Thank you, it he was having problems with the Z version
Quote from Stuff :... or whenever it was updated.. works in Z28 anyway.

It was updated in Z25
As much as I try to understand this bitwise stuff and try to learn about flags in VB, i can`t manage to see shift light. Looking at LFS virtual gauges, I can see "shift up" sign when over revving but red square below gear label won`t appear.
Tried all the combinations for variables, even made a separate labels for each flag, followed all the examples and posts, still no success.
Someone mentioned that shift light will only work for manual shifting but I tried to change (G25 shifter configured) but again only paddles work for gear change.
Maybe I`m asking stupid questions, but I would like if someone will point me into right direction.
Thanks in advance!
have you made sure youre testing with a car that still has a shift light? its been removed from most of the cars relatively recently (on the geological timescale that were on with lfs right now) and presumably also from the flags if youre in one of them
Thanks very much for VB6 source code. I have been trying to get your "outgauge Test" to run on my Xp OS but no luck so far.
If I do a test run from VB6 I recieve an error 6 from it (Stack Overflow) It seems linked tothe "IsBitSet'" function. I can get the rest to work -RPM Speed - by disabling that function and 'remarking' out any reference to it. But I desperately would like to get the dashlights etc. working so I can build up my own Dash. Has anyone overcome this problem or know how to? (Please note - LFS noob and VB6 self taught - but willing to learn)
I am using LFS version 0.5Z28, so the it looks like I have the latest outgauge version - eg. DL_Handbrake not OG_Handbrake.
[Have exhasted my search on google for workable answer] Please help if u can.

OutGauge - now available in T6
(165 posts, started )
FGED GREDG RDFGDR GSFDG