What's likely happening is that SignalData
is indirectly changing the subscribers dictionary under the hood during the loop and leading to that message. You can verify this by changing
foreach(Subscriber s in subscribers.Values)
To
foreach(Subscriber s in subscribers.Values.ToList())
If I'm right, the problem will disappear.
Calling subscribers.Values.ToList()
copies the values of subscribers.Values
to a separate list at the start of the foreach
. Nothing else has access to this list (it doesn't even have a variable name!), so nothing can modify it inside the loop.
The Android emulator is based on QEMU. Even if the emulator version is so ancient, there appears to be support for passing USB devices from the host. It does not seem to be available for ARM devices though, the emulated ARM machine does not have a USB controller. (I have already tried enabling all USB host controllers for the goldfish_armv7 kernel based on Linux 3.4, without luck. The default emulator goldfish_armv7 kernel does not even have Host USB enabled.)
If you are not limited to ARM and can use x86, then I suggest to check out http://www.android-x86.org/, its images can be used with a standard QEMU i386 (or x86_64) machine. This also yields better performance by using the KVM extension on Linux.
To passthrough a USB device with of vendor ID 1234 and device ID abcd, you can run the emulator command:
emulator -avd x86-machine -qemu -usb -usbdevice host:1234:abcd
Or, when using QEMU:
qemu-system-i386 -m 1G -cdrom android-x86.iso -usb -usbdevice host:1234:abcd
You will need read/write permissions for /dev/bus/usb/XXX/YYY
, for that you can create a udev rule such as:
SUBSYSTEM!="usb", GOTO="end_skip_usb"
ATTRS{idVendor}=="1234", ATTRS{idProduct}=="abcd", TAG+="uaccess"
LABEL="end_skip_usb"
Now, upon insertion of the USB device, your emulator should recognize a USB device. This is tested for a Linux installation with a Android x86 4.3 image.
Best Answer
This is possible. There is a project called SharpUSBLib that you should check out. This a wrapper library written in C# to the USBLib for Unix & Linux which is written in C. There is also a port of USBLib to Win32.
One of the things that you may need to be aware of is that you may not need the SharpUSBLib depending on what type of USB device you are trying to talk to. For instance, most USB HIDs (Human Interface Device) like Keyboards and Mice are full Plug'n'Play capable and require no drivers or interface libs. I have a small USB Unitech barcode scanner which when plugged into the USB port works like a keyboard and the system (both Linux and Win32) see it as a HID.