The online racing simulator
I need a example in VB to connect InSim
Hi, I'm making an interface for a real gauges, I had connect to Outgauge and received data from. But now I need more packets like Time per Lap, sectors, etc... But my knowledges of programming are few. Anyone can to make me an example in VB connecting to InSim and receiving a packet?

Thanks in advance
Hello.

I think you can find something here: [removed link to unacceptable site]
I already had this, but this is not VB, is in .NET and VisualC. I need in VisualBasic
Sry but then i cant help
#5 - Silox
Quote from Napalm Candy :I already had this, but this is not VB, is in .NET and VisualC. I need in VisualBasic

You mean the VB 6.0 version?

I don't have a connection for that, but I think you can use the same .dll file and just edit the syntax a bit.
How I say... i only know a very little of programing and only in VB, I don't know how to load a DLL

And if I will open that dll i think that I will can't translate in to VB
#7 - Stuff
I posted some VB6 code a while back that works for an older version of InSim (LFS S2 0.5V3, InSimVer=3, I think). It's a starting point I guess VB6_ISE and a simple, older OutGauge only example. I have some updated code around here somewhere that I will have to find if you're interested.
I'm trying your program, but LFS says "InSim : first byte in packet does not match size"

I take a look to code, but it is too complex for me, i don't know what the part of code make connection with LFS
At the moment I'm using your example of VBOutgauge.... well actually I am using only the code to connection. Your program is in...

http://www.lfsforum.net/showthread.php?p=117090#post117090

The code for connections to Outgauge looks easy, 7 or 8 lines, can you do another for insim? Only I need the code to connect and example receiving 1 packet.

Thanks
OK.. I went through the latest okSocket code I had and fixed it up, included my partial okInSimClient (uses okSocket and LFS.bas stuff), and made a simple example using them. It connects to the latest InSim but it doesn't handle everything. A starting point you can use, or you can study it on how to roll you own. Upto you of course. Hope it helps! ¡Buena suerte!
Attached files
InSimStarter.zip - 30.4 KB - 239 views
Thank you very much stuff! I will take a look
I see that it connect to LFS, but I don't know how to take a data. Well, I don't know where to put the code to take data.

In the Outgauge example I put after

Private Sub theSocket_Received(lngSocket As Long, Data() As Byte)
If lngSocket = lngTheSocket Then

I have make a label, and I want to see the time for last lap.

lblLapTime.Caption = Format(InsimPackets.ISP_LAP, "HH:MM:SS")

Where I can put this line?
Well, you have two choices. You can either use the InSimClient events to handle it like main.frm does with the InSim object. (just select the PlayerLap event from the dropdown, result below) OR you can do away with the InSimClient altogether and handle the pure data from the socket. To see an example of how InSimClient does this, look at the InSimSocket_Received event.

The quickest way would be the first as I already have quite a bit of InSim handled but not all. You might have to modify that class but it's better than starting from scratch imo. That is unless you only want to handle a few events making most of InSimClient useless.


Private Sub InSim_PlayerLap(ByVal bytPLID As Byte, ByVal sngSeconds As Single, ByVal lngLapsDone As Long, ByVal lngPlayerFlags As Long, _
ByVal Penalty As PenaltyValue, ByVal bytNumStops As Byte)
lblLapTime.Caption = SecondsToTime(sngSeconds)
End Sub

'242.800 -> 4:02.80
Private Function SecondsToTime(ByVal sngSeconds As Single) As String
On Error GoTo SecondsToTimeErr
Dim intMinutes As Integer, sngSec60 As Single

intMinutes = sngSeconds \ 60 'integer division
sngSec60 = sngSeconds - (intMinutes * 60)

SecondsToTime = Format(CStr(intMinutes), "0") & ":" & Format(CStr(sngSec60), "00.00")

Exit Function
SecondsToTimeErr:
SecondsToTime = "parse error for " & CStr(sngSeconds)
End Function

I had try this example, I don't understand all code but it runs. But it has a fail in conversion, I put a IA with a BF1 in Fe Club, and when it makes a LAP don't indicate correctly.. some examples.

First Lap. 40.08 program says 146:36,00.
Second Lap. 35.23 -> 160:17,00
Third Lap. 35.18 -> 110:17,00

I don't find in your example the variable to time Laps, I thought was ISP_LAP but you don't put this... from where you extract that data? Is important to me understand that to make successfully with another data packets
Attached files
InSimStarter.rar - 29.7 KB - 180 views
Ahh, I see the problem. It's like I kinda said above, the InSimClient is not all there and was originally made for an older version of InSim. The lap packet, and probably tons of others, have changed. In the case of lap time, it went from a minutes/seconds/hundreths/thousandths structure to a plain, unsigned integer in ms. In any case, it's out of date So, you'll have to either fix InSimClient or delete it and make your own. But before you do anything maybe I should explain how some things work. Hopefully you'll follow me..

InSimClient uses the okSocket you give it to do the magic. If you open up InSimClient, change the left dropdown to InSimSocket and the right dropdown to Received (InSimSocket_Received) you can see where it handles the raw data. You'll also find that ISP_LAP (it's there, defined on line 67 in the InSimPackets type) raises the PlayerLap event (line 1060). After it does that, main.frm gets the event because it declared the InSimClient object using WithEvents, you see. It goes: okSocket receives data then raises Received event. InSimClient handles the okSocket Received event, parses the packet then raises whatever event. Finally main.frm handles the InSimClient events. For an article on VB6 events check out this: http://www.developer.com/net/vb/article.php/1430631 (sorry, couldn't find it en español :shrug

So yeah, check out the InSimClient's InSimSocket_Received event to see where the data is extracted/parsed. Let me know if you're stuck or want an example without the InSimClient
Thank you I will take a look this weekend, this is the interface that have at the moment. Only with outgauge. If you want the code i can to send you, but it is not public at the moment
Attached files
OutGaugeTest.rar - 706.8 KB - 196 views
This weekend I was trying things, I read documentation in english and spanish about raise Received event, but I don't understand how it works, so I don't made nothing for the program I see that too much complicated to me. I don't understand how it is possible that be so difficult to extract a time by lap

I can to convert ms to "HH:MM:SS.ss" I think, but first I need a variable with this data, but i continue without find where is.

Another question, I want to use this connection to InSim to replace with the older program (VB6OutgaugeTest) but if I put line
lblLapTime.Caption = Format(OutGaugePacket.sngSpeed * 3.6, "##0.0")

in the "Private Sub InSim_PlayerLap" I have an error when finish a Lap. Where I have to put? Thank you for your patient

FGED GREDG RDFGDR GSFDG