Access USB device from Ruby on Rails web app

87 views
Skip to first unread message

Adi bm

unread,
Jan 23, 2018, 2:46:01 AM1/23/18
to Ruby on Rails: Talk

I have a Ruby on Rails web app via which I want to access my smart card reader connected to my PC via a USB.

The idea is to press a button in the web app to initiate read action in the card reader.[I have a ruby script to read the data serially].I however want to extend the functionality to the web app,i.e. when the user clicks the read button on the webapp the card details are read via the card reader and displayed in the web page(Ruby on Rails web app). I am not sure on how to go about it. These are some of the "sources" that I have encountered online which might be the possible way:

WebUSB API
chrome.usb
libusb

Anyone who has previously done the same please guide me on how to go about it.

Colin Law

unread,
Jan 23, 2018, 4:00:59 AM1/23/18
to Ruby on Rails: Talk
On 22 January 2018 at 22:34, Adi bm <adity...@gmail.com> wrote:

I have a Ruby on Rails web app via which I want to access my smart card reader connected to my PC via a USB.

The idea is to press a button in the web app to initiate read action in the card reader.[I have a ruby script to read the data serially].I however want to extend the functionality to the web app,i.e. when the user clicks the read button on the webapp the card details are read via the card reader and displayed in the web page(Ruby on Rails web app). I am not sure on how to go about it. These are some of the "sources" that I have encountered online which might be the possible way:

Are you saying that you want a web page running in a browser has access to your card reader?  Do you think it is a good idea to allow the browser to do that?  What about a malicious website doing it and sending your card details across the internet?

Colin

Rafael Belo

unread,
Jan 23, 2018, 7:14:56 AM1/23/18
to Ruby on Rails: Talk
If you want to send card data through a device, I don't think ruby will do that for you, instead you have to delegate this to browser, because it must be a client process and ruby works from server side.
Everything that you have to do by client side, you should do through browser API and to use ruby (or any backend lang) to process these data.

kopf1988

unread,
Jan 24, 2018, 9:16:13 PM1/24/18
to Ruby on Rails: Talk
Rails & Ruby aren't going to be what you need for this. You'll need some kind of library probably in C/C++/etc that runs on the host computer. The best way is to make that app respond to http web inquiries, and then it will run the appropriate native code and return the result as if it were a web page.
Reply all
Reply to author
Forward
0 new messages