card reader or bar code reader in rails ? URGENT HELP

hai all how to manipulate (read/write) card readers (or bar code reader ) in rails project ? give me any sample code ,tutorials ,tools, etc .

i am new to this card reader category its very urgent

thank you .

Is there a card reader or bar code reader attached to your webserver?

Most card readers that I've seen (for barcodes, at least) simply scan an object and return a number. You could do whatever you want with the number.

-Kyle

Most readers I've played with come in two varieties: Keyboard Wedge or RS-232 Serial.

Keyboard Wedge -- these are probably the most common type in use today since PC hardware is so damned cheap. They look like a keyboard, and actually type out the numbers. You can usually program what they send before and after a bar code or credit card is read, so you could (for instance) send some codes to focus on the right input field, where the number will just be typed as any other keyboard input would go. I also suspect some clever Javascript might help here.

Serial types are usually driven by a central server or some other special driver on a local machine. For example, I've had up to 32 serial barcode scanners tied into one machine before, each doing inventory processing. The user would scan in the box, then scan in a quantity from a card they had. This is probably not what you mean though when you want to use it with Rails.

This is where a real application (written in Java, C++, or whatever) would work better than a Web application. If you really want to limit people to using IE (like so many do...) then you can write an ActiveX based application, but that's not really Rails anymore. You can also just require the user to focus on the right field when scanning / swiping, but that is going to cause errors.

--Michael

I just evaluated and purchased bar code readers and after buy and returning 3 different models, I highly recommend the Intermec SR30 (P/ N 225-728-001)

They are windows Plug and Play, USB and your software will not know that the user did not type in the info.

Suggested retail price of about 299.00

I hate to sound like a salesman, but I am a very happy customer

That means these are "keyboard wedge" types.

They are probably by far the easiest to handle when a web browser is the application in use. However, it is still necessary to either have the user focus on the right field, have a screen used just for scanning (a pop-up Javascript window, etc) or have some way to make the keyboard wedge scanner focus the display.

Most sites I've seen recently will use the Javascript pop-up modal window method, which will ask the user to scan / swipe, and the "submit" button will automatically be pressed. This also allows manual entry of some data.

Just remember, most credit card swipes won't really be human readable, and you have to be prepared for this. The readers I use (Scanteam models of various types) are all keyboard wedge or serial, and they frame the credit card, check MICR, or barcodes well, and are easily to process.

I also have several serial-only 2c barcode scanners made by Symbol, which will read 1D and 2D barcodes in common use, as well as take (rather crappy) photos. :slight_smile:

AndyV wrote:

Is there a card reader or bar code reader attached to your webserver?

On Mar 24, 1:10 am, Pokkai Dokkai <rails-mailing-l...@andreas-s.net>

yes

How is it attached to your web server machine, via serial or USB?

Michael Graff wrote:

How is it attached to your web server machine, via serial or USB?

On Tue, Mar 25, 2008 at 12:32 AM, Pokkai Dokkai

through USB Port

Gan you give us more specifics on the scenario and what you are trying to accomplish here?

This is kinda unusual.

OK, so from what I understand, you have:

A web server running RoR, with a USB-connected bar code or other scanner.

A client which may or may not be running on the same machine.

You want the client to see data coming in from the bar code scanner.

This is a rather unusual situation, as most bar code scanners will typically connect to the client machine. If they are the same machine, I could see what you're wanting to do, but really the server part doesn't come into play at all -- the USB scanner will look like someone is typing into the browser.

If you really want to read a "remote" scanner from the client somehow, then you need to have some way (in Ruby or callable from Ruby) to read server keyboard input or to talk to the USB scanner in some other manner.

If the device looks like a serial port this is fairly easy to do, but if it looks like a keyboard, this is going to be hard.

I have used a barcode reader attached to a usb port to read label to a text file. Once I am done the barcoding. I save the file and then upload that to the application. I then read the file, parse and process the information. Let me know if you are interested in any piece of that code and I will send it to you.

Gan you give us more specifics on the scenario and what you are trying to accomplish here?

This is kinda unusual.

This was basically my point. If the barcode reader were on the client (browser) end then you 'd never know. The USB/wedge/RS-232 would pass straight through STDIN and the webserver would have no clue that it wasn't keyed from a keyboard.

The same is essentially true on the webserver... but I'm not sure why you'd be doing it.

saljamil wrote:

I have used a barcode reader attached to a usb port to read label to a text file. Once I am done the barcoding. I save the file and then upload that to the application. I then read the file, parse and process the information. Let me know if you are interested in any piece of that code and I will send it to you.

thank you for the help ...

this is exactly what i want. my client machine have one bar code reader which is connected through USB Port. In client browser html form has lots of text_fields one of that is register_no. When the cursor point that register_no text_field, that time the barcode reader should read a ID card (which have registration_no,etc,..those are encrypted in barcode styles). And the corresponding registration_no text_filed should be filled automatically .that is my requirement.

thank you for your help

how to get the barcode input into browser javascripts code ? how to parse it to corresponding values ?

saljamil wrote:

I have used a barcode reader attached to a usb port to read label to a text file. Once I am done the barcoding. I save the file and then upload that to the application. I then read the file, parse and process the information. Let me know if you are interested in any piece of that code and I will send it to you.

thank you can you send me the source code what you have ?

Here is the controller methods:

def load_file   @data_loads=DataLoad.find(:all,:conditions => ["organization_id in (?)",session[:org_ids]]) end def load_data   if params[:csv_file].class==StringIO     @file=File.new("temp1","w")     params[:csv_file].each_line do |line|       @file.puts line     end     @file.close   else     @file=params[:csv_file]   end   i=0   @data_load=DataLoad.find(params[:load_header])

    #load physical records here     arr=Array.new     cable_link=Hash.new     File.open("temp1","r") do |f|       arr=IO.readlines("temp1")     end     j=0     for i in 0...arr.length       b_data=arr[i].split("-")       case b_data[0]       when "RP"

dc=Datacenter.find(:first, :conditions=>["short_name=?",b_data[1]])         dcroom=Dcroom.find(:first, :conditions=>["name=? and datacenter_id=?",b_data[2],dc.id])         dcrack=Dcrack.find(:first, :conditions=>["name=? and dcroom_id=?",b_data[3],dcroom.id])         rp=b_data[4].delete("*").to_i #rack position (integer)       when "AS"         asset=Server.find(:first, :conditions=>["name=? and organization_id in (?)",b_data[1].delete("*\n"),session[:org_ids]])         @pi=PhysicalItem.new         @pi.data_load_id=@data_load.id         @pi.created_by=session[:user_id]         @pi.asset_type="Server"         @pi.dcrack_id=dcrack.id         @pi.rack_position=rp         @pi.asset_id=asset.id         if @pi.save           j+=1         end         last_asset="server"         rp=rp+asset.server_type.height       when "AC" # Console         cnsole=Console.find(:first, :conditions=>["name=? and organization_id in (?)",b_data[1].delete("*\n"),session[:org_ids]])         @pi=PhysicalItem.new         @pi.data_load_id=@data_load.id         @pi.created_by=session[:user_id]         @pi.asset_type="Console"         @pi.dcrack_id=dcrack.id         @pi.rack_position=rp         @pi.asset_id=cnsole.id         if @pi.save           j+=1         end         last_asset="console"         rp=rp+cnsole.rus       when "C" #Cable         c_num=b_data[1].delete("*\n")         if cable_link[c_num].nil?           cable_link[c_num]=Array.new         end         case last_asset # we need to expand this to all asset classes         when "console"           cable_link[c_num][1]=cnsole.id         else           cable_link[c_num][0]=asset.id         end       end     cable_link.each_key {|k|         pi=PhysicalItem.find(:first, :conditions=>["asset_id=? and data_load_id=?",cable_link[k][0],@data_load.id])         pi.console_id=cable_link[k][1]         pi.save       }     flash[:notice] = j.to_s+' Physical records were loaded successfully.'     redirect_to :controller=> 'inventory', :action => 'list_physical_items', :id=>@data_load   end end

and here is the view:

<fieldset class='w450'>   <legend>Please select file to upload</legend> <%= form_tag({:action=>:load_data}, :multipart => true)%>       <p><label for="csv_file"> File to Upload:</label>       <%=file_field_tag 'csv_file', :size=>30 %></p>       <p><label for="load_header">Select Data Load:</label>       <select id="load_header" name="load_header">         <%=options_for_select(@data_loads.collect{|p|[p.name, p.id]})%>       </select></p>       <%= submit_tag 'upload it' %> <%=end_form_tag%> </fieldset>

When the cursor is on the form field register_no, the user should "swipe" the card. This will fill the field with the code from the card. This is totally transparent to your Rails application, since not even the browser knows that data is coming from a barcode reader. You see, the way a simple barcode reader works is that when you swipe the card, it sends to the keyboard port on your computer the electric signals for the numbers, so probably not even your computer can tell if those signals are coming from the keyboard or what. It is essentially the same thing as you typing in your phone number or your name, only its done "instantly" as you swipe the card.

If it is a USB reader, it is a little bit different on how it does it's magic, but the way you interact with it should be the same. Have you tried creating a simple HTML form with the field, positioning the cursor on the field and swiping the card? It should work.

saljamil wrote:

Here is the controller methods:

On Mar 25, 11:39�pm, Pokkai Dokkai <rails-mailing-l...@andreas-s.net>

thank you saljamil to give the source code

thank you to all..

Hi ! I've just visited this forum. Happy to get acquainted with you. Thanks.