Xuartctl: Difference between revisions

From embeddedTS Manuals
No edit summary
Line 10: Line 10:
xuartctl is a userspace driver utility to manage the UARTs that go through the FPGA.
xuartctl is a userspace driver utility to manage the UARTs that go through the FPGA.


== Overview ==
= Overview =


XUART serial ports are also implemented entirely from userspace. The 8 serial ports have a single shared 4kByte receive FIFO which makes real time interrupt latency response less of a concern and in actual implementation, the serial ports are simply polled at 100Hz and don't even use an IRQ. Even with all 8 ports running at 230400 baud, it is not possible to overflow the receive FIFO in 1/100th of a second. The "xuartctl --server" daemon is started by default in the INITRD linuxrc file which sets up listening TCP/IP ports for all 8 XUART channels on ports 7350-7357. An application may simply connect to these ports via localhost (or via the network) and use the serial ports as if they were network services.
XUART serial ports are also implemented entirely from userspace. The 8 serial ports have a single shared 4kByte receive FIFO which makes real time interrupt latency response less of a concern and in actual implementation, the serial ports are simply polled at 100Hz and don't even use an IRQ. Even with all 8 ports running at 230400 baud, it is not possible to overflow the receive FIFO in 1/100th of a second. The "xuartctl --server" daemon is started by default in the INITRD linuxrc file which sets up listening TCP/IP ports for all 8 XUART channels on ports 7350-7357. An application may simply connect to these ports via localhost (or via the network) and use the serial ports as if they were network services.


== Help ==
= Usage =
The xuartctl utility is split into 2 parts.  The first part is the main server.  This server must run on the board and provides the communication between the FPGA and the TCP ports.  This can be created by running:
<source lang=bash>
xuartctl --server
</source>


=== Usage ===
You can also specify the speed and mode arguments to make them the default for the port servers.  The port servers are created by simply specifying a port after the main server has been started:
<SyntaxHighlight lang=bash>
<source lang=bash>
xuartctl --server --port=0 --speed=115200
</source>
 
 
 
== Usage ==
<source lang=bash>
xuartctl --help
xuartctl --help
Usage: xuartctl [OPTION] ...
Usage: xuartctl [OPTION] ...
Line 35: Line 46:
  -t, --test              Run loopback and latency test
  -t, --test              Run loopback and latency test
  -h, --help              This help
  -h, --help              This help
</source>


</SyntaxHighlight>
== Supported Modes ==
 
=== Supported Modes ===
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 76: Line 86:
|}
|}


== Examples ==
= Examples =


=== Change the default mode and baud rate for all ports ===
== Change the default mode and baud rate for all ports ==
The default mode is "8N1" and default baud rate is 115200-- should the default need to be changed, modifying the linuxrc line that invokes the XUART server can be changed from:
The default mode is "8N1" and default baud rate is 115200-- should the default need to be changed, modifying the linuxrc line that invokes the XUART server can be changed from:


<SyntaxHighlight lang=bash>
<source lang=bash>
   xuartctl --server
   xuartctl --server
</SyntaxHighlight>
</source>
to
to
<SyntaxHighlight lang=bash>
<source lang=bash>
   xuartctl --server --speed=9600 --mode=7e1
   xuartctl --server --speed=9600 --mode=7e1
</SyntaxHighlight>
</source>


=== Configure baud rate for specific port ===
== Configure baud rate for specific port ==
<SyntaxHighlight lang=bash>
<source lang=bash>
xuartctl --port 0 --speed 115200
xuartctl --port 0 --speed 115200
</SyntaxHighlight>
</source>


=== Configure xuarts on startup ===
== Configure xuarts on startup ==
Edit your /etc/rc.local file and add in these lines before exit:
Edit your /etc/rc.local file and add in these lines before exit:
<SyntaxHighlight lang=bash>
<source lang=bash>
eval $(xuartctl --port 0 --speed 9600 2>&1); ln -s $ttyname /dev/ttyxuart0
eval $(xuartctl --port 0 --speed 9600 2>&1); ln -s $ttyname /dev/ttyxuart0
eval $(xuartctl --port 1 --speed 115200 2>&1); ln -s $ttyname /dev/ttyxuart1
eval $(xuartctl --port 1 --speed 115200 2>&1); ln -s $ttyname /dev/ttyxuart1
eval $(xuartctl --port 2 --speed 38400 2>&1); ln -s $ttyname /dev/ttyxuart2
eval $(xuartctl --port 2 --speed 38400 2>&1); ln -s $ttyname /dev/ttyxuart2
</SyntaxHighlight>
</source>


=== Create a local xuart port server running on a remote xuartctl main server ===
== Create a local xuart port server running on a remote xuartctl main server ==
If the xuartctl --server is running remotely on 192.168.0.50, you could run this from any remote system:
If the xuartctl --server is running remotely on 192.168.0.50, you could run this from any remote system:
<SyntaxHighlight lang=bash>
<source lang=bash>
xuartctl --port=192.168.0.50:7350 --speed=9600
xuartctl --port=192.168.0.50:7350 --speed=9600
</SyntaxHighlight>
</source>


== FAQ ==
= FAQ =


=== How do I kill the old xuart process controlling one port? ===
== How do I kill the old xuart process controlling one port? ==
When you run xuartctl on a port that is already running, it will replace that instance without affecting the other configured ports.
When you run xuartctl on a port that is already running, it will replace that instance without affecting the other configured ports.


