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
Flags(0 To 1) As Integer
Flags As Integer
'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