如何在Python代码中使用导入的xsensdeviceapi64.dll类和函数?

huangapple go评论101阅读模式
英文:

How to use imported xsensdeviceapi64.dll classes and functions in Python code?

问题

From Xsens Device API documentation:

>The C++ interface is not available in compiled form but is provided as part of the SDK as source code that is incorporated in the C header files. This C++ interface code implements a convenience wrapper around the C API. This means that the developer does not have to deal with memory management (i.e. easy object-lifetime management) as the class implementation takes care of this.
>
>The API comprises of two C-interface libraries that are supplied for MS Windows (32 and 64 bit) and Linux. These are:
XsTypes that contains generic types (vectors, matrices, quaternions, etc.) and some basic operations on those types.Xsens Device API that contains the access to functionality as implemented in Xsens devices. The Xsens Device API library depends on the XsTypes, while XsTypes is an independent library.

So I import xsensdeviceapi64.dll to my Python 3.8.10 code:

import os
xda = os.add_dll_directory(r'C:\path\xsensdeviceapi64.dll')

However, this line

class XdaCallback(xda.XsCallback):

throws an error when trying to create a class based on XsCallback Xsens Device API class:

builtins.AttributeError: '_AddedDllDirectory' object has no attribute 'XsCallback'

XsCallback is a clearly documented Xsens Device API class and I have a working code for Linux (Linux works with a Python wheel file, this code is for Windows) so there is no question about that. I tried also with xsensdeviceapi_csharp64.dll and xsensdeviceapi_com64.dll which come with the Software Development Kit Windows download, in addition to using an import of xstypes64.dll with the api imports, but it didn't make any difference. Also renaming the ...dll files to ...pyd did not help.

Why doesn't this work? How can I access the API classes and functions in Windows using Python 3.8.10?

英文:

From Xsens Device API documentation:

>The C++ interface is not available in compiled form but is provided as part of the SDK as source code that is incorporated in the C header files. This C++ interface code implements a convenience wrapper around the C API. This means that the developer does not have to deal with memory management (i.e. easy object-lifetime management) as the class implementation takes care of this.
>
>The API comprises of two C-interface libraries that are supplied for MS Windows (32 and 64 bit) and Linux. These are:
XsTypes that contains generic types (vectors, matrices, quaternions, etc.) and some basic operations on those types.Xsens Device API that contains the access to functionality as implemented in Xsens devices. The Xsens Device API library depends on the XsTypes, while XsTypes is an independent library.

So I import xsensdeviceapi64.dll to my Python 3.8.10 code:

import os
xda = os.add_dll_directory(r'C:\path\xsensdeviceapi64.dll')

However, this line

class XdaCallback(xda.XsCallback):

throws an error when trying to create a class based on XsCallback Xsens Device API class:

builtins.AttributeError: '_AddedDllDirectory' object has no attribute 'XsCallback'

XsCallback is a clearly documented Xsens Device API class and I have a working code for Linux (Linux works with a Python wheel file, this code is for Windows) so there is no question about that. I tried also with xsensdeviceapi_csharp64.dll and xsensdeviceapi_com64.dll which come with the Software Development Kit Windows download, in addition to using an import of xstypes64.dll with the api imports, but it didn't make any difference. Also renaming the ...dll files to ...pyd did not help.

Why doesn't this work? How can I access the API classes and functions in Windows using Python 3.8.10?

答案1

得分: 0

在Movella MTi产品软件套件中有适用于Python的Wheel文件。我已经下载了MTw Awinda软件套件,因为我正在为的项目使用MTw传感器和Awinda Dongle。

https://www.movella.com/support/software-documentation

英文:

There are wheel files for Python in Movella MTi Products Software Suite. I had downloaded MTw Awinda Software Suite because the project I'm programming for uses MTw sensors and Awinda Dongle.

https://www.movella.com/support/software-documentation

huangapple
  • 本文由 发表于 2023年5月18日 02:52:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76275357.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定