=== xuartctl works in the booted environment, but not in my startup scripts ===
== xuartctl works in the booted environment, but not in my startup scripts ==
Make sure the main server is started when you try to start a port server.  If you add your scripts in /etc/rc.local or your fastboot linuxrc, you should be fine.  However if it doesn't start you can create the main server instance with:
Make sure the main server is started when you try to start a port server.  If you add your scripts in /etc/rc.local or your fastboot linuxrc, you should be fine.  However if it doesn't start you can create the main server instance with:
<SyntaxHighlight lang=bash>
<source lang=bash>
xuartctl --server
xuartctl --server
</SyntaxHighlight>
</source>


=== When I brought up my first port it appeared as /dev/pts/1, but normally shows up as /dev/pts/0 ===
== When I brought up my first port it appeared as /dev/pts/1, but normally shows up as /dev/pts/0 ==
The psuedo terminal devices will show up in order they were brought up, and other devices can claim them as xuartctl does.  If you want this consistancy, it is usually best to link the files to the output of xuartctl's ttyname.
The psuedo terminal devices will show up in order they were brought up, and other devices can claim them as xuartctl does.  If you want this consistancy, it is usually best to link the files to the output of xuartctl's ttyname.

Revision as of 15:58, 16 June 2011

xuartctl
Xuartctl-diagram.png

xuartctl is a userspace driver utility to manage the UARTs that go through the FPGA.

Overview

XUART serial ports are also implemented entirely from userspace. The 8 serial ports have a single shared 4kByte receive FIFO which makes real time interrupt latency response less of a concern and in actual implementation, the serial ports are simply polled at 100Hz and don't even use an IRQ. Even with all 8 ports running at 230400 baud, it is not possible to overflow the receive FIFO in 1/100th of a second. The "xuartctl --server" daemon is started by default in the INITRD linuxrc file which sets up listening TCP/IP ports for all 8 XUART channels on ports 7350-7357. An application may simply connect to these ports via localhost (or via the network) and use the serial ports as if they were network services.

Usage

The xuartctl utility is split into 2 parts. The first part is the main server. This server must run on the board and provides the communication between the FPGA and the TCP ports. This can be created by running:

xuartctl --server

You can also specify the speed and mode arguments to make them the default for the port servers. The port servers are created by simply specifying a port after the main server has been started:

xuartctl --server --port=0 --speed=115200


Usage

xuartctl --help
Usage: xuartctl [OPTION] ...
xuartctl --port=PORT [OPTION] ... -- [COMMAND] [ARGS]
Technologic Systems XUART core userspace driver utility.
Example: xuartctl --server
    xuartctl --port=192.168.0.50:7350 --speed=9600 -- /bin/sh -i
    xuartctl --port=0 --test

 -i, --irq=N             Use IRQ N as XUART IRQ (32)
 -r, --regstart=ADD      Use ADD address as regstart (0x600ff100)
 -m, --memstart=ADD      Use ADD address as memstart (0x60000000)
 -s, --speed=BAUD        Use BAUD as default baudrate (115200)
 -o, --mode=MODE         Use MODE as default mode (8n1)
 -d, --server            Daemonize and run as server
 -p, --port=PORT         Connect to local or remote XUART port
 -t, --test              Run loopback and latency test
 -h, --help              This help

Supported Modes

Mode Notes
8n1 (default mode)
8n2
dmx baudrate argument is ignored, uses 250 kbaud
8e1
8o1
8e2
8o2
7n1
7n2
7e1
7o1
7e2
7o2
9n1 The pseudo-tty is incompatible with this mode. You must use TCP.

Examples

Change the default mode and baud rate for all ports

The default mode is "8N1" and default baud rate is 115200-- should the default need to be changed, modifying the linuxrc line that invokes the XUART server can be changed from:

   xuartctl --server

to

   xuartctl --server --speed=9600 --mode=7e1

Configure baud rate for specific port

xuartctl --port 0 --speed 115200

Configure xuarts on startup

Edit your /etc/rc.local file and add in these lines before exit:

eval $(xuartctl --port 0 --speed 9600 2>&1); ln -s $ttyname /dev/ttyxuart0
eval $(xuartctl --port 1 --speed 115200 2>&1); ln -s $ttyname /dev/ttyxuart1
eval $(xuartctl --port 2 --speed 38400 2>&1); ln -s $ttyname /dev/ttyxuart2

Create a local xuart port server running on a remote xuartctl main server

If the xuartctl --server is running remotely on 192.168.0.50, you could run this from any remote system:

xuartctl --port=192.168.0.50:7350 --speed=9600

FAQ

How do I kill the old xuart process controlling one port?

When you run xuartctl on a port that is already running, it will replace that instance without affecting the other configured ports.

xuartctl works in the booted environment, but not in my startup scripts

Make sure the main server is started when you try to start a port server. If you add your scripts in /etc/rc.local or your fastboot linuxrc, you should be fine. However if it doesn't start you can create the main server instance with:

xuartctl --server

When I brought up my first port it appeared as /dev/pts/1, but normally shows up as /dev/pts/0

The psuedo terminal devices will show up in order they were brought up, and other devices can claim them as xuartctl does. If you want this consistancy, it is usually best to link the files to the output of xuartctl's ttyname.