Plugin development notes for developing or converting a plugin for use on Linux.
The plugins for Linux are EXE plugins, just like Windows. You should be able to supply one plugin that works for both. For example, our HSTouch plugin and X10 plugin are the same for both. The biggest change for Linux is that all filepaths are "/" rather than "\". There is an hs. call you make to HS to find out if you are running on Windows or Linux. We have a function called "FixPath(path)" that simply swaps the slashes.
We do have 2 Z-Wave plugins, but that is because the plugin supports HID devices which is Windows specific, so in the Z-Wave version that is removed.
Also, there is no windows forms, or least we don't depend on them, so you need to wrap any "Application." calls in a class that handles each OS.
There is no "Err" and "Erl" object so you need to wrap those. (mainly used to display line numbers)
To see how close your plugin is, run it through the MOMA app (runs on Windows) and it will point out any .net calls that are not in MONO. Get the app here:
http://www.mono-project.com/MoMA
When you build for Linux, you can build for "Any CPU", although building for X86 seems to work anyway.
When using COM ports, note that there is a bug in the MONO serialport class where if you try to open a non-existent com port, the finalizer on the serialport class throws an exception. The finalizer is run in it's own thread so there is no way to catch this. The fix is to make sure the file exists. In Linux, COM ports are files like "/dev/ttyUSB0". Do this check only if you are on Linux. Here is an example:
The plugins for Linux are EXE plugins, just like Windows. You should be able to supply one plugin that works for both. For example, our HSTouch plugin and X10 plugin are the same for both. The biggest change for Linux is that all filepaths are "/" rather than "\". There is an hs. call you make to HS to find out if you are running on Windows or Linux. We have a function called "FixPath(path)" that simply swaps the slashes.
We do have 2 Z-Wave plugins, but that is because the plugin supports HID devices which is Windows specific, so in the Z-Wave version that is removed.
Also, there is no windows forms, or least we don't depend on them, so you need to wrap any "Application." calls in a class that handles each OS.
There is no "Err" and "Erl" object so you need to wrap those. (mainly used to display line numbers)
To see how close your plugin is, run it through the MOMA app (runs on Windows) and it will point out any .net calls that are not in MONO. Get the app here:
http://www.mono-project.com/MoMA
When you build for Linux, you can build for "Any CPU", although building for X86 seems to work anyway.
When using COM ports, note that there is a bug in the MONO serialport class where if you try to open a non-existent com port, the finalizer on the serialport class throws an exception. The finalizer is run in it's own thread so there is no way to catch this. The fix is to make sure the file exists. In Linux, COM ports are files like "/dev/ttyUSB0". Do this check only if you are on Linux. Here is an example:
Code:
If hs.GetOSType = eOSType.linux Then If Not System.IO.File.Exists(port) Then hs.WriteLog(IFACE_NAME, "Cannot open com port, port does not exist: " & port) gInterfaceStatus.intStatus = IPlugInAPI.enumInterfaceStatus.WARNING gInterfaceStatus.sStatus = "Cannot Open Port." Return "Cannot open com port" End If End If ' now its ok to open the port
Comment