PyUSB Barcode Scanner without Button by Honeywell - barcode-scanner

I have a Honeywell N5600 that I'm trying to use, but I don't get it to scan anything.
The device is recognized as /dev/hidraw1, but as it does not have any button to press, I cannot trigger the scan and thus, when I try to read from it, it just waits forever.
I started creating a python program, that seems to be able to communicate with it (different return values):
VENDOR_LEGO = 0x0c2e
PRODUCT_EV3 = 0x0967
device = usb.core.find(idVendor=VENDOR_LEGO, idProduct=PRODUCT_EV3)
device.detach_kernel_driver(0)
#"TRGMOD8." would - when scanned (which I cannot do, at this point) - activate a permanent scanning mode
device.ctrl_transfer(0x21, 0x9, wValue=0x200, wIndex=0x00, data_or_wLength='TRGMOD8.')
#8 is returned
device.ctrl_transfer(0x21, 0x9, wValue=0x200, wIndex=0x00, data_or_wLength='PAPSPC.')
#7 is returned
Unluckily the link given in this post is not reachable anymore. It seems like it would have solved my problem.
How can I activate the scanning?

The document on Honeywell N5600 is as follows.
N5600 OEM 2D Imager Data Sheet
N56XX Decoded Engine User's Guide
You need a Windows PC that can connect to the Internet, but there is a tool called EZConfig-Scanning that configures and maintains the scanner.
EZConfig Device Management Data Sheet
Perhaps the recognition device /dev/hidraw1 is probably because the scanner is set to USB HID Bar Code Scanner mode.
If you change the setting to USB Keyboard(PC/Mac), it is always readable and the barcode you read will be notified as keyboard input.
By changing the setting to USB Serial, reading start/stop can be controlled by SerialPort command transmission. The barcode read is notified by receiving data from SerialPort.

Related

Can not configure 5GHz WiFi band for Beaglebone AI

I am trying to configure 5GHz WiFi band for my new Beaglebone AI.
What I am doing is
cp /tmp/hostapd-bbai.conf to /etc/hostapd.conf
opening /etc/default/bb-wl18xx and changing USE_GENERATED_HOSTAPD to 'no'
USE_GENERATED_HOSTAPD=no
in order to use /etc/hostapd.conf file instead of generated conf file from /tmp
this method works perfect for 'b' and 'g' but I can not configure to 'a' in order to use 5GHz band
Can anyone help me regarding this?
this is my hostapd.conf
interface=SoftAp0
ssid=BeagleBone-59A4
hw_mode=a
channel=1
wmm_enabled=1
country_code=IN
ieee80211d=1
ieee80211n=1
ieee80211ac=1
wmm_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=BeagleBone
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
logger_syslog=-1
logger_syslog_level=2
New Beagle Bone AI WIFI stack is more powerful and its auto handle.
if still you facing issue regarding any other interfaces then please follow below link :
https://github.com/MalavPatel3501/BeagleBone-AI--mpBBAI-IO-Python-Library
In this project you got .dts file and all pin muxing steps. Moreover i puts some example code in this project.

How to select a particular USB port on raspberry pi 3B+ to program two arduino boards with arduino-mk?

I have a python program on my Raspberry pi 3B+ witch updates an Arduino mega2560 and an Arduino Uno by using Arduino-mk through bash commands. Each Arduino has its own code folder with its code (.ino) and a Makefile which looks like:
ARDUINO_DIR = /usr/share/arduino
ARDUINO_PORT = /dev/ttyUSB0 (here is the problem)
USER_LIB_PATH = /home/pi/sketchbook/libraries
BOARD_TAG = mega2560 (Uno for the uno one)
include /usr/share/arduino/Arduino.mk
When I call the following command:
os.system("(cd ~/sketchbook/mega; make upload clean)")
with only the mega connected on the USB port everything works and the mega gets programed (same with Uno only). but when I try to get both done:
os.system("(cd ~/sketchbook/mega; make upload clean)")
os.system("(cd ~/sketchbook/uno; make upload clean)")
arduino-mk can't program the Uno (multiple timeouts).
At first the second line in Makefile was:
ARDUINO_PORT = /dev/ttyAMC0
but it was not working so I checked on the web and found that some Arduino copies worked better with:
ARDUINO_PORT = /dev/ttyUSB0
Then it worked but I couldn't get any result with ttyUSB1 up to ttyUSB3 (I hoped it would work like COM ports on windows).
I also noticed that if I keep testing with ttyUSB0 and try with each physical USB port and worked so ttyUSB0 refers to the four physical ports right?
Please how can I get one particular port name?
Or is there an other way to make Arduino-mk work?
Plug in one device at a time and look at the output of ls -l /dev/serial/by-id/, you should see a symlink to the actual device node, but uniquely named for your specific device.
You can then set ARDUINO_PORT=/dev/serial/by-id/unique_name in the respective makefiles.

Persistant name in usb device which open several connections || connect USB to specific port [duplicate]

This question already has an answer here:
Change default names for USB virtual serial ports in Linux
(1 answer)
Closed 5 years ago.
I am trying to add a persistent name to a USB device connection to be able to connect to it by writing /dev/multitech instead of /devttyACMx. I have been able to do so with other devices by adding an udev rule, for example:
SUBSYSTEM=="tty", ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="0021",ATTRS{serial}=="356136967675473", SYMLINK+="multitech"
The problem is that this device open 6 connections, from ttyACM0 to ttyACM5 (if nothing else connected) but to use it you have to use the ttyACM0 (meaning the first connection) but if you write:
$ ls -l /dev/multitech
you may get whatever connection it has open, maybe ttyACM0 or maybe ttyACM3... the thing is that this is useless for me, since it sometimes works and sometimes it does not. Is there anything I can do about this?
Thanks a lot!!
normally each connection the device establishes has its own interface or alternate setting in USB tree structure. in udev rules you can use several other attributes (all you can display using udevadm info --attribute-walk http://www.beyondlogic.org/usbnutshell/usb5.shtml#InterfaceDescriptors )
run an attribute walk with udevadm info --attribute-walk + /sys/class/... or /dev/... path for your device to see the identifiers of the several usb interfaces it has in its usb structure and try to include them in the udev rule, i.e. using the following attributes:
ATTRS{bAlternateSetting}=="..."
ATTRS{bInterfaceClass}=="..."
ATTRS{bInterfaceNumber}=="..."
ATTRS{bInterfaceProtocol}=="..."
ATTRS{bInterfaceSubClass}=="..."
try to assign a specific /dev/ttyACMx for any interface the device has in its usb structure and try to assign the top-level interface in the usb structure to /dev/ttyACM0 ...
http://weininger.net/how-to-write-udev-rules-for-usb-devices.html
Change default names for USB virtual serial ports in Linux
This post was the solution to my troubles, instead of using the /devttyACMx
y changed to used the names in /dev/serial/by-id/
up until now it has worked fine, if it stops doing it I will post it

REDHAWK UHD device usage

I have successfully installed the UHD device along side REDHAWK version 1.8.3. It isn't obvious to me how to connect a component in a waveform to a device being managed by a device manager. I am also unclear on the interplay between the IDL interfaces and the data ports on the USRP device.
I was unable to find a trivial example to send and receive waveform that utilizes the USRP device (e.g. a signal generator component sending a sine wave to the USRP). Does anyone have experience with this or any suggestions?
One way to connect a Component to a Device in a running environment is through the REDHAWK python module. It is able to attach to a running domain, query any launched Applications and connect Ports from Components to Devices. The following is an example python script (Note the ports must both be the same type in order for the connection to succeed):
from ossie.utils import redhawk
from ossie.cf import CF
# Connect to the running domain
domain = redhawk.attach("REDHAWK_DEV")
# Gets a reference to the running application
for app in domain.apps:
# Find desired application
if app.name == 'desired_name':
application = app
# Gets the component from the application
for comp in application.comps:
# Find desired component
if comp.name == 'desired_name':
component = comp
# Gets the device to connect
for devMgr in domain.devMgrs:
for dev in devMgr.devs:
# Find desired device
if dev.name = 'desired_name':
device = dev
# Gets the references to the input and output ports
comp_port = component.getPort('port_name')._narrow(CF.Port)
dev_port = device.getPort('port_name')
# Makes the actual connection
comp_port.connectPort(dev_port, 'ConnectionID')
# Make sure device is started
device.start()
# Start application
application.start()
# To disconnect:
# Stop device and application
application.stop()
device.stop()
comp_port.disconnectPort('ConnectionID')
There are multiple ways to accomplish this depending on your situations. Here are a few:
A.) Problem: You are debugging an issue in the IDE and quickly want to connect a device port to a component port
Solution: With the component and device both running in either domain or in the sandbox, expand the component and device in your SCA Explorer view to expose the ports. Click on the output port then ctrl+click the input port you would like to connect to. With both ports highlighted you can now right click and select Connect.
B.) Problem: You need a generic way of connecting a components input port, regardless of implementation language, to a particular type of devices output port, regardless of language implementation.
Solution: This is a multi-step process and is not that intuitive at first. I recommend you look at the SCA spec page D-43 for additional detail for step 10 and beyond below.
Open the component in your editor and navigate to the Implementations tab.
Right click on the implementation you would like to use for this connection (ex. python)
Select New → Uses Device
Generate (or enter) a unique DCE ID for this connection
Enter the type "usesDevice" although I'm not 100% sure if the type matters, I used usesDevice
Right click on the Uses Device select new Property Ref. You will not be directly connecting component X to device Y. Instead you are connecting component X to a device which meets the property restrictions set here. ie. model, type, etc.
In your device, in the properties tab, set a property like device_kind or device_model's Name field to something you want to match to. We'll say XYZ123 for an example. Save and deploy this to the SDR ROOT
Back in the component where we were setting the property Ref, select browse and select the property on the device you just set as your matching property.
Set the Value to the value you set it to ex XYZ123. Save and deploy the compnent
Now in your waveform, you'll need to hand edit the SAD file and add something like this, where [[TEXT]] indicates something for you to change:
<connections>
<connectinterface id="[[Connection_Name]]">
<usesport>
<usesidentifier>[[Output Port Name]]</usesidentifier>
<deviceusedbythiscomponentref refid="[[DCE matching the componentinstantiationID]]" usesrefid="[[DCE matching the generated ID from step 4]]"/>
</usesport>
<providesport>
<providesidentifier>[[Input Port Name]]</providesidentifier>
<componentinstantiationref refid="[[DCE matching the componentinstantiationID]]"/>
</providesport>
</connectinterface>
</connections>
I recommend you add a dummy component to your SAD editor and connect dummy component to the real compnent just so your SAD file is populated with the connectinterface block and you can see an example of a connection.
After making those changes, the IDE may tell you that an error exists in your SAD file, save anyway, close the SAD editor and reopen. If no error is displayed then your syntax is fine. Deploy the waveform and launch as usual.
C.) Problem: You want to connect to a device via a python script outside of REDHAWK, a python service within REDHAWK, or through a python component in your waveform.
Solution: See Adam's solution.

Weird URI string displayed on mounting iPod

I have written a small program to detect whenever a device is mounted on a desktop running Linux. I have used GIO for this. I am extracting the URI of the mounted resource and displaying it to the user. When I put in a CD I get a URI string which looks like file:///media/cdrom0/ which I can understand. But when I mount an iPod the URI I see is something like gphoto2://[usb:002,028]. What does this mean? I have observed that the second number (028) keeps increasing every time I take the device out and plug it back in. Can some one interpret this URI for me?
Update: As shodanex answered, the two numbers are the bus number and device number respectively. gphoto2:// indicates the protocol (PTP/MTP).
gphoto2://[usb:002,028]
I guess 002 is the bus number, and 28 is the adress of the device on that bus.
It maps to the second and fourth field of the lsusb util output. Here is an example
on my system :
Bus 001 Device 015: ID 05e3:0715 Genesys Logic, Inc. USB 2.0 microSD Reader
I guess it would translate to :
usb:001,015
I have these kinds of URL's in Nautilus too, but the other response doesn't explain how that relates to a mount location on disk. I can navigate through the files on an SD card via the Nautilus file browser, but I don't see any of these files in /mnt/ or /media/ or anywhere else I would typically look for automatically mounted file systems.
Eventually I tried right-clicking the folder, selecting "Open with other application," choosing a text editor, and then I could see that the folder was actually mounted at:
'~/.gvfs/gphoto2 mount on usb%3A001,010'
I wish Nautilus and other tools in ubuntu would provide some more obvious way to find these files... this seems pretty un-intuitive.

Resources