Difference between revisions of "OutSim / OutGauge"

From LFS Manual
Jump to navigationJump to search
 
(Added rough OutSim/OutGauge info.)
Line 1: Line 1:
 +
OutSim and OutGauge are protocols, similar to InSim, designed for use in motion simulators and dashboards respectively. Both protocols allow you to receive UDP packets broadcast by LFS, which can be enabled in the 'LFS\cfg.txt' file. Like with InSim, the official documentation for these packets can be found the in the game's 'doc\InSim.txt' file.
 +
 +
Although the packets can only be sent by LFS using UDP, each packet provides a timestamp in order for you to verify the order. It must be noted as well that both OutSim and OutGauge packets will only be sent if you are viewing the car from '''cock-pit mode'''! Note the ID attribute of both OutSim and OutGauge packets is only present if set the 'cfg.txt' file.
 +
 
== OutSim ==
 
== OutSim ==
  
OutSim allows support for motion simulators in LFS.
+
To instruct LFS to send OutSim packets, update this section of your 'LFS\cfg.txt' file:
 +
 
 +
<big><pre>// OutSim Mode 0        :0-off 1-driving 2-driving+replay
 +
// OutSim Delay 1      :minimum delay between packets (100ths of a sec)
 +
// OutSim IP 0.0.0.0    :IP address to send the UDP packet
 +
// OutSim Port 0        :IP port
 +
// OutSim ID 0          :if not zero, adds an identifier to the packet</pre></big>
 +
 
 +
Here is an example of receiving OutSim packets using Python.
 +
 
 +
<big><pre>import socket
 +
import struct
 +
 
 +
# Create UDP socket.
 +
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 +
 
 +
# Bind to LFS.
 +
sock.bind(('127.0.0.1', 30000))
 +
 
 +
while True:
 +
    # Receive data.
 +
    data = sock.recv(256)
 +
 
 +
    if not data:
 +
        break # Lost connection
 +
 
 +
    # Unpack the data.
 +
    outsim_pack = struct.unpack('I12f3i', data)
 +
    time = outsim_pack[0]
 +
    angvel = [outsim_pack[1], outsim_pack[2], outsim_pack[3]]
 +
    header = outsim_pack[4]
 +
    pitch = outsim_pack[5]
 +
    roll = outsim_pack[6]
 +
    accel = [outsim_pack[7], outsim_pack[8], outsim_pack[9]]
 +
    vel = [outsim_pack[10], outsim_pack[11], outsim_pack[12]]
 +
    pos = [outsim_pack[13], outsim_pack[14], outsim_pack[15]]
 +
 
 +
# Release the socket.
 +
sock.close()</pre></big>
  
 
== OutGauge ==
 
== OutGauge ==
  
OutGauge allows support for external dashboards in LFS.
+
To instruct LFS to send OutGauge packets, update this section of your 'LFS\cfg.txt' file:
 +
 
 +
<big><pre>// 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</pre></big>
 +
 
 +
Here is an example of receiving OutSim packets using Python.
 +
 
 +
<big><pre>import socket
 +
import struct
 +
 
 +
# Create UDPO socket.
 +
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 +
 
 +
# Bind to LFS.
 +
sock.bind(('127.0.0.1', 30000))
 +
 
 +
while True:
 +
    # Receive data.
 +
    data = sock.recv(256)
 +
 
 +
    if not data:
 +
        break # Lost connection
 +
 
 +
    # Unpack the data.
 +
    outgauge_pack = struct.unpack('I3sxH2B7f2I3f15sx15sx', data)
 +
    time = outgauge_pack[0]
 +
    car = outgauge_pack[1]
 +
    flags = outgauge_pack[2]
 +
    gear = outgauge_pack[3]
 +
    speed = outgauge_pack[5]
 +
    rpm = outgauge_pack[6]
 +
    rutbo = outgauge_pack[7]
 +
    engtemp = outgauge_pack[8]
 +
    fuel = outgauge_pack[9]
 +
    oilpressure = outgauge_pack[10]
 +
    oiltemp = outgauge_pack[11]
 +
    dashlights = outgauge_pack[12]
 +
    showlights = outgauge_pack[13]
 +
    throttle = outgauge_pack[14]
 +
    brake = outgauge_pack[15]
 +
    clutch = outgauge_pack[16]
 +
    display1 = outgauge_pack[17]
 +
    display2 = outgauge_pack[18]
 +
 
 +
    print throttle
 +
 
 +
# Release the socket.
 +
sock.close()</pre></big>

Revision as of 19:11, 24 December 2010

OutSim and OutGauge are protocols, similar to InSim, designed for use in motion simulators and dashboards respectively. Both protocols allow you to receive UDP packets broadcast by LFS, which can be enabled in the 'LFS\cfg.txt' file. Like with InSim, the official documentation for these packets can be found the in the game's 'doc\InSim.txt' file.

Although the packets can only be sent by LFS using UDP, each packet provides a timestamp in order for you to verify the order. It must be noted as well that both OutSim and OutGauge packets will only be sent if you are viewing the car from cock-pit mode! Note the ID attribute of both OutSim and OutGauge packets is only present if set the 'cfg.txt' file.

OutSim

To instruct LFS to send OutSim packets, update this section of your 'LFS\cfg.txt' file:

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

Here is an example of receiving OutSim packets using Python.

import socket
import struct

# Create UDP socket.
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Bind to LFS.
sock.bind(('127.0.0.1', 30000))

while True:
    # Receive data.
    data = sock.recv(256)

    if not data:
        break # Lost connection
  
    # Unpack the data.
    outsim_pack = struct.unpack('I12f3i', data)
    time = outsim_pack[0]
    angvel = [outsim_pack[1], outsim_pack[2], outsim_pack[3]]
    header = outsim_pack[4]
    pitch = outsim_pack[5]
    roll = outsim_pack[6]
    accel = [outsim_pack[7], outsim_pack[8], outsim_pack[9]]
    vel = [outsim_pack[10], outsim_pack[11], outsim_pack[12]]
    pos = [outsim_pack[13], outsim_pack[14], outsim_pack[15]]

# Release the socket.
sock.close()

OutGauge

To instruct LFS to send OutGauge packets, update this section of your 'LFS\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

Here is an example of receiving OutSim packets using Python.

import socket
import struct

# Create UDPO socket.
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Bind to LFS.
sock.bind(('127.0.0.1', 30000))

while True:
    # Receive data.
    data = sock.recv(256)

    if not data:
        break # Lost connection
  
    # Unpack the data.
    outgauge_pack = struct.unpack('I3sxH2B7f2I3f15sx15sx', data)
    time = outgauge_pack[0]
    car = outgauge_pack[1]
    flags = outgauge_pack[2]
    gear = outgauge_pack[3]
    speed = outgauge_pack[5]
    rpm = outgauge_pack[6]
    rutbo = outgauge_pack[7]
    engtemp = outgauge_pack[8]
    fuel = outgauge_pack[9]
    oilpressure = outgauge_pack[10]
    oiltemp = outgauge_pack[11]
    dashlights = outgauge_pack[12]
    showlights = outgauge_pack[13]
    throttle = outgauge_pack[14]
    brake = outgauge_pack[15]
    clutch = outgauge_pack[16]
    display1 = outgauge_pack[17]
    display2 = outgauge_pack[18]

    print throttle

# Release the socket.
sock.close()