Php Serial Port Communication Linux Kernel

Posted on  by  admin

I am attempting to connect to a serial device from a Android tablet, via USB-Serial Converter. In order to interface with this particular serial device, a linux library must be used as an interface. This library takes an integer as an argument, and tries to connect to the device at the following location: /dev/ttySx, where x is the arguement. If 2 is provided to the library, it will look for the device at /dev/ttyS2. When I connect the device to Ubuntu, there's is one simple extra step for this device to work with the USB-Serial convert. The converter is exposed at the location /dev/ttyUSB1.

I just need to create a simple soft-link with the serial port pattern (etc 'ln -s /dev/ttyUSV1 /dev/ttyS99'). It works perfectly. Now the problem arises for Android. The converter is seen at /dev/bus/usb/01/01. I never seen this convention in other project.

The question is how can I direct the I/O from /dev/ttySX to /dev/bus/usb/01/01. Quote: Originally Posted by ehpaul I am attempting to connect to a serial device from a Android tablet, via USB-Serial Converter. In order to interface with this particular serial device, a linux library must be used as an interface. This library takes an integer as an argument, and tries to connect to the device at the following location: /dev/ttySx, where x is the arguement. If 2 is provided to the library, it will look for the device at /dev/ttyS2. When I connect the device to Ubuntu, there's is one simple extra step for this device to work with the USB-Serial convert. The converter is exposed at the location /dev/ttyUSB1.

I just need to create a simple soft-link with the serial port pattern (etc 'ln -s /dev/ttyUSV1 /dev/ttyS99'). It works perfectly. Now the problem arises for Android. The converter is seen at /dev/bus/usb/01/01.

I never seen this convention in other project. The question is how can I direct the I/O from /dev/ttySX to /dev/bus/usb/01/01.

Hacking zte router (zxhn h108n) download and rename firmware to “ras”. Zte zxhn h108n firmware update.

Which android device are you using and with which kernel and android build? In my case I am using kernel 3.0.+ with CM9 on a Kindle Fire and I do see the /dev/ttyUSBx getting created along with the /dev/bus/01/01. It has been a month since I tried it but I was able to see the problem you see and here is what I remember. When you plug the serial convertor both /dev get created but since the Android USB support only uses /dev/bus/usb/01/01, the kernel in order to save power 'unmounts' the unused /dev/ttyUSBx after a certain time period.

You can try using dmesg to see if that is happening in your case also. There is a kernel build flag that tells the kernel not to 'unmount' it but I dont remember it off-hand.

Best would be to use the Android USB support to talk to your device instead of the linux library if you can. Quote: Originally Posted by pankaj013 Which android device are you using and with which kernel and android build? In my case I am using kernel 3.0.+ with CM9 on a Kindle Fire and I do see the /dev/ttyUSBx getting created along with the /dev/bus/01/01. It has been a month since I tried it but I was able to see the problem you see and here is what I remember. When you plug the serial convertor both /dev get created but since the Android USB support only uses /dev/bus/usb/01/01, the kernel in order to save power 'unmounts' the unused /dev/ttyUSBx after a certain time period. You can try using dmesg to see if that is happening in your case also.

There is a kernel build flag that tells the kernel not to 'unmount' it but I dont remember it off-hand. Best would be to use the Android USB support to talk to your device instead of the linux library if you can. This is from a question on stackoverflow titled 'Android USB host and hidden devices' (sorry, i can't add external URLs yet). It worked like a charm on a micromax A120 canvas 2 phone (kitkat 4.4.2). Now i can control my Arduino! I used busybox tools to do all the command line work (otherwise chmod wouldn't work). My steps (perhaps some were not required): (0) install PDAnet drivers on my Windows 8 computer.

Php Serial Port Communication Linux KernelKernelCommunication

(1) root the phone using Vroot (now called iRoot). Very simple, only catch is that the su grant/deny page is partly in chinese, no big deal.

(2) install busybox and jackpal's Android-Terminal-Emulator available on github and the google play store (free). (3) open a terminal window and become the superuser: # su (4) the file system may be read-only, so you might have to remount it: # mount -o rw,remount -t yaffs2 / or # mount -o rw,remount -t rootfs / or # mount -o rw,remount -t rootfs rootfs /system (5) make default.prop read/write: chmod 666 /default.prop (6) edit /default.prop, make the following changes: ro.secure=0 ro.debuggable=1 persist.service.adb.enable=1.

Linux Serial Port Communication

And this is the real meat of it: (7) To enable USB host API support you should add a file named android.hardware.usb.host.xml and containing the following lines: into folder /system/etc/permissions in that folder find file named handheldcorehardware.xml or tabletcorehardware.xml and add into section. (8) Reboot your device. Usb host api should work.

Coments are closed