tjensen / fsuipc

Python client wrapper for FSUIPC
MIT License
15 stars 0 forks source link

Error from PyCapsule #1

Closed Matthewli623 closed 4 years ago

Matthewli623 commented 4 years ago
  1. After Installing the fsuipc by "pip install fsuipc" , I tried to run below script and i got the below error.

C:\Users\user\Documents\GitHub\PythonPlayground>C:/Users/user/AppData/Local/Programs/Python/Python37-32/python.exe c:/Users/user/Documents/GitHub/PythonPlayground/testbat.py Traceback (most recent call last): File "c:/Users/user/Documents/GitHub/PythonPlayground/testbat.py", line 27, in latitude, longitude, altitude = prepared.read() AttributeError: 'PyCapsule' object has no attribute 'read'

from fsuipc import FSUIPC
with FSUIPC() as fsuipc:
    prepared = fsuipc.prepare_data([
        (0x560, "l"),
        (0x568, "l"),
        (0x570, "l")
    ], True)

    while True:
        latitude, longitude, altitude = prepared.read()

        print(f"Latitude: {latitude}")
        print(f"Longitude: {longitude}")
        print(f"Altitude: {altitude}")

        input("Press ENTER to read again")
  1. Apart from download it from github , I have downloaded fsuipcSDK .I am able to use it but it is a bit slow which take 200 ms to read or write data.Is there any way to improve the speed?

Thank you!

tjensen commented 4 years ago

Hi @Matthewli623. The version you downloaded from PyPI was an alpha release, which had a different interface from what is currently shown in the README on GitHub.

Good news, however! I just published version 1.0.0, which should enable you to run the example code. Please upgrade your installation by running the command:

pip install -U fsuipc

Regarding your question about the performance, I'm seeing individual read calls take about 4 or 5 ms to complete when I run the following code against Flight Simulator X:

import timeit

from fsuipc import FSUIPC

NUM_READS = 1000

with FSUIPC() as fsuipc:
    prepared = fsuipc.prepare_data([
        (0x560, "l"),
        (0x568, "l"),
        (0x570, "l")
    ], True)

    duration = timeit.timeit(prepared.read, number=NUM_READS)

    print(f"Duration: {duration} seconds ({duration / NUM_READS} seconds per read)")

Can you share the code you are running to get the 200 ms measurement? Also, I'm wondering if other simulator versions may give very different results.

tjensen commented 4 years ago

Hi @Matthewli623. One week has passed without any activity, so I am assuming that upgrading fsuipc has fixed your issue and that you no longer need assistance. Thanks.