Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing existing device metadata while running in docker, until device is removed and then added #35

Open
tcochunk opened this issue Jan 21, 2024 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@tcochunk
Copy link

I have downloaded your latest version 11.1.0.1 and it is working GREAT on the Raspberry PI....THANK YOU for all your effort on issue #29

Now, I am trying to run the application within a docker container. When the application first loads up, I list out all the connected devices. When the devices are listed they are missing all the meta data, but I need the device information when the container is first turned on for all the connected devices:
image

Within the container, if I unplug and plug in the device, the meta data shows up during the add event (but not until i remove and add the device):
image

However, when i run it directly on the PI, the data shows up immediately when the program starts.
image

Interestingly, in both scenarios (container and on pi directly) the existing device counts are 0 and then all the devices get "Added"

My containers Image is based on mcr.microsoft.com/dotnet/runtime:7.0.15-bullseye-slim-arm64v8
and then i install udev and setup some udev rules:

RUN apt-get update -y && \
apt-get install -y udev usbutils && \
echo '\
ACTION=="add", RUN+="mknod %N c %M %m"\n\
ACTION=="remove", RUN+="rm %N"\n\
' > /etc/udev/rules.d/99-togglePico.rules

The container is run in privilege mode. My understanding is that if i run in privilege mode, I dont have to map any devices or volumes but maybe i am wrong.
sudo docker run -it --privileged usb_test_image

and the udev service is restarted before my program is run:
cmd service udev restart && ./USBDetectionTesting

I suspect I am missing some basic dependency in the container but cant figure out what i am missing so your code can find the meta data of the existing devices.

Any help/insight would be appreciated.

@Jinjinov
Copy link
Owner

Jinjinov commented Jan 21, 2024

Uf, this sounds like a complicated problem. I don't have much experience with Docker...

The good news is that I bought a Raspberry Pi 5 last month :)

The bad news is that I have a LOT of things that I have to do right now and I don't have the time to investigate this...

If there were no events at all, I would suggest looking into UDEV, if it is properly installed. But since you said that it works after you remove and insert it again, I have no ideas what you could do...

The only thing I can think of right now is that you try debugging the native C code in Docker, if that is possible... that code is the only place that can give you any clues about the problem...

EnumerateDevices finds existing devices:
https://github.com/Jinjinov/Usb.Events/blob/master/Usb.Events/Linux/UsbEventWatcher.Linux.c#L162

Set a breakpoint where it is called in StartLinuxWatcher:
https://github.com/Jinjinov/Usb.Events/blob/master/Usb.Events/Linux/UsbEventWatcher.Linux.c#L310

After that, the MonitorDevices is called where the code runs continuously inside a while loop...

@Jinjinov Jinjinov added the help wanted Extra attention is needed label Feb 11, 2024
@Jinjinov Jinjinov pinned this issue Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants