Ricardo_Ochoa
Posts: 14
Joined: Mon Mar 21, 2016 5:20 pm

barcode scanner Help!!

Thu Mar 31, 2016 1:38 am

Hello !!
Im sorry im new on this .... I have a project... I have to connect a Barcode scanner in USB.. in my RaspBerry Pi 2..
In windows i haven't any inconvenience to use a barcode scanne USBr because windows have the drives of this barcode scanner for default..

My question is ... raspberry have any driver to use this barcode scanner USB?

Thanks for your patience... (and im sorry my english is low xD i hope you can understand me )

have a great day.

pksato
Posts: 295
Joined: Fri Aug 03, 2012 5:25 pm
Location: Brazil

Re: barcode scanner Help!!

Thu Mar 31, 2016 2:57 pm

Hi,
We need more details about this barcode reader.

But, most SOHO barcode reader emulate a keyboard. Not need any special driver. Any system that support USB HID can work.
If is this case, it work on raspberry pi.

Industrial barcode can have rs232, rs485, i2c, isp or other interface bus.

Ricardo_Ochoa
Posts: 14
Joined: Mon Mar 21, 2016 5:20 pm

Re: barcode scanner Help!!

Thu Mar 31, 2016 3:08 pm

Ty for answer my petition...

this is my barcode scanner : http://www.steren.com.mx/lector-de-codi ... s-usb.html

in the specification say that this barcode scanner is connected for USB port and the transition data is for RS232...

I don't know whats happens i connect this barcode in the raspberry pi 2 and no write when i scan any code :/

and my raspberry is already update do you knowany driver?? for this barcode scanner?

thanks for your time.

User avatar
topguy
Posts: 6983
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: barcode scanner Help!!

Thu Mar 31, 2016 3:16 pm

Ricardo_Ochoa wrote: in the specification say that this barcode scanner is connected for USB port and the transition data is for RS232...
Then its very likely that the device is automatically detected as a virtual serialport with the name "/dev/ttyUSB0" or "/dev/ttyACM0".

To make sure:
- boot the Pi with the scanner NOT pluggen in.
- open a terminalwindow or use the console.
- plug the scanner in.
- run the command "dmesg" and look at the last few lines they should mention "new usb device" etc. and show the name of the driver used and possible the name of the device.

Ricardo_Ochoa
Posts: 14
Joined: Mon Mar 21, 2016 5:20 pm

Re: barcode scanner Help!!

Thu Mar 31, 2016 5:39 pm

In the following image.. show you the dmesg command.. i cant see any ACM0.... or USB0.... or im doing something wrong?

PD: when i use smesg command the barcod scanner is plug in :)
Attachments
commando_1.jpg
commando_1.jpg (57.99 KiB) Viewed 2162 times

Ricardo_Ochoa
Posts: 14
Joined: Mon Mar 21, 2016 5:20 pm

Re: barcode scanner Help!!

Thu Mar 31, 2016 5:53 pm

this is the result when i write the command 'dmesg'

