LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-13-2013, 11:19 PM   #1
bhangale1013ashish
LQ Newbie
 
Registered: Aug 2013
Location: Bangalore-India
Distribution: Ubuntu
Posts: 2

Rep: Reputation: Disabled
How to access USB barcode scanner data directly from USB port using C/C++


Hi Everyone, i am Ashish,

Currently i am working on USB port programming for Linux to fully controll USB ports. I am running Ubuntu 13.04 and i try to read data from ttySX files for USB port and also from /dev/bus/usb. But i am not et any results. I serach online for that so i find ttyUSBX port but in my case there no tty like that. Also problem is that, the manufacturer of USB barcode scanner not provide driver for linux. So can any one suggest me how to read data from USB port without driver.

Thanks
Ashish
 
Old 08-15-2013, 09:28 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
can you provide us with the infor from lsusb.

also run sudo tail -f /var/log/messages # hit enter a few times.
then plug in the scanner and paste in the output in *code* tags.

[related but not the same]: here is my program for reading a magtek usb magnetic stripe credit card reader:
Code:
[schneidz@hyper temp-cc]$ cat   bin2ascii.c
#include "stdio.h"
 
main(int argc, char *argv[])
{
 int i, c;
 FILE * fstream;
 
 fstream = fopen(argv[1], "r");
 c = fgetc(fstream);
 
 for(i=0; i < 4059; i++)
   fgetc(fstream);

 for(i=0; i < 380; i++)
 {
//printf(" i = %d \n", i);
  if((i - 1) % 8 == 0)
printf("%c", c);
//  if((c >= 0 && c <= 31) || (c >= 127))
//   printf("");
//  if(c >= 32 && c <= 126)
//   printf("\n%d --- %c\n", (i - 1),c);
  c = fgetc(fstream);
 }
 fclose(fstream);
}
i would run it by typing bin2ascii.x /dev/ttyUSB0 and it would give me the credit card number / name / expiration date when swiped.
 
1 members found this post helpful.
Old 08-15-2013, 09:58 AM   #3
bhangale1013ashish
LQ Newbie
 
Registered: Aug 2013
Location: Bangalore-India
Distribution: Ubuntu
Posts: 2

Original Poster
Rep: Reputation: Disabled
I definitely try this code and also provide ouput fro lsusb....
 
Old 01-08-2014, 01:37 AM   #4
makaveiljojo
LQ Newbie
 
Registered: Jan 2014
Posts: 3

Rep: Reputation: Disabled
What's the model number of the barcode scanner you are using? As far as I know, most of them support Linux and some other system like Windows 2000/Vista/XP/7 and Mac OS.
As for how to access USB barcode scanner data directly from USB port using C/C++, I googled and got to know that most barcode scanners can work as simple usb-to-serial converters and thus you get a ttyusbx device in /dev. The way this usually works is you download some software or manual from the manufacturer's website and scan a barcode or a series of barcodes that put the device in this mode.
Even simpler, ALL barcode scanners should work as HID devices(keyboard)...again this requires downloading some sort of software or manual and scanning a couple barcodes.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
read from a USB barcode scanner that simulates a keyboard bricedebrignaisplage Programming 12 12-06-2016 01:14 PM
Pos-x ion linear usb barcode scanner not working with debian MartyJay Linux - Hardware 2 06-24-2013 09:09 PM
redirecting the output of a USB barcode scanner (= USB keyboard) bricedebrignaisplage Programming 1 06-10-2009 07:26 PM
can't read from USB barcode scanner JoyPA Linux - Hardware 0 05-16-2007 10:21 AM
FC4 and Symbol USB Microscan Barcode Scanner MardukKurios Linux - Hardware 0 10-20-2005 04:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 08:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration