# Opticon OPN 2001 Handheld Barcode Scanner Linux Support

## jasn

I wanted to get a barcode scanner that would scan and save internally, the barcodes from things such as my books, CDs, and DVDs, and then upload the barcodes to a file on my computer, for importing into an app like tellico. I ended up choosing the Opticon OPN 2001 for the scanner, and now I'm looking for some way of uploading the saved barcodes under Linux. I found this BarcodeLibrary project, so there appears to be some work in this area. Any suggestions for linux apps that support this kind of uploading would be greatly appreciated.

Thanks..

----------

## jasn

In case anyone finds this thread and has a similar desire.

I emailed the author of the BOSS BarcodeLibrary project, and I made the mistake of thinking that the library they are working on was one for Linux, running under say Mono, as opposed to a Windows .NET project. He corrected me and instead pointed me to a blog here, where someone has written a python script to access the Symbol CS 1504 handheld scanner, which folks have suggested in near enough to the Opticon OPN 2001, that it may work. I haven't tried the script yet because it is designed to access the scanner via a serial port, and I don't know if the necessary drivers (USB to serial) is included in the kernel, or if it's a generic USB to serial driver that's included.

Anyway if anyone else plays around with this and can add some insight, it would be great. Otherwise I'll keep tinkering and reporting back if I'm successful.

Thanks..

----------

## Mr.Evolution

Hi!

I've one Opticon OPN-2001. This is the lspci output

```

Bus 003 Device 004: ID 065a:0009 Optoelectronics Co., Ltd

```

It is succesfully detected by my actual kernel Linux 2.6.31-gentoo-r3-64bit #1 SMP PREEMPT

enabling Device Drivers  ---> USB support  ---> USB Serial Converter support  ---> USB Opticon Barcode driver (serial mode)

```

usb 3-1: new full speed USB device using uhci_hcd and address 4

usb 3-1: New USB device found, idVendor=065a, idProduct=0009

usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0

usb 3-1: Product: Barcode Device

usb 3-1: Manufacturer: Optoelectronics Co., Ltd.

usb 3-1: configuration #1 chosen from 1 choice

opticon 3-1:1.0: opticon converter detected

usb 3-1: opticon converter now attached to ttyUSB0

```

I've tryed the script as is but i've the following error:

```

 # python cs1504.py

cs1504.py:318: DeprecationWarning: struct integer overflow masking is deprecated

  assert crc16('\x01\x02\x00') == '\x9f\xde', \

cs1504.py:318: DeprecationWarning: 'H' format requires 0 <= number <= 65535

  assert crc16('\x01\x02\x00') == '\x9f\xde', \

Using device /dev/ttyUSB0... Traceback (most recent call last):

  File "cs1504.py", line 323, in <module>

    scanner.interrogate()

  File "cs1504.py", line 154, in interrogate

    self.send('\x01\x02\x00')

  File "cs1504.py", line 266, in send

    self.ser.write(cmd)

  File "/usr/lib64/python2.6/site-packages/serial/serialposix.py", line 475, in write

    n = os.write(self.fd, d)

OSError: [Errno 8] Exec format error

```

dmesg error:

```

opticon ttyUSB0: opticon_write - usb_submit_urb(write bulk) failed with status = -8

```

Does anyone have use it successfull with this script?

Thank you a lot

Luca

----------

## fritz.brause

Hi!

I know this post is one and a half years old but I am currently facing the same problems as described by Mr.Evolution to get this script working. I just wanted to know if anybody has some experiences with running the Opticon OPN 2001 under Linux (Ubuntu) and would like to give support?!?

I receive the message (dmesg) that the Hardware is detected by the kernel:

```

[16298.810037] usb 4-1: new full speed USB device using uhci_hcd and address 8

[16298.976334] usb 4-1: configuration #1 chosen from 1 choice

[16298.979421] opticon 4-1:1.0: opticon converter detected

[16298.979498] usb 4-1: opticon converter now attached to ttyUSB0

```

lsusb output:

```

Bus 004 Device 007: ID 065a:0009 Optoelectronics Co., Ltd

```

Running the script produces almost the same output:

```

python cs1504.py 

cs1504.py:318: DeprecationWarning: struct integer overflow masking is deprecated

  assert crc16('\x01\x02\x00') == '\x9f\xde', \

cs1504.py:318: DeprecationWarning: 'H' format requires 0 <= number <= 65535

  assert crc16('\x01\x02\x00') == '\x9f\xde', \

Using device /dev/ttyUSB0... Traceback (most recent call last):

  File "cs1504.py", line 323, in <module>

    scanner.interrogate()

  File "cs1504.py", line 154, in interrogate

    self.send('\x01\x02\x00')

  File "cs1504.py", line 266, in send

    self.ser.write(cmd)

  File "/usr/lib/python2.6/dist-packages/serial/serialposix.py", line 328, in write

    if self.fd is None: raise portNotOpenError

serial.serialutil.SerialException: Port not open

```

And I get the same dmesg error message:

```

opticon ttyUSB0: opticon_write - usb_submit_urb(write bulk) failed with status = -8

```

Tanks in advance!

Fritz

----------

## nolaviz

I just submitted a set of patches to the kernel fixing this behavior.

(The cs1504.py script has its own set of bugs, left as an exercise to the reader)

----------