3648.984885] usb 1-1.2: new full-speed USB device number 4 using dwc_otg
[ 3649.096523] usb 1-1.2: New USB device found, idVendor=1d57, idProduct=001c
[ 3649.096549] usb 1-1.2: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 3649.096567] usb 1-1.2: Product: HID Keyboard Device
[ 3649.096582] usb 1-1.2: Manufacturer: HID Keyboard Device
[ 3649.096598] usb 1-1.2: SerialNumber: Keyboard Device
[ 3649.108348] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:1D57:001C.0001/input/input0
[ 3649.165494] hid-generic 0003:1D57:001C.0001: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.2/input0
[ 3785.979427] usb 1-1.2: USB disconnect, device number 4
[ 3828.464728] usb 1-1.4: new full-speed USB device number 5 using dwc_otg
[ 3828.576575] usb 1-1.4: New USB device found, idVendor=1d57, idProduct=001c
[ 3828.576603] usb 1-1.4: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 3828.576620] usb 1-1.4: Product: HID Keyboard Device
[ 3828.576635] usb 1-1.4: Manufacturer: HID Keyboard Device
[ 3828.576651] usb 1-1.4: SerialNumber: Keyboard Device
[ 3828.586920] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:1D57:001C.0002/input/input1
[ 3828.647800] hid-generic 0003:1D57:001C.0002: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.4/input0
[ 4163.629826] usb 1-1.4: USB disconnect, device number 5
[ 4178.204748] usb 1-1.4: new full-speed USB device number 6 using dwc_otg
[ 4178.317695] usb 1-1.4: New USB device found, idVendor=1d57, idProduct=001c
[ 4178.317723] usb 1-1.4: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 4178.317740] usb 1-1.4: Product: HID Keyboard Device
[ 4178.317755] usb 1-1.4: Manufacturer: HID Keyboard Device
[ 4178.317770] usb 1-1.4: SerialNumber: Keyboard Device
[ 4178.325120] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:1D57:001C.0003/input/input2
[ 4178.388054] hid-generic 0003:1D57:001C.0003: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.4/input0
[ 4185.904748] usb 1-1.4: USB disconnect, device number 6
[ 4187.674733] usb 1-1.2: new full-speed USB device number 7 using dwc_otg
[ 4187.787716] usb 1-1.2: New USB device found, idVendor=1d57, idProduct=001c
[ 4187.787745] usb 1-1.2: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 4187.787762] usb 1-1.2: Product: HID Keyboard Device
[ 4187.787777] usb 1-1.2: Manufacturer: HID Keyboard Device
[ 4187.787792] usb 1-1.2: SerialNumber: Keyboard Device
[ 4187.795878] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:1D57:001C.0004/input/input3
[ 4187.855649] hid-generic 0003:1D57:001C.0004: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.2/input0
[ 4482.648280] usb 1-1.2: USB disconnect, device number 7
[ 4517.964733] usb 1-1.5: new full-speed USB device number 8 using dwc_otg
[ 4518.076496] usb 1-1.5: New USB device found, idVendor=1d57, idProduct=001c
[ 4518.076525] usb 1-1.5: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 4518.076541] usb 1-1.5: Product: HID Keyboard Device
[ 4518.076557] usb 1-1.5: Manufacturer: HID Keyboard Device
[ 4518.076573] usb 1-1.5: SerialNumber: Keyboard Device
[ 4518.087572] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/0003:1D57:001C.0005/input/input4
[ 4518.148070] hid-generic 0003:1D57:001C.0005: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.5/input0
[ 4565.347323] usb 1-1.5: USB disconnect, device number 8
[ 4939.261943] gpiomem-bcm2835 3f200000.gpiomem: gpiomem device opened.
[ 7148.454737] usb 1-1.2: new full-speed USB device number 9 using dwc_otg
[ 7148.565448] usb 1-1.2: New USB device found, idVendor=1d57, idProduct=001c
[ 7148.565480] usb 1-1.2: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 7148.565497] usb 1-1.2: Product: HID Keyboard Device
[ 7148.565513] usb 1-1.2: Manufacturer: HID Keyboard Device
[ 7148.565528] usb 1-1.2: SerialNumber: Keyboard Device
[ 7148.577814] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:1D57:001C.0006/input/input5
[ 7148.635794] hid-generic 0003:1D57:001C.0006: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.2/input0
[ 7557.106203] usb 1-1.2: USB disconnect, device number 9
[ 7713.014772] usb 1-1.2: new full-speed USB device number 10 using dwc_otg
[ 7713.126611] usb 1-1.2: New USB device found, idVendor=1d57, idProduct=001c
[ 7713.126643] usb 1-1.2: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 7713.126660] usb 1-1.2: Product: HID Keyboard Device
[ 7713.126676] usb 1-1.2: Manufacturer: HID Keyboard Device
[ 7713.126691] usb 1-1.2: SerialNumber: Keyboard Device
[ 7713.136409] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:1D57:001C.0007/input/input6
[ 7713.197655] hid-generic 0003:1D57:001C.0007: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.2/input0
[ 8011.054750] usb 1-1.2: USB disconnect, device number 10
[ 8012.314806] usb 1-1.3: new full-speed USB device number 11 using dwc_otg
[ 8012.421714] usb 1-1.3: New USB device found, idVendor=1d57, idProduct=001c
[ 8012.421737] usb 1-1.3: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 8012.421748] usb 1-1.3: Product: HID Keyboard Device
[ 8012.421759] usb 1-1.3: Manufacturer: HID Keyboard Device
[ 8012.421769] usb 1-1.3: SerialNumber: Keyboard Device
[ 8012.428920] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/0003:1D57:001C.0008/input/input7
[ 8012.486213] hid-generic 0003:1D57:001C.0008: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.3/input0
[ 8018.479648] usb 1-1.3: USB disconnect, device number 11
[ 8019.734718] usb 1-1.5: new full-speed USB device number 12 using dwc_otg
[ 8019.842707] usb 1-1.5: New USB device found, idVendor=1d57, idProduct=001c
[ 8019.842731] usb 1-1.5: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 8019.842743] usb 1-1.5: Product: HID Keyboard Device
[ 8019.842754] usb 1-1.5: Manufacturer: HID Keyboard Device
[ 8019.842765] usb 1-1.5: SerialNumber: Keyboard Device
[ 8019.850607] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/0003:1D57:001C.0009/input/input8
[ 8019.905363] hid-generic 0003:1D57:001C.0009: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.5/input0
[ 8024.880494] usb 1-1.5: USB disconnect, device number 12
[ 8026.144759] usb 1-1.4: new full-speed USB device number 13 using dwc_otg
[ 8026.256586] usb 1-1.4: New USB device found, idVendor=1d57, idProduct=001c
[ 8026.256616] usb 1-1.4: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 8026.256634] usb 1-1.4: Product: HID Keyboard Device
[ 8026.256649] usb 1-1.4: Manufacturer: HID Keyboard Device
[ 8026.256665] usb 1-1.4: SerialNumber: Keyboard Device
[ 8026.265768] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:1D57:001C.000A/input/input9
[ 8026.327238] hid-generic 0003:1D57:001C.000A: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.4/input0
[ 8032.561550] usb 1-1.4: USB disconnect, device number 13
[ 8033.824795] usb 1-1.2: new full-speed USB device number 14 using dwc_otg
[ 8033.935497] usb 1-1.2: New USB device found, idVendor=1d57, idProduct=001c
[ 8033.935530] usb 1-1.2: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 8033.935547] usb 1-1.2: Product: HID Keyboard Device
[ 8033.935563] usb 1-1.2: Manufacturer: HID Keyboard Device
[ 8033.935578] usb 1-1.2: SerialNumber: Keyboard Device
[ 8033.943688] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:1D57:001C.000B/input/input10
[ 8033.995710] hid-generic 0003:1D57:001C.000B: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.2/input0
[ 8049.971818] usb 1-1.2: USB disconnect, device number 14
[ 8051.234780] usb 1-1.3: new full-speed USB device number 15 using dwc_otg
[ 8051.345303] usb 1-1.3: New USB device found, idVendor=1d57, idProduct=001c
[ 8051.345336] usb 1-1.3: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 8051.345353] usb 1-1.3: Product: HID Keyboard Device
[ 8051.345368] usb 1-1.3: Manufacturer: HID Keyboard Device
[ 8051.345384] usb 1-1.3: SerialNumber: Keyboard Device
[ 8051.353499] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/0003:1D57:001C.000C/input/input11
[ 8051.405687] hid-generic 0003:1D57:001C.000C: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.3/input0
[ 8057.652904] usb 1-1.3: USB disconnect, device number 15
[ 8058.654734] usb 1-1.5: new full-speed USB device number 16 using dwc_otg
[ 8058.764026] usb 1-1.5: New USB device found, idVendor=1d57, idProduct=001c
[ 8058.764051] usb 1-1.5: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 8058.764062] usb 1-1.5: Product: HID Keyboard Device
[ 8058.764073] usb 1-1.5: Manufacturer: HID Keyboard Device
[ 8058.764084] usb 1-1.5: SerialNumber: Keyboard Device
[ 8058.771896] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/0003:1D57:001C.000D/input/input12
[ 8058.825416] hid-generic 0003:1D57:001C.000D: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.5/input0
[ 8063.285617] usb 1-1.5: USB disconnect, device number 16
[ 8065.314784] usb 1-1.4: new full-speed USB device number 17 using dwc_otg
[ 8065.424302] usb 1-1.4: New USB device found, idVendor=1d57, idProduct=001c
[ 8065.424334] usb 1-1.4: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 8065.424351] usb 1-1.4: Product: HID Keyboard Device
[ 8065.424367] usb 1-1.4: Manufacturer: HID Keyboard Device
[ 8065.424382] usb 1-1.4: SerialNumber: Keyboard Device
[ 8065.433358] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:1D57:001C.000E/input/input13
[ 8065.485743] hid-generic 0003:1D57:001C.000E: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.4/input0

