I am working with an Arduino micro and RN-42 Bluetooth module. I have set the BT module as an HID keyboard by sending the commands through a terminal (using a COM port).
I want to set the device as a mouse but, now that it is in HID mode, I can't use a terminal.
How do I send the commands to set it as a mouse?
Thank you.
As your device now identifies itself as an HID device, the system no longer creates a corresponding tty file. I am not sure if it is a policy (meaning it doesn't do it because it would not make sense) or a mechanism issue (meaning it's just not able to do serial communication with a device using HID profile).
All you need is a serial console. Get a USB to serial/TTL adapter, your serial adapter will have a corresponding tty file that you can open as a serial console and you will be able to output commands directly to the RN42's UART, just as you used to over Bluetooth.
Related
We are integrating a new barcode reader (Newland NLS-FM430) in one of our products and we need to control its functionality. We have already implemented this behavior with another reader but it was an RS232 version, so we were able to send commands and wait for its input. The new one is a USB version which makes things different.
Generally, we want to initialize the barcode reader when the application is started (e.g. to disable reading setup codes) and turn it off. Then we want to enable it at the moment we need input from it and disable it again once we have read the data. There are commands for all these operations, documented in the user guide.
The issue comes when trying to communicate with the USB device. When connected to the computer it acts as a normal keyboard (Human Interface Device, HID in Device Manager) and we need to send commands to it. For this we need to open a stream to the device and write in it. We tried different libraries and solutions and opening the device always fails with an ACCESS_DENIED error. My suspicion is that the device is locked because Windows uses it as a keyboard.
I found this topic which discusses a similar problem. They found a workaround by deleting the suffix /kbd in the Device Path (and ours also has as this suffix) but removing it does not work for us - it says it cannot find the device.
I am looking into a solution in C# or C/C++ that would make it possible to open a connection to the USB device and write to it. Any help is highly appreciated.
Your introduced user guide states that the scanner still supports serial port mode.
Page 76 : USB CDC
Page 79 : IBM SurePOS (Handheld)
Page 79 : IBM SurePOS (Tabletop)
You can stop using it in keyboard input emulation mode and use serial port mode.
This is because, also on page 14 Chapter 3 System Settings of the User Guide, it is stated that the user can program by serial command.
Command Programming
The FM430 can also be configured by serial commands sent from the host device.
Users can design an application program to send those command strings to the scanners to perform device configuration
For more information, refer to the Programming Guide Based on Newland Unified Command s Set.
What's more, the vendor-provided configuration tool, also on page 13 Chapter 2 EasySet of the User Guide, does not support configuration in keyboard input simulation mode.
EasySet can communicate with device via one of the following interface: RS 232, USB COM Port Emulation (UFCOM driver required), USB CDC (UFCOM driver required), USB DataPipe (UFCOM driver required), USB HID POS.
In addition, the HID POS (POS HID Barcode Scanner) mode on page 77 allows for configuration and input/output as a variant of HID as described in the USB.org specification HID Point of Sale Usage Tables 1.02.
However, that method will not be able to notify the barcode read by the keyboard input emulation method. And it will require more complicated programming than setting/input/output in serial port mode.
A method to Connect / Disconnect a USB device "softly".
Hey, Assume I have a USB device connected to my PC, I want to enable/disable the port it is connected via computer so that I don't have to unplug/plug my device each time.
P.S : Device is a Microcontroller Board ( powered by USB port ) , so I don't want it to be active all the time. I want to deactivate it when appyling changes to code etc. and then activate that port so I can load my code into it again.
Is there a method to do so ?
Thanks in advance.
Device is a Microcontroller Board ( powered by USB port )
Most USB enabled µC types can "unplug" themself.
The idea is to put the USB data pins (usually called D+ and D-) into "output low" state for about one second at startup. This forces USB to be recognized as "disconnected".
After that is done, re-configure the pins to for their USB function and initialze the USB as usual.
Note that this method is not possible on old style boards that still use USB2UART chips instead of hardware USB inside the µC itself.
I have developed a kernel driver for a USB device. Such a device has some pins that can provide functionality both as CDC ACM serial port or as input buttons. So to implement that I had to use two different USB configuration descriptors.
The driver works as expected, but I have to hardcode the chosen setup before compiling and loading the firmware to the micro-controller. I am searching a mechanism to change that device configuration from userspace.
I read about a SET_CONFIGURATION message on USB documentation, but coudn't find any Linux tool to send such kind of standard USB messages from userspace to the USB bus.
Does some of you (with more experience on this topic) know some userspace Linux tool to send a SET_CONFIGURATION message to a device connected to the USB bus?
Thanks in advance! :)
The function libusb_set_configuration() in LibUSB could do that in theory, but there is no need.
One can simply put both HID (for the button) and CDC (serial port) into one configuration using an "Interface association descriptor" (IAD).
This github repo resolves my issue:
https://github.com/avtolstoy/usbtool
No need for any special tools. You can simply do it via sysfs:
Find your device cd /sys/bus/usb/devices/X-Y/ where X is the bus number and Y is the device number.
Edit bConfigurationValue e.g., using sudoedit
Set the file contents to the desired configuration number and save it
That’s it!
A number of bluetooth Arduino shields (Bluefruit EZ-link, SparkFun Bluetooth Silver) support DTR/RTS and have special out pin to wire. How do they work? Does it require special drivers (linux f.e.)? Can any bluetooth receiver be used or modified to provide DTR/RTS? Since setting DTR/RTS is vendor-specific does it depend on transmitter side or receiver (bluetooth shield) only?
The only idea is that special USB drivers needed that send special AT commands to make BT receiver know actual DTR/RTS value.
The documentation of Bluetooth SPP (https://developer.bluetooth.org/TechnologyOverview/Documents/SPP_SPEC.pdf) states in section 4.1 RS232 Control Signals that "all devices are required to send information on all changes in RS232 control signals".
And since Bluefruit EZ-link is not using any special drivers on the side of the computer, it must be that the standard BT virtual serial port drivers that manage the ports created for the BT connection to Arduino handle the control signals properly and send them over to the BT shield connected to Arduino. Hence no work should be needed on the side of the computer, and it only depends on the receiver: whether it has the control signals accessible on any of the output pins and operates them as it should, or not (as usually is the case, unfortunately).
Bluefruit EZ-link is described as programmer. It means it supports RTS/DTR:
The EZ-Link has another impressive feature: the DTR/RTS/DSR flow
control pins are automatically synced to the computer serial port.
What this means is that if the computer sets the hardware flow control
DTR or RTS pins high or low the pins on the bluetooth module will
follow.
So Arduino IDE performs reset to initiate flashing (as Arduino's Bootloader wait for few seconds after reset for upload commands from Arduino IDE). For USB reset works by switching DTR to 1 and 0 and special schematics on Arduino board monitors it and performs reset. After reset is done Arduino IDE runs avrdude and start flashing.
The question is "How does it works over Bluetooth module by Adafruit?" There is no RTS/DTR line for Bluetooth..
PS. I believe virtual COM-port drivers for this Bluetooth device should send special AT+ commands and Bluetooth device should handle them and perform setting 1 or 0 to special pin wired with MCUs reset. But this requires Bluefruit bluetooth driver to be used. But i can't see it requires special BT drivers at computer.
RFCOMM do support flow control.
RFCOMM is based on GSM TS 07.10. Bluefruit extract info on RFCOMM and map it to flow control lines.