Compare commits

..

No commits in common. "9ec76323d7a4b461b17944097809693dca142283" and "e55927dbe27db96cd5e95b22747d2ca9e4871568" have entirely different histories.

6 changed files with 6 additions and 26 deletions

0
FORZA_METHODS Normal file
View file

View file

@ -1 +0,0 @@
FROZA_DATA_FORMAT = '<iIfffffffffffffffffffffffffffffffffffffffffffffffffffiiiiifffffffffffffffffHBBBBBBbbb'

View file

@ -1 +1 @@
__all__= ["BEAMNG_METHODS","FORZA_METHODS"]
__all__= ["BEAMNG_METHODS"]

View file

@ -7,38 +7,18 @@ from GAME_METHODS import *
COM_PORT = 'COM5'
UDP_IP = "127.0.0.1"
BEAMNG_UDP_PORT = 4444
FORZA_UDP_PORT= 4843
UDP_PORT = 4444
connectedArduino = False
connectedWebSocket = False
gameSelected = False
portToConnect= 0
dataFormat = ""
while gameSelected == False:
gameNo = input("1:BEAMNG\n2:FORZA\n")
if gameNo == "1":
portToConnect = BEAMNG_UDP_PORT
dataFormat =BEAMNG_METHODS.BEAMNG_DATA_FORMAT
gameSelected = True
print("BeamNG Selected")
elif gameNo == "2":
portToConnect = FORZA_UDP_PORT
dataFormat = FORZA_METHODS.FROZA_DATA_FORMAT
print("Forza Selected")
gameSelected=True
else:
print("please select a number from the list")
while connectedWebSocket == False:
try:
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.bind((UDP_IP,portToConnect))
sock.bind((UDP_IP,UDP_PORT))
connectedWebSocket = True
except:
print("please check you are able to open the socket on this system\ntired to open port: "+portToConnect)
print("please check you are able to open the socket on this system")
exit()
while connectedArduino == False:
@ -51,9 +31,10 @@ while connectedArduino == False:
print("ready:\n")
while True:
data, addr = sock.recvfrom(1024)
unpackedData = struct.unpack(dataFormat,data)
unpackedData = struct.unpack(BEAMNG_METHODS.BEAMNG_DATA_FORMAT,data)
carData = BEAMNG_METHODS.unpackData(unpackedData)
kmh=carData["speed"]*3.6
toPi.write(str(kmh).encode()+":".encode())