UniPi API - need to use Win 10 IoT or Mono



  • Hello,

    we have uploadet an non Commercial version of the driver for windows 10 IOT

    https://www.nuget.org/packages/adcoso.iot.devicedrivers.neuron.driver/

    kind regards

    Mirco



  • Hello,
    I've downloaded the Windows 10 IOT core drivers using nuget, but the link to the related documentation is dead. Without code examples it is really difficult to start using the driver. Would it be possible to share a couple of examples on how to initiate the driver and read out device related information?
    Kind regards,
    Mario


  • administrators

    Hi @marioverhaeg !

    Unfortunately we do not have local copies of the documentation, to the best of my knowledge. I understand that this is less-than-ideal, however if you still wish to use Windows 10 IoT I recommend extracting the .nupkg with 7zip and loading the library "adcoso.iot.devicedrivers.neuron.driver.dll" inside into ILSpy.

    It works remarkably well for using undocumented C# libraries. Though we would still very much welcome if @mircotoepfer could provide us with some more documentation on how to use the library, which we would then perhaps be able to host ourselves.

    Here is a quick sample of what the ILSpy analysis looks like:

    I hope this helps somewhat


  • administrators

    I may try to provide some examples later myself, but we are a little shorthanded right now unfortunately. I may be able to get back to you about this during or after the christmas period.



  • @tomasknot said in UniPi API - need to use Win 10 IoT or Mono:

    arkably well for using undocumented C# libraries. Though we would still very much welcome if @mircotoepfer could provide us with some more documentation on how to use the library, which we would then perhaps be able to host ourselves.
    Here is a quick sample of what the ILSpy analysis looks like:

    Thank you Tomas. In the meantime I've figured out that the generic Rinsen library for reading out the 1Wire bus works as well on UniPI: https://www.nuget.org/packages/Rinsen.OneWire/

    I was thinking to build my own driver for the other components, but it would save me a lot of work if I can use an existing component :-). I will look into your method as well.


  • administrators

    Hi @marioverhaeg,

    I hope it will be of some help. If you do decide to make use of the existing driver you may also find the dnSpy utility helpful if you wish to make any changes, as it allows directly editing c# binaries, either in c# directly or in the interpreted instruction language underneath. It can also decompile directly into a Visual Studio project, but some manual editing is required afterwards to recompile.

    Another useful tool might be the Patchwork Launcher's OpenAssemblyCreator utility, which allows overloading private parts of any c# binaries by making a copy which has all members declared as public - any binary compiled against such a modified copy will be able to link against a non-modified library as well, since c# member hiding is purely a link-time affair.



  • Hi,
    After some digging around I've actually found the source code including example on github:
    https://github.com/mircotoepfer/unipi-neuron
    I was actually very close to understanding how it should work. The example code included in the project on github is not working (the NeuronDevice object stays empty). I'm still trying to figure out what is happening, but it seems something goes wrong in the GPIO pin-layout.
    When I use the Windows GPIO driver with this pinlayout, and match that to the GPIO pin-layout of the UniPI (according to the technical documentation) I see some inconsistencies as well. For example, GPIO 7 and 8 (should be digital inputs 8 and 9, pull down according to the piyout) are always high, while they are not connected. GPIO 4 (digital input 1) seems to be working (high when not connected, low while connected, pull down).

    2018-12-23 15:44:19.942 +01:00 [INF] GPIO4 value: High
    2018-12-23 15:44:19.957 +01:00 [INF] GPIO17 value: Low
    2018-12-23 15:44:19.974 +01:00 [INF] GPIO27 value: Low
    2018-12-23 15:44:19.990 +01:00 [INF] GPIO23 value: Low
    2018-12-23 15:44:20.005 +01:00 [INF] GPIO22 value: Low
    2018-12-23 15:44:20.021 +01:00 [INF] GPIO24 value: Low
    2018-12-23 15:44:20.037 +01:00 [INF] GPIO11 value: Low
    2018-12-23 15:44:20.052 +01:00 [INF] GPIO7 value: High
    2018-12-23 15:44:20.068 +01:00 [INF] GPIO8 value: High
    2018-12-23 15:44:20.084 +01:00 [INF] GPIO9 value: Low
    2018-12-23 15:44:20.099 +01:00 [INF] GPIO25 value: Low
    2018-12-23 15:44:20.136 +01:00 [INF] GPIO10 value: Low

    I will post some updates here when I've figured things out. The example code is already really helpful but as this is also not working I need to go one level down, which is quite time consuming.



  • Update: the unipi Neuron driver is not suitable for UniPi 1.1. It assumes that all the ports are located on the SPI bus: the Neuron has a different architecture compared to the UniPi. I have the most important things working now (digital inputs, onewire, relays) but still need some work on the analogue inputs and outputs. I will start wrapping things up and will publish a project on github when it's ready. As I'm not a professional software developer it will not be as nice as Mirco's solution, but it should do the trick and provide similar functionality :-).


  • administrators

    Hi @marioverhaeg!

    That's great to hear! We would love to have a look at it once you are happy to have it be public. And thank you for finding the link to the documentation as well, it should be very useful to us in the future.



  • Hi Thomas,
    I've uploaded the driver here:
    https://github.com/marioverhaeg/UniPi
    AnalogueInputs and outputs are not implemented, but digitalinputs, onewire and relays are working. There are some events and some functions to poll information from the board. As said, I'm far from a professional developer but it might help others to understand how to read information from the UniPi. I will try to update the project now and then when I make improvements.