Changes

Jump to: navigation, search
Created page with "{{InfoBoxTop}} {{AppliesToSBCLynx}} {{InfoBoxBottom}} == History == {| class="wikitable" border="1" !Version !Date !AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)|XUELK..."
{{InfoBoxTop}}
{{AppliesToSBCLynx}}
{{InfoBoxBottom}}

== History ==
{| class="wikitable" border="1"
!Version
!Date
![[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)|XUELK version]]
!Notes
|-
|{{oldid|7001|1.0.0}}
|October 2018
|[[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)#Downloadable_binary_images | 2.0.1]]
|First release
|}

==Introduction==
[[:Category:SBC_Lynx|SBC Lynx]] has two [[Physical_devices_mapping_(XUELK)#Multi-protocol_UARTs | serial port connector]] for mutliprotocol UARTs. Sometimes, further serial port can be required for particular applications.

This application note describes how to add other serial port using standard cable like the [http://www.manhattan-products.com/usb-to-serial-converter Manhattan PL2303] USB to serial converter

==USB serial converte kernel driver==

XUELK kernel [[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)#Downloadable_binary_images | 2.0.1]] already integrates the PL2303 driver.

Once plugged on USB host connector, the kernel driver recognizes the device

<pre class="board-terminal">
root@sbc-lynx:~# [ 7995.031735] usb 1-1: new full-speed USB device number 4 using ci_hdrc
[ 7995.196888] pl2303 1-1:1.0: pl2303 converter detected
</pre>

==tty==

If the kernel driver is present, the kernel create the <code>ttyUSBx</code> device node, e.g.

<pre class="board-terminal">
root@sbc-lynx:~# [ 42.091835] usb 1-1: new full-speed USB device number 2 using ci_hdrc
[ 42.259706] pl2303 1-1:1.0: pl2303 converter detected
[ 42.290004] usb 1-1: pl2303 converter now attached to ttyUSB0
</pre>

where <code>ttyUSB0</code> is the serial port device used for the new serial port instantiated

== Accessing the serial port ==
Here below the simple commands used for opening and using the serial port.

Once linux bootstrap is completed, insert the USB serial adapter:

<pre class="board-terminal">
root@sbc-lynx:~# [ 42.091835] usb 1-1: new full-speed USB device number 2 using ci_hdrc
[ 42.259706] pl2303 1-1:1.0: pl2303 converter detected
[ 42.290004] usb 1-1: pl2303 converter now attached to ttyUSB0
</pre>

The device node is listed:

<pre class="board-terminal">
root@sbc-lynx:~# ls -la /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Dec 10 03:20 /dev/ttyUSB0
root@sbc-lynx:~#
</pre>

Configure the serial port parameter, e.g.

<pre class="board-terminal">
root@sbc-lynx:~# stty -F /dev/ttyUSB0 115200
root@sbc-lynx:~#
</pre>

Connect the DB9 adapter to another device serial port, then you can check the correct transmission from SBC Lynx, simply echoing a string on the device:

<pre class="board-terminal">
root@sbc-lynx:~# echo "This is a serial port test transmission" > /dev/ttyUSB0
root@sbc-lynx:~#
</pre>

or getting a string from the other device simply with a cat on the device (terminated with Ctrl+C:

<pre class="board-terminal">
root@sbc-lynx:~# cat /dev/ttyUSB0
This is a serial port test reception
^C
root@sbc-lynx:~#
</pre>

== Serial port hotplug ==

Disconnecting the USB serial port adapter, the kernel close the device:

<pre class="board-terminal">
root@sbc-lynx:~# [ 517.344155] usb 1-1: USB disconnect, device number 2
[ 517.358084] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 517.368117] pl2303 1-1:1.0: device disconnected

root@sbc-lynx:~# ls -la /dev/ttyUSB0
ls: /dev/ttyUSB0: No such file or directory
root@sbc-lynx:~#
</pre>

and reinserting the cable, the device will be automatically re-created:

<pre class="board-terminal">
</pre>

It is possible to test the kernel hotplug capability with this simple script:

echo Test kernel USB hotplug
echo
while [ 1 ]
do
read -p "Insert the cable and press Enter" answer
echo Test the device presence:
echo
ls -la /dev/ttyUSB0
sleep 1
read -p "Disconnect the cable and press Enter" answer
echo Test the device disconnection:
echo
ls -la /dev/ttyUSB0
sleep 1
done

ansd repeat the connect/disconnect many times

<pre class="workstation-terminal">
root@sbc-lynx:~# sh test-usb-to-serial.sh
Test kernel USB hotplug

Insert the cable and press Enter[ 968.021749] usb 1-1: new full-speed USB device number 11 using ci_hdrc
[ 968.186161] pl2303 1-1:1.0: pl2303 converter detected
[ 968.214650] usb 1-1: pl2303 converter now attached to ttyUSB0

Test the device presence:

crw-rw---- 1 root dialout 188, 0 Dec 10 03:35 /dev/ttyUSB0
Disconnect the cable and press Enter[ 972.397217] usb 1-1: USB disconnect, device number 11
[ 972.407480] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 972.427977] pl2303 1-1:1.0: device disconnected

Test the device disconnection:

ls: /dev/ttyUSB0: No such file or directory
Insert the cable and press Enter[ 976.331835] usb 1-1: new full-speed USB device number 12 using ci_hdrc
[ 976.497614] pl2303 1-1:1.0: pl2303 converter detected
[ 976.525595] usb 1-1: pl2303 converter now attached to ttyUSB0

Test the device presence:

crw-rw---- 1 root dialout 188, 0 Dec 10 03:35 /dev/ttyUSB0
Disconnect the cable and press Enter[ 980.698156] usb 1-1: USB disconnect, device number 12
[ 980.714359] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 980.729902] pl2303 1-1:1.0: device disconnected

Test the device disconnection:

ls: /dev/ttyUSB0: No such file or directory
Insert the cable and press Enter[ 985.201808] usb 1-1: new full-speed USB device number 13 using ci_hdrc
[ 985.367978] pl2303 1-1:1.0: pl2303 converter detected
[ 985.395658] usb 1-1: pl2303 converter now attached to ttyUSB0

Test the device presence:

crw-rw---- 1 root dialout 188, 0 Dec 10 03:35 /dev/ttyUSB0
Disconnect the cable and press Enter[ 988.074469] usb 1-1: USB disconnect, device number 13
[ 988.089665] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 988.103128] pl2303 1-1:1.0: device disconnected

Test the device disconnection:

ls: /dev/ttyUSB0: No such file or directory
Insert the cable and press Enter^C
root@sbc-lynx:~#
</pre>
8,220
edits

Navigation menu