1 (edited by timothyp 2019-03-18 21:16:21)

Topic: DeviceList.Local.Changed not triggered on Linux without modifications

Without modification `DeviceList.Local.Changed` does not get triggered on Ubuntu 18.04

Filename: `LinuxHidManager.cs`
Line: ~69

This is the code in the current version

if (0 != (fds[0].revents & (NativeMethods.pollev.ERR | NativeMethods.pollev.HUP | NativeMethods.pollev.NVAL))) { break; }                       
if (0 != (fds[0].revents & NativeMethods.pollev.IN))
{                                
    IntPtr device = NativeMethodsLibudev.Instance.udev_monitor_receive_device(monitor);
    if (device != null)
    {                                    
        NativeMethodsLibudev.Instance.udev_device_unref(device);
        DeviceList.Local.RaiseChanged();
    }
}

The following line never returns true:

if (0 != (fds[0].revents & NativeMethods.pollev.IN))

However, if I disable this check I get proper change notification and no exceptions.
Basically, the following version works:

if (ret == 1)
{

    if (0 != (fds[0].revents & (NativeMethods.pollev.ERR | NativeMethods.pollev.HUP | NativeMethods.pollev.NVAL))) { break; }                       

                                   
   IntPtr device = NativeMethodsLibudev.Instance.udev_monitor_receive_device(monitor);
    if (device != null)
    {                                    
        NativeMethodsLibudev.Instance.udev_device_unref(device);
        DeviceList.Local.RaiseChanged();
    }
   
}

Do you see any issue with this?

PS: Again, it would be really great if you had an official git repo for this, it is such a useful project.

2

Re: DeviceList.Local.Changed not triggered on Linux without modifications

Very odd. What is revents returning for you, then?
Also, is it blocking in poll in your version, or blocking in udev_monitor_receive_device? Thanks!