Hi All,
I have an LS2208 Barcode scanner. It is plugged in to my computer using the USB. I am trying to read the barcodes scanned using the scanner. I primarily work in python language.
I scoured the internet for the correct way to do it but nothing worked. I tried to read the barcode with standard method of keyboard input as the scanner is an HID device that types data into stream. That did not work either
Any help in this case would be appreciated.
Regards,
S R U
3 Replies
Greetings.
Just wanted to update that i have resolved my problem.
I am able to interface with LS2208 scanner using python with the help of following python package libraries.
1. PyUSB - https://pypi.org/project/pyusb/
2. LibUSB - https://pypi.org/project/libusb/
After installing them, here are some additional resources that need to be install in order to avoid errors when the script is run. I found all these by googling so you can also find them .
To resolve No Backend Error
-- Download the latest Windows binary: https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.21/libusb-1.0.21.7z/download
-- Unzip using 7zip into a temp dir
-- If on 64-bit Windows, copy MS64\dll\libusb-1.0.dll into C:\windows\system32. If on 32-bit windows, copy MS32\dll\libusb-1.0.dll into C:\windows\SysWOW64.
Here is the python script i used to interface with the barcode scanner.
"""
Author : Ardyn Izuya 02/17/2023
Change Log:
-- Initial Release 02/17/2023
Description:
-- Script to read barcode data from LS2208 scanner
-- Script uses libusb and pyusb libraries
-- Vendor ID and Product ID are mandatory fields
Steps to configure the script:
-- Get Procduct ID and Vendor ID
-- Go to Device Manager
-- Select the correct device under Human Interface Devices
-- Install the python libraries
-- https://pypi.org/project/pyusb/
-- https://pypi.org/project/libusb/
-- To resolve No Backend Error
-- Download the latest Windows binary: https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.21/libusb-1.0.21.7z/download
-- Unzip using 7zip into a temp dir
-- If on 64-bit Windows, copy MS64\dll\libusb-1.0.dll into C:\windows\system32. If on 32-bit windows, copy MS32\dll\libusb-1.0.dll into C:\windows\SysWOW64.
Resources:
-- https://pypi.org/project/pyusb/ -- pusb package download
-- https://pypi.org/project/libusb/ -- Libusb package download
-- https://github.com/pyusb/pyusb
-- https://github.com/pyusb/pyusb/issues/120#issuecomment-322058585
-- beyondlogic.org/usbinnutshell
-- asciitable.com
"""
import usb.core # main module
import usb.util # contains utility functions
import string
VENDOR_ID = 0x05e0
PRODUCT_ID = 0x1300
while True:
try:
# find our device using vendor ID and Product ID
dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
print(dev)
except usb.core.USBTimeoutError as timeOutError:
print("Scanner Read Time Out Occurred \n")
print("Closing device Object and")
except Exception as e:
print(f"The following exception has occurred {e} \n . Retrying.........")
The read functionality is already present in PyUSB GitHub page. Just follow that and make sure you are trimming your non-printable characters out.
Regards,
A I
is your LS2208 mfd after December 2014 ?
This code works for Li2208, Here is a version that also read bar codes not only check connections