OpenZWave / openzwave-dotnet-uwp

An Open-ZWave wrapper for use with .NET or UWP apps
Apache License 2.0
45 stars 27 forks source link

Support for Mono on Raspberry / Raspbian #18

Closed stmax82 closed 6 years ago

stmax82 commented 6 years ago

Is there a way to make this work on a Raspberry (Linux / Raspbian) using Mono?

There's a package called "libopenzwave1.5" that can be installed using apt:

pi@raspberrypi:~/openzwave $ apt-cache search openzwave
libopenzwave-doc - documentation for the openzwave library
libopenzwave1.5 - API to use a Z-Wave controller
libopenzwave1.5-dev - header files for the openzwave library
openzwave - Sample Program for libopenzwave

Currently the problem is that the OpenZWaveDotNet.dll contains native code (instead of [DllImort]ing a shared library) and thus cannot be executed on Linux / Mono:

pi@raspberrypi:~/openzwave $ mono ZWaveTest3.exe
Method '<Module>:_getFiberPtrId ()' in assembly '/home/pi/openzwave/OpenZWaveDotNet.dll' contains native code that cannot be executed by Mono on this platform. The assembly was probably created using C++/CLI.

Unhandled Exception:
System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load.
dotMorten commented 6 years ago

Nope it would require a significant rewrite from scratch to support that, since the library is native and not a C API Wrapper. You could instead install Windows 10 on your raspberry and build a UWP startuptask. This has been working really great for me.

stmax82 commented 6 years ago

Yes I had a look at the code and it doesn't seem to be an easy task to do. I thought about switching to Win 10 IoT but that's not going to work due to other software we have to run.. too bad.. this library seems to be the most stable one of those available for .NET. Thanks anyway!