User avatar
rpdom
Posts: 18132
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: barcode scanner Help!!

Thu Mar 31, 2016 6:00 pm

Ricardo_Ochoa wrote: [3648.984885] usb 1-1.2: new full-speed USB device number 4 using dwc_otg
[ 3649.096523] usb 1-1.2: New USB device found, idVendor=1d57, idProduct=001c
[ 3649.096549] usb 1-1.2: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 3649.096567] usb 1-1.2: Product: HID Keyboard Device
[ 3649.096582] usb 1-1.2: Manufacturer: HID Keyboard Device
[ 3649.096598] usb 1-1.2: SerialNumber: Keyboard Device
[ 3649.108348] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:1D57:001C.0001/input/input0
[ 3649.165494] hid-generic 0003:1D57:001C.0001: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.2/input0
It looks like your barcode reader is identifying itself as a USB Keyboard, which should mean that when you read a barcode it will act as if you typed it in.

However... this
[ 3785.979427] usb 1-1.2: USB disconnect, device number 4
show that it lost the connection soon afterwards and the log shows several of these connect/disconnect cycles.

The most common cause of this is the device needing more current than the USB port is supplying. On a Pi 2 you can increase the USB port output by putting the line

Code: Select all

max_usb_current=1
in /boot/config.txt and rebooting. As long as your power supply is good that should fix the disconnects.

Ricardo_Ochoa
Posts: 14
Joined: Mon Mar 21, 2016 5:20 pm

Re: barcode scanner Help!!

Thu Mar 31, 2016 6:17 pm

i do that now i havent desconnection from the barcode scanner!! Thanks so much!!!! now when i write the command 'dmesg' it show me this....

[ 87.284618] usb 1-1.4: new full-speed USB device number 4 using dwc_otg
[ 87.395340] usb 1-1.4: New USB device found, idVendor=1d57, idProduct=001c
[ 87.395367] usb 1-1.4: New USB device strings: Mfr=1, Product=1, SerialNumber=2
[ 87.395384] usb 1-1.4: Product: HID Keyboard Device
[ 87.395399] usb 1-1.4: Manufacturer: HID Keyboard Device
[ 87.395414] usb 1-1.4: SerialNumber: Keyboard Device
[ 87.408444] input: HID Keyboard Device HID Keyboard Device as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:1D57:001C.0001/input/input0
[ 87.465460] hid-generic 0003:1D57:001C.0001: input,hiddev0,hidraw0: USB HID v1.10 Keyboard [HID Keyboard Device HID Keyboard Device] on usb-3f980000.usb-1.4/input0


how you can see i haven't disconnections, but my question is... how i can connect my barcode scanner un python?? i have this code..

import sys

fp = open('/dev/ttyhidraw0', 'rb')

while True:
buffer = fp.read(8)
for c in buffer:
if ord(c) > 0:
print ord(c)
print "\n"

where 'hidraw0' is the name from the device... im sorry im new on this and im lost xD

do you know whats happens? what is the real name from my barcode scanner??
in the section code I have... fp = open('/dev/ttyhidraw0', 'rb') i think this is file name from my barcode scanner... in python

User avatar
topguy
Posts: 6983
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: barcode scanner Help!!

Fri Apr 01, 2016 10:59 am

Google it more.. you are not the first one with this problem...

But there is 3 different approaches I have seen,
a: using PyUsb to talk to the device on usb-level,
b: try to reade /dev/hidrawX
c: use "evdev" and parse the "keystrokes" of "/dev/input/inputX"

- http://stackoverflow.com/questions/2631 ... -available
- http://www.rkblog.rk.edu.pl/w/p/control ... ces-pyusb/
- viewtopic.php?f=45&t=55100

Ricardo_Ochoa
Posts: 14
Joined: Mon Mar 21, 2016 5:20 pm

Re: barcode scanner Help!!

Fri Apr 01, 2016 3:03 pm

Ty so much!!!! omg i was very lost! now i can use the bar code thanks for your help n___n

Yeah its correct the name of my Barcode is hidraw0 and for have acces to this i put chmod 777 hidraw0 in the console... after this i can now use my bar code in python n__n

Ty very much!!! <3 :lol: 8-) 8-) :D :D :D

Return to “General discussion”