The online racing simulator
[Python] OutSim: struct.error: unpack requires a buffer of 64 bytes
(2 posts, started )
[Python] OutSim: struct.error: unpack requires a buffer of 64 bytes
Hey, I'm new to LFS. I've ran into a problem while trying to use an Outsim example that I got from here: https://en.lfsmanual.net/wiki/OutSim_/_OutGauge?fbclid=IwAR1GBAJr-6HScMo28zpz2H8JfsIVNRqb__ghZzJ4xlzSuk7IU8J-OYuqcew

Here's the code:

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', 25505))

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

if not data:
break # Lost connection
print("pass")
# 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]]
print("pass2")

# Release the socket.
sock.close()

Here's the console output:

pass
pass2
pass
Traceback (most recent call last):
File "test.py", line 18, in <module>
outsim_pack = struct.unpack('I12f3i', data)
struct.error: unpack requires a buffer of 64 bytes

Basically, it runs once (I can grab data in the first iteration), and then it crashes. I'm also new to python so I can't figure out a solution. Can anyone help? Thanks.
I fixed it. Dumb mistake, I had both outsim and outgauge activated and they used the same port.

[Python] OutSim: struct.error: unpack requires a buffer of 64 bytes
(2 posts, started )
FGED GREDG RDFGDR GSFDG