Samurai2083
Posts: 1
Joined: Tue Mar 06, 2018 8:58 am

How to capture USB input on Raspberry Pi 3

Tue Mar 06, 2018 9:19 am

I've spent several days trying to figure this out, if anyone can help me I'd greatly appreciate it.

I have a Raspberry Pi 3 running Windows 10 IoT. I have a RFID reader attached to the Raspberry Pi via USB. My goal is to simply capture the FOB ID when it is scanned by the reader.

This reader really only acts like a keyboard. When I scan the FOB, the ID will output on the command line.

I've gone through a ton of examples and samples capturing input, but nothing will actually see the RFID device. I can't find it in the list of SerialDevices, nor can I find it in a list of USBDevices.

What I have been able to do is create a UWP with an interface (form) and a TextBox. When running this app on the Raspberry, scanning the FOB will show up in the TextBox. That works fine.

However, I need to run this app as a Background Task (headless) and accept input from the RFID reader. This is where I'm stuck. I thought a simple keyboard event capture would suffice, but I can't figure out how to set the background task in listening mode to read input when it is sent. Perhaps I'm going the wrong direction.

As a starting code I have the following:

Code: Select all

public sealed class StartupTask : IBackgroundTask
{
	private BackgroundTaskDeferral _deferal;

	public void Run(IBackgroundTaskInstance taskInstance)
	{
    	Debug.WriteLine("StartupTask.Run()");

    	_deferal = taskInstance.GetDeferral();
    	taskInstance.Canceled += TaskInstance_Canceled;
	}

	private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
	{
    	Debug.WriteLine("StartupTask.TaskInstance_Canceled() - {0}", reason.ToString());

    	_deferal.Complete();
	}
}
If anyone has an idea on how I can accomplish this, please let me know.

Thank you.

Return to “Windows 10 for IoT”