storing nfc tag in client pc webpage

43 views
Skip to first unread message

Patrick Yudi

unread,
Nov 22, 2014, 1:22:39 AM11/22/14
to rubyonra...@googlegroups.com
hi.

i'm new to ruby on rails. at the moment i'm developing web app with
acr122u and iso/iec 14443a card.
i want client pc to open web page, swipe cards, lookup tags which is
already in the database then bring back some data to the page.
i'd already tried gem nfc or nfc-eventd, both of them can read tags
continuously.
but how do i pass the tag to a page or look it up in database?

thanks

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Nov 22, 2014, 4:24:42 AM11/22/14
to rubyonra...@googlegroups.com
On 22 November 2014 06:22, Patrick Yudi <li...@ruby-forum.com> wrote:
> hi.
>
> i'm new to ruby on rails. at the moment i'm developing web app with
> acr122u and iso/iec 14443a card.
> i want client pc to open web page, swipe cards, lookup tags which is
> already in the database then bring back some data to the page.
> i'd already tried gem nfc or nfc-eventd, both of them can read tags
> continuously.
> but how do i pass the tag to a page or look it up in database?

I don't know about the tags but if you don't know how to look things
up in a database then I suggest working right through a good rails
tutorial such as railstutorial.org (which is free to use online) which
will show you the basics of rails. Then when you have found how to
work the card reader you will know how to deal with it in rails.

Colin

Patrick Yudi

unread,
Nov 27, 2014, 4:31:37 AM11/27/14
to rubyonra...@googlegroups.com
maybe its too wide.. let me simplify.
i have a ruby script that reads NFC tags:

require 'nfc'

ctx = NFC::Context.new
dev = ctx.open nil

loop do

p dev.pool.to_s

end

par example the output in the terminal is 'c2 f3 44 12'.

i also have a webform with a text field with label "id".

how do i pass the output to id.text_field? or... is it possible?

Colin Law

unread,
Nov 27, 2014, 4:55:17 AM11/27/14
to rubyonra...@googlegroups.com
On 27 November 2014 at 09:30, Patrick Yudi <li...@ruby-forum.com> wrote:
> maybe its too wide.. let me simplify.
> i have a ruby script that reads NFC tags:
>
> require 'nfc'
>
> ctx = NFC::Context.new
> dev = ctx.open nil
>
> loop do
>
> p dev.pool.to_s
>
> end
>
> par example the output in the terminal is 'c2 f3 44 12'.
>
> i also have a webform with a text field with label "id".
>
> how do i pass the output to id.text_field? or... is it possible?

Are you asking how to run a ruby script from the web browser, where
the script directly accesses hardware on the computer?

Colin

Patrick Yudi

unread,
Nov 27, 2014, 5:14:21 AM11/27/14
to rubyonra...@googlegroups.com
that's an alternative i thought before.. but yes.

Colin Law

unread,
Nov 27, 2014, 5:32:00 AM11/27/14
to rubyonra...@googlegroups.com
On 27 November 2014 at 10:12, Patrick Yudi <li...@ruby-forum.com> wrote:
> that's an alternative i thought before.. but yes.

Please quote the previous message when replying so that it is easier
to follow the thread. Someone seeing your reply will not know what
you it is that you are saying yes to. Thanks.

I believe it is normally not possible to access hardware from the
browser. Would you want a web page you visit messing with the
hardware on your PC.

One option for you is to write an app that runs on the PC that fetches
the data and posts it to the rails server directly. There may be
other alternatives.

I don't understand what you mean when you say "that's an alternative i
thought before". Alternative to what?

Colin
Reply all
Reply to author
Forward
0 new messages