Log in

View Full Version : Access USB from Java


AlexBrinister
14-01-2015, 16:54
Hi all,

I would like to inquire about accessing the USB port from Java. How would one go about doing that?

My idea is to write a Linux kernel module to transport data from a coprocessor handling video camera data to the roboRIO via USB. Provided that I do this, how would I go about accessing said USB data from Java on the roboRIO?

PS: I want to use a coprocessor to handle video data because I want to run heavy openCV code to handle the camera feed. Despite the fact that the roboRIO is a dual-core processor, I am afraid of the 667 MHz clock rating being too slow to run the robot and the vision processing code without causing some hiccups.

Alex Brinister

Joe Ross
19-01-2015, 13:23
Why not use a more supported communication method, like I2C, SPI, or ethernet? What coprocessor are you using?

I would assume that someone who's smart enough to write a kernel module would also be able to figure out how to access that data in java. I don't know how to do either.

Pault
19-01-2015, 20:04
Create a SerialPort object and select kUSB in the constructor.

AlexBrinister
20-01-2015, 09:15
I was thinking about an Intel NUC we have sitting around. It has an i3 processor and we have used it in the past for vision processing with success.

I don't yet actually know how to write a kernel module but I was going to learn. We have had issues using Ethernet for that type of thing in competition. There are a lot of hiccups processing the data.

Thanks, Pault.

Alex Brinister

jhersh
21-01-2015, 14:03
PS: I want to use a coprocessor to handle video data because I want to run heavy openCV code to handle the camera feed. Despite the fact that the roboRIO is a dual-core processor, I am afraid of the 667 MHz clock rating being too slow to run the robot and the vision processing code without causing some hiccups.

It sounds like you are adding a lot of complexity based on a gut feeling that you can't accomplish your goals with the hardware you already have on the robot. You are likely to have far more hiccups writing drivers and software on multiple boards than you will simply writing it all in one process if you have the processing power. I would recommend trying to implement your solution on a single device first and only expand if actually needed. If you do expand, use a standard way to communicate. Network Tables over Ethernet is the recommended way from WPI. You can emulate Ethernet over USB (i.e. no driver to write) if you plug the roboRIO USB device port into your Intel board's USB host port and still use Network Tables.