nettrom / forza_motorsport

Various utilities to work with data streams from the Forza Motorsport and Forza Horizon games.
MIT License
52 stars 11 forks source link

struct.error: unpack requires a string argument of length 311 #7

Open egrissino opened 5 years ago

egrissino commented 5 years ago

CRS-Lockout:forza_motorsport-master evangrissino$ python data2file.py 2048 forza_data Traceback (most recent call last): File "data2file.py", line 194, in main() File "data2file.py", line 189, in main args.packet_format, args.config_file) File "data2file.py", line 129, in dump_stream fdp = ForzaDataPacket(message, packet_format = packet_format) File "/Users/evangrissino/Documents/Programming/forza_motorsport-master/fdp.py", line 104, in init unpack(self.dash_format, data)): struct.error: unpack requires a string argument of length 311

Running on MacBook pro with python 2.7.15 from terminal. Netgear Nighthawk router as access point on xfinity network. Forza ip set 10.0.0.171:2048

gnoshme commented 4 years ago

Ditto.

gnoshme commented 4 years ago

CRS-Lockout:forza_motorsport-master evangrissino$ python data2file.py 2048 forza_data Traceback (most recent call last): File "data2file.py", line 194, in main() File "data2file.py", line 189, in main args.packet_format, args.config_file) File "data2file.py", line 129, in dump_stream fdp = ForzaDataPacket(message, packet_format = packet_format) File "/Users/evangrissino/Documents/Programming/forza_motorsport-master/fdp.py", line 104, in init unpack(self.dash_format, data)): struct.error: unpack requires a string argument of length 311

Running on MacBook pro with python 2.7.15 from terminal. Netgear Nighthawk router as access point on xfinity network. Forza ip set 10.0.0.171:2048

Wait.. are you trying to use it with Horizon 4? I see in the code there's a new option for packet_format of packet_format: fh4

that solves this.

ChadSpeedburger commented 4 years ago

Had the same issue and eventually realised Forza 7 defaults to "sled" format. Change this option (at the end of the HUD options list) to "dash" and it all works!

kirkofthefleet commented 4 months ago

I hope this project is still getting some attention. I am attempting to use this script with Forza Motorsport 8 and am getting the following error: root$ ./data2file.py -c config.yml 5005 output.csv Traceback (most recent call last): File "/root/scripts/forza_motorsport-master/./data2file.py", line 194, in <module> main() File "/root/scripts/forza_motorsport-master/./data2file.py", line 188, in main dump_stream(args.port, args.output_filename, args.format, args.append, File "/root/scripts/forza_motorsport-master/./data2file.py", line 129, in dump_stream fdp = ForzaDataPacket(message, packet_format = packet_format) File "/root/scripts/forza_motorsport-master/fdp.py", line 104, in __init__ unpack(self.dash_format, data)): struct.error: unpack requires a buffer of 311 bytes

My configuration file looks as follows: ` port: 5005 output_filename: forza_data.csv format: csv append: False packet_format: dash parameter_list:

I have tried setting Forza to both Dash and Sled formats with no success. Both give back the same error message.

Is there something I am doing wrong here or is FM8 incompatible with this script?

In case that output above looks as bad as it looks in the preview, here is the error: root$ ./data2file.py -c config.yml 5005 output.csv Traceback (most recent call last): File "/root/scripts/forza_motorsport-master/./data2file.py", line 194, in main() File "/root/scripts/forza_motorsport-master/./data2file.py", line 188, in main dump_stream(args.port, args.output_filename, args.format, args.append, File "/root/scripts/forza_motorsport-master/./data2file.py", line 129, in dump_stream fdp = ForzaDataPacket(message, packet_format = packet_format) File "/root/scripts/forza_motorsport-master/fdp.py", line 104, in init unpack(self.dash_format, data)): struct.error: unpack requires a buffer of 311 bytes

nettrom commented 4 months ago

Hi @kirkofthefleet , and thanks for testing this with FM8! I just did some testing on my end and figured out what settings are needed to make it work.

In your configuration file, use packet_format: fh4

In the game settings, set the the Data Out Packet Format to Car Dash.

I’ve also looked at the current data out documentation, and noticed that there are fields we’re missing such as for tyre wear and track ID. I’ll open a separate issue for that and see if I can do some testing and update the code to include those.