uart accessory emulator
This project aim to help a user to develop an open accessory android application without left adb usb debug using a linux powerd PC how android accessory device emulator.
The scheme is simple:
Android Device -> AOA ready application -> USB cable -> Linux PC -> this software ->/dev/ttyUSBx -> target device
-
To build on console use: gcc -g -o accessory
$(pkg-config --cflags libusb-1.0) *.c $ (pkg-config --libs libusb-1.0)That compiles and links everything in one go, only one -g is needed, and pkg-config is used to get the correct compiler and linker flags for finding libusb files.
To debug it use: dbg ./accessory
To run it use: run [options]
To catch stack after a segfault use: "fb" -
I get a "Permission denied" error when I try to execute the program. Is mandatory to run it with root user priviledges ?
Usually to access to /dev/ttyUSBx you need root rights but how you can see with "ls -l /dev/ttyUSBx" you can solve adding your user to "dialout" group with following commands:
this add your user to dialout group permitting access to /dev/ttyUSB0 without root rights
sudo adduser user_name dialout
sudo reboot -
How can I enable libusb debug and catch eventual interface error logs ?
To enable libusb log message is only necessary to define the environment variable LIBUSB_DEBUG to desired value:
Level 0: no messages ever printed by the library (default)
Level 1: error messages are printed to stderr
Level 2: warning and error messages are printed to stderr
Level 3: informational messages are printed to stdout, warning and error messages are printed to stderr -
Sometime I get error running like user.
This depends by fact that for some at me unknowed reason (at moment) the USB interface is already claimed by kernel and there is necessity to free it. To do that the program must be run in root rights.