The online racing simulator
Whats you OutGauge CFG Settings??

I use (see below) and with the dash im making (I might release it, who knows :shrug its very smooth and instant updating with no lag

Quote :OutGauge Mode 2
OutGauge Delay 1
OutGauge IP 127.0.0.1
OutGauge Port 35555
OutGauge ID 1

No one has anything new about VB libraries? Got very nice example of handling OutGauge with C++ from DarkTimes but C++ serial communications is waaay beyond my skills. On the other hand I have perfectly working VB software but it doesn't support new flags becose of T-RonX's library is out of date. And make things even more frustrating I'm able to use serial communication in C# but it lacks of any understandable OutGauge example...
I tried de-compiling the dll but it doesn't work correctly

We really need it updated *hint* *hint*
Does anyone have a tutorial on how to update this or does someone have a tutorial on how to make a UDP socket and receive the packets? Thanks.
Quote from kyler :Does anyone have a tutorial on how to update this or does someone have a tutorial on how to make a UDP socket and receive the packets? Thanks.

I'm also interested in getting the UDP socket to work in VB. Spent hours and hours yesterday trying to get over this problem somehow, but without any final breakthrough. Any VB experts around here to give us a clue how to start? I'm not completely newbie in VB, but UDP without any sign where to start is too much for my skills.
I don't have a VB version, but here is a simple C# example of how to receive OutGauge packets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;

namespace OutGauge
{
class Program
{
const int BufferSize = 1024;
const string Host = "127.0.0.1";
const ushort Port = 30000;

static void Main()
{
// Create UDP socket.
Socket socket = new Socket(
AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
byte[] buffer = new byte[BufferSize];

try
{
// Create EndPoint for LFS and bind the socket to it.
IPEndPoint endPoint = new IPEndPoint(
IPAddress.Parse(Host),
Port);
socket.Bind(endPoint);

while (true)
{
// Receive packet data.
int received = socket.Receive(buffer);
if (received > 0)
{
// Copy data from buffer into correctly sized array.
byte[] data = new byte[received];
Buffer.BlockCopy(buffer, 0, data, 0, received);

// Packet received...
OutGaugePack packet = new OutGaugePack(data);
OutGaugePacketReceived(packet);
}
else
{
Console.WriteLine("Lost connection to OutGauge");
break;
}
}
}
catch (SocketException ex)
{
Console.WriteLine("Socket Error: {0}", ex.Message);
}
}

static void OutGaugePacketReceived(OutGaugePack packet)
{
// Do stuff with packet etc..

Console.WriteLine(packet.RPM);

if (packet.DashLights.HasFlag(DashLightFlags.DL_SHIFT))
{
Console.WriteLine("Shift-light on!");
}
}

class OutGaugePack
{
public TimeSpan Time { get; private set; }
public string Car { get; private set; }
public OutGaugeFlags Flags { get; private set; }
public int Gear { get; private set; }
public int SpareB { get; private set; }
public float Speed { get; private set; }
public float RPM { get; private set; }
public float Turbo { get; private set; }
public float EngTemp { get; private set; }
public float Fuel { get; private set; }
public float OilPressure { get; private set; }
public float OilTemp { get; private set; }
public DashLightFlags DashLights { get; private set; }
public DashLightFlags ShowLights { get; private set; }
public float Throttle { get; private set; }
public float Brake { get; private set; }
public float Clutch { get; private set; }
public string Display1 { get; private set; }
public string Display2 { get; private set; }
public int ID { get; private set; }

public OutGaugePack(byte[] data)
{
Time = TimeSpan.FromMilliseconds(BitConverter.ToUInt32(data, 0));
Car = ASCIIEncoding.ASCII.GetString(data, 4, 4).TrimEnd(char.MinValue);
Flags = (OutGaugeFlags)BitConverter.ToUInt16(data, 8);
Gear = data[10];
SpareB = data[11];
Speed = BitConverter.ToSingle(data, 12);
RPM = BitConverter.ToSingle(data, 16);
Turbo = BitConverter.ToSingle(data, 20);
EngTemp = BitConverter.ToSingle(data, 24);
Fuel = BitConverter.ToSingle(data, 28);
OilPressure = BitConverter.ToSingle(data, 32);
OilTemp = BitConverter.ToSingle(data, 36);
DashLights = (DashLightFlags)BitConverter.ToUInt32(data, 40);
ShowLights = (DashLightFlags)BitConverter.ToUInt32(data, 44);
Throttle = BitConverter.ToSingle(data, 48);
Brake = BitConverter.ToSingle(data, 52);
Clutch = BitConverter.ToSingle(data, 56);
Display1 = ASCIIEncoding.ASCII.GetString(data, 60, 16).TrimEnd(char.MinValue);
Display2 = ASCIIEncoding.ASCII.GetString(data, 76, 16).TrimEnd(char.MinValue);

if (data.Length == 96)
{
ID = BitConverter.ToInt32(data, 92);
}
}
}

[Flags]
enum OutGaugeFlags
{
OG_TURBO = 8192,
OG_KM = 16384,
OG_BAR = 32768,
}

[Flags]
enum DashLightFlags
{
DL_SHIFT = 1,
DL_FULLBEAM = 2,
DL_HANDBRAKE = 4,
DL_PITSPEED = 8,
DL_TC = 16,
DL_SIGNAL_L = 32,
DL_SIGNAL_R = 64,
DL_SIGNAL_ANY = 128,
DL_OILWARN = 256,
DL_BATTERY = 512,
DL_ABS = 1024,
DL_SPARE = 2048,
}
}
}

Damn! I took that DarkTimes C# OutGauge example and combined it with this and I have excatly what I need!

Now my (or DarkTimes's and Microsoft's) C# program sends data to my microcontroller. It's WIP thingy but I have now RPM, Speed and emulated gear "N" (Edit: wrote it really, so it works now, see the code) on external LCD. I did all this with VB too, but outdated lib didn't understand new flags so this is as far as I got. Next I'll hook few LEDs to my uC and see how ABS, TC and stuff like that gives me signals.

My analog tacho is working somehow too, but it's old and slow. I'm more interested in this LCD and LEDs right now. I'll post some pics and videos when I'm far enough with this. Thank you DarkTimes, once again!!


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.IO.Ports;
using System.Threading;

namespace OutGauge
{
class Program
{
const int BufferSize = 1024;
const string Host = "127.0.0.1";
const ushort Port = 35555;

static SerialPort _serialPort;

static void Main()
{
StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;

// Create a new SerialPort object with default settings.
_serialPort = new SerialPort();

// Allow the user to set the appropriate properties.
_serialPort.PortName = "COM3";
_serialPort.BaudRate = 57600;
_serialPort.DataBits = 8;
_serialPort.Parity = (Parity)Enum.Parse(typeof(Parity), "None");
_serialPort.StopBits = (StopBits)Enum.Parse(typeof(StopBits), "Two");

// Set the read/write timeouts
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;

_serialPort.Open();

// Create UDP socket.
Socket socket = new Socket(
AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
byte[] buffer = new byte[BufferSize];

try
{
// Create EndPoint for LFS and bind the socket to it.
IPEndPoint endPoint = new IPEndPoint(
IPAddress.Parse(Host),
Port);
socket.Bind(endPoint);

while (true)
{
// Receive packet data.
int received = socket.Receive(buffer);
if (received > 0)
{
// Copy data from buffer into correctly sized array.
byte[] data = new byte[received];
Buffer.BlockCopy(buffer, 0, data, 0, received);

// Packet received...
OutGaugePack packet = new OutGaugePack(data);
OutGaugePacketReceived(packet);
}
else
{
Console.WriteLine("Lost connection to OutGauge");
break;
}
}
}
catch (SocketException ex)
{
Console.WriteLine("Socket Error: {0}", ex.Message);
}
}

static void OutGaugePacketReceived(OutGaugePack packet)
{
// Do stuff with packet etc..

_serialPort.Write("S"); // Start-byte for uC

if ((int)packet.RPM < 10){
_serialPort.Write("000");
} else if ((int)packet.RPM < 100){
_serialPort.Write("00");
} else if ((int)packet.RPM < 1000){
_serialPort.Write("0");
}

_serialPort.Write(((int)packet.RPM).ToString());

Int32 speed_kph = (int)(packet.Speed *3.6);

if (speed_kph < 10)
{
_serialPort.Write("00");
}
else if (speed_kph < 100)
{
_serialPort.Write("0");
}

_serialPort.Write(speed_kph.ToString());

if (packet.Gear == 0){
_serialPort.Write("R");
} else if (packet.Gear == 1){
_serialPort.Write("N");
} else if (packet.Gear > 1){
_serialPort.Write((packet.Gear - 1).ToString());
}
}

class OutGaugePack
{
public TimeSpan Time { get; private set; }
public string Car { get; private set; }
public OutGaugeFlags Flags { get; private set; }
public int Gear { get; private set; }
public int SpareB { get; private set; }
public float Speed { get; private set; }
public float RPM { get; private set; }
public float Turbo { get; private set; }
public float EngTemp { get; private set; }
public float Fuel { get; private set; }
public float OilPressure { get; private set; }
public float OilTemp { get; private set; }
public DashLightFlags DashLights { get; private set; }
public DashLightFlags ShowLights { get; private set; }
public float Throttle { get; private set; }
public float Brake { get; private set; }
public float Clutch { get; private set; }
public string Display1 { get; private set; }
public string Display2 { get; private set; }
public int ID { get; private set; }

public OutGaugePack(byte[] data)
{
Time = TimeSpan.FromMilliseconds(BitConverter.ToUInt32(data, 0));
Car = ASCIIEncoding.ASCII.GetString(data, 4, 4).TrimEnd(char.MinValue);
Flags = (OutGaugeFlags)BitConverter.ToUInt16(data, 8);
Gear = data[10];
SpareB = data[11];
Speed = BitConverter.ToSingle(data, 12);
RPM = BitConverter.ToSingle(data, 16);
Turbo = BitConverter.ToSingle(data, 20);
EngTemp = BitConverter.ToSingle(data, 24);
Fuel = BitConverter.ToSingle(data, 28);
OilPressure = BitConverter.ToSingle(data, 32);
OilTemp = BitConverter.ToSingle(data, 36);
DashLights = (DashLightFlags)BitConverter.ToUInt32(data, 40);
ShowLights = (DashLightFlags)BitConverter.ToUInt32(data, 44);
Throttle = BitConverter.ToSingle(data, 48);
Brake = BitConverter.ToSingle(data, 52);
Clutch = BitConverter.ToSingle(data, 56);
Display1 = ASCIIEncoding.ASCII.GetString(data, 60, 16).TrimEnd(char.MinValue);
Display2 = ASCIIEncoding.ASCII.GetString(data, 76, 16).TrimEnd(char.MinValue);

if (data.Length == 96)
{
ID = BitConverter.ToInt32(data, 92);
}
}
}

[Flags]
enum OutGaugeFlags
{
OG_TURBO = 8192,
OG_KM = 16384,
OG_BAR = 32768,
}

[Flags]
enum DashLightFlags
{
DL_SHIFT = 1,
DL_FULLBEAM = 2,
DL_HANDBRAKE = 4,
DL_PITSPEED = 8,
DL_TC = 16,
DL_SIGNAL_L = 32,
DL_SIGNAL_R = 64,
DL_SIGNAL_ANY = 128,
DL_OILWARN = 256,
DL_BATTERY = 512,
DL_ABS = 1024,
DL_SPARE = 2048,
}
}
}

It seems that DarkTimes's code tells that "Shift light is ON!" all the time, even it isn't. Is there some small problem?

My OutGauge settings:

OutGauge Mode 2
OutGauge Delay 4
OutGauge IP 127.0.0.1
OutGauge Port 30000
OutGauge ID 2

Edit: Ah, yeah, it should be "if (packet.ShowLights.HasFlag(DashLightFlags.DL_ABS))", not DashLights.
Quote from DarkTimes :I don't have a VB version, but here is a simple C# example of how to receive OutGauge packets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;

namespace OutGauge
{
class Program
{
const int BufferSize = 1024;
const string Host = "127.0.0.1";
const ushort Port = 30000;

static void Main()
{
// Create UDP socket.
Socket socket = new Socket(
AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
byte[] buffer = new byte[BufferSize];

try
{
// Create EndPoint for LFS and bind the socket to it.
IPEndPoint endPoint = new IPEndPoint(
IPAddress.Parse(Host),
Port);
socket.Bind(endPoint);

while (true)
{
// Receive packet data.
int received = socket.Receive(buffer);
if (received > 0)
{
// Copy data from buffer into correctly sized array.
byte[] data = new byte[received];
Buffer.BlockCopy(buffer, 0, data, 0, received);

// Packet received...
OutGaugePack packet = new OutGaugePack(data);
OutGaugePacketReceived(packet);
}
else
{
Console.WriteLine("Lost connection to OutGauge");
break;
}
}
}
catch (SocketException ex)
{
Console.WriteLine("Socket Error: {0}", ex.Message);
}
}

static void OutGaugePacketReceived(OutGaugePack packet)
{
// Do stuff with packet etc..

Console.WriteLine(packet.RPM);

if (packet.DashLights.HasFlag(DashLightFlags.DL_SHIFT))
{
Console.WriteLine("Shift-light on!");
}
}

class OutGaugePack
{
public TimeSpan Time { get; private set; }
public string Car { get; private set; }
public OutGaugeFlags Flags { get; private set; }
public int Gear { get; private set; }
public int SpareB { get; private set; }
public float Speed { get; private set; }
public float RPM { get; private set; }
public float Turbo { get; private set; }
public float EngTemp { get; private set; }
public float Fuel { get; private set; }
public float OilPressure { get; private set; }
public float OilTemp { get; private set; }
public DashLightFlags DashLights { get; private set; }
public DashLightFlags ShowLights { get; private set; }
public float Throttle { get; private set; }
public float Brake { get; private set; }
public float Clutch { get; private set; }
public string Display1 { get; private set; }
public string Display2 { get; private set; }
public int ID { get; private set; }

public OutGaugePack(byte[] data)
{
Time = TimeSpan.FromMilliseconds(BitConverter.ToUInt32(data, 0));
Car = ASCIIEncoding.ASCII.GetString(data, 4, 4).TrimEnd(char.MinValue);
Flags = (OutGaugeFlags)BitConverter.ToUInt16(data, 8);
Gear = data[10];
SpareB = data[11];
Speed = BitConverter.ToSingle(data, 12);
RPM = BitConverter.ToSingle(data, 16);
Turbo = BitConverter.ToSingle(data, 20);
EngTemp = BitConverter.ToSingle(data, 24);
Fuel = BitConverter.ToSingle(data, 28);
OilPressure = BitConverter.ToSingle(data, 32);
OilTemp = BitConverter.ToSingle(data, 36);
DashLights = (DashLightFlags)BitConverter.ToUInt32(data, 40);
ShowLights = (DashLightFlags)BitConverter.ToUInt32(data, 44);
Throttle = BitConverter.ToSingle(data, 48);
Brake = BitConverter.ToSingle(data, 52);
Clutch = BitConverter.ToSingle(data, 56);
Display1 = ASCIIEncoding.ASCII.GetString(data, 60, 16).TrimEnd(char.MinValue);
Display2 = ASCIIEncoding.ASCII.GetString(data, 76, 16).TrimEnd(char.MinValue);

if (data.Length == 96)
{
ID = BitConverter.ToInt32(data, 92);
}
}
}

[Flags]
enum OutGaugeFlags
{
OG_TURBO = 8192,
OG_KM = 16384,
OG_BAR = 32768,
}

[Flags]
enum DashLightFlags
{
DL_SHIFT = 1,
DL_FULLBEAM = 2,
DL_HANDBRAKE = 4,
DL_PITSPEED = 8,
DL_TC = 16,
DL_SIGNAL_L = 32,
DL_SIGNAL_R = 64,
DL_SIGNAL_ANY = 128,
DL_OILWARN = 256,
DL_BATTERY = 512,
DL_ABS = 1024,
DL_SPARE = 2048,
}
}
}


Is there a way to convert this from a Console to Windows App?

I'm new to programing sorry for all the questions. I'm slowly learning =)

Thanks, Kyler
Hey guys

I converted DarkTimes' C# code into VB.NET 2008
Its still a console app, but I'm sure those of you who want VB.NET code can make a console app

Cheers
-Dave

EDIT: Added rar with VB.NET 2008 Source
Attached files
VBOutgaugez28.rar - 74.3 KB - 802 views
Got a tutorial on how to convert this from console to an app. ?

Thanks, Kyler
I don't but as you see from my previous posts in this thread, I really want an z28 VB.NET version of outgauge...

I'm not too good with the whole UDP connections etc and I only know VB, C#
But preferably use VB.NET

I'm working on making a form/GUI version of this, but as im quite busy it may be a few days.. So if someone can do that before then, Kudos to you
I would like to try some older LFS External versions like 1.1.1.2 or 1.1.1.3. Where i can find them?
Quote from DavidTiger :Hey guys

I converted DarkTimes' C# code into VB.NET 2008
Its still a console app, but I'm sure those of you who want VB.NET code can make a console app

Cheers
-Dave

EDIT: Added rar with VB.NET 2008 Source

Thank you very much Darktimes for the code and you DavidTiger for converting it to vb.net
Hi all,

The insim running in my drift server is using LFS External, and it's going quite well so far, but I was wondering, the people using mouse can't seem to hide their cursor. There are no clickable buttons on the screen, just normal buttons, and still the mouse appears... Is this something not possible in LFS External, or some kind of option, or did I do something wrong?

Thanks in advance,

Bose
Quote from Bose321 :Hi all,

The insim running in my drift server is using LFS External, and it's going quite well so far, but I was wondering, the people using mouse can't seem to hide their cursor. There are no clickable buttons on the screen, just normal buttons, and still the mouse appears... Is this something not possible in LFS External, or some kind of option, or did I do something wrong?

Thanks in advance,

Bose

Have they tried to press Shift+Z?
When the connections list is open (pressing N) it happens too.
Quote from broken :Have they tried to press Shift+Z?
When the connections list is open (pressing N) it happens too.

I'm trying it out myself. Connections list is not on the screen, and the mouse is hidden with Shift+Z. Still a cursor on screen.
Quote from Bose321 :I'm trying it out myself. Connections list is not on the screen, and the mouse is hidden with Shift+Z. Still a cursor on screen.

even the insim is off the mouse still shows?
Quote from Bose321 :I'm trying it out myself. Connections list is not on the screen, and the mouse is hidden with Shift+Z. Still a cursor on screen.

These are the 3 factors I know:
Shift+Z
Connections list
Clickable button

If it is not the first two, have a really good look at your application, and make sure none of the buttons it sends are clickable.
Quote from DarkTimes :Here is a simple C# example of how to receive OutGauge packets.

Can someone please convert this code to a C# WinForms project?

I have tried for hours on end but for the life of me I can't get it to work.

I've modified the LFS_External example project to show some of the data I want, but it's to outdated to show things such as lights or the current car.
Because of this it's impossible to scale the tachometer for example.

I have enough "experience" with C# to kludge something together, but this is way beyond my abilities.
Well, you can use og_relay to solve the problem with dashboard lights

OR

use Spark, or wait a few weeks until the release of InSim.NET (the succesor of Spark)
-
(vforce) DELETED by vforce
regarding variable spare1 in the: - LFS External 1.1 with OutSim and OutGauge example for VB.NET
How can you convert the single floating point to separate bits?
Because I want to see the dashboard lights

is it possible to have the full code and not the dll??

kind regards
(double post)
You don't have to be concerned about any "spare" variables 'cause they serve no purpose now. They're there just in case they'll be needed in the future.

Regarding the OutGauge dashLights, I believe you meant integer, not a float. There are multiple ways how to check if a certain bit is set, but I guess the simplest one is using a set of constants like this:

const int DL_SHIFT = 1
const int DL_FULLBEAM = 2
const int DL_HANDBRAKE = 4
... and so on

and using logical AND to check if a certain bit is set like this:

if (OutGaugePacket.DashLights & DL_SHIFT)
{
(do something when shift light is on)
}

I'm not great with C#, but I guess this approach should work in almost any language.
But there is no OutGaugePacket.DashLights in the c# file ( I started working whit c# instead of vb) I have everything working except for the dashboard lights.
There is no og.Dashlights ore something of that kind. I noticed that the spare3 changes value if you put on a dashboard light.Sow that is why I thought a need to work whit this variable fore the lights

FGED GREDG RDFGDR GSFDG