Xuartctl: Difference between revisions

From embeddedTS Manuals
No edit summary
Line 14: Line 14:
XUART TTL 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 TTL 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.


== Command line options ==
== Help ==


=== -i, --irq=N ===
<SyntaxHighlight lang=bash>
Use IRQ N as XUART IRQ (32)
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


=== -r, --regstart=ADD ===
-i, --irq=N            Use IRQ N as XUART IRQ (32)
Use ADD address as regstart (0x600ff100)
-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


=== -m, --memstart=ADD ===
</SyntaxHighlight>
Use ADD address as memstart (0x60000000)


=== -s, --speed=BAUD ===
=== Supported Modes ===
Use BAUD as default baudrate (115200)
{| class="wikitable"
|-
! Mode
! Notes
|-
| 8n1
| (default mode)
|-
| 8n2
|-
| dmx
| baudrate argument is ignored, uses 250 kbaud
|-
| 8e1
|-
| 8o1
|-
| 8e2
|-
| 8o2
|-
| 7n1
|-
| 7n2
|-
| 7e1
|-
| 7o1
|-
| 7e2
|-
| 7o2
|}


=== -o, --mode=MODE ===
== Common Usage ==
Use MODE as default mode (8n1)


Available modes are:
=== Change the default mode and baud rate for all ports ===
8n1, raw, 8n2, dmx, 8e1, 8o1, 8e2, 8o2, 7n1, 7n2, 7e1, 7o1, 7e2, 7o2, 9n1
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:


dmx will also set the baud rate to 250k
<SyntaxHighlight lang=bash>
  xuartctl --server
</SyntaxHighlight>
to
<SyntaxHighlight lang=bash>
  xuartctl --server --speed=9600 --mode=7e1
</SyntaxHighlight>


=== -d, --server ===
=== Configure baud rate for port specific port ===
Daemonize and run as server.  Default is to listen at TCP port numbers starting at 7350 with 1 port per XUART channel.
 
=== -I, --bind=IPADDR ===
Bind server to IPADDR.  You can specify 127.0.0.1 to restrict the ports to a local connection only.  They are by default accesible from the outside.
 
=== -p, --port=PORT ===
Connect to local or remote XUART port
 
The PORT option can be a either a number 0-7, or a HOSTNAME:TCPPORT for a remote TCP socket.  When both --port and --server are used, a pseudo-tty is allocated and connected to the XUART channel and pseudo-tty processing continues in the background.  When only --port is specified and no command is given, stdin and stdout are connected to the XUART channel.  Otherwise COMMAND is run as a sub-program with its stdin/stdout/stderr connected to the allocated pseudo-tty.
 
=== -t, --test Run loopback and latency test ===
Tests the latency to the uarts.
 
=== -h, --help ===
Print the help menu
 
== Examples ==
 
=== Configure baud rate ===
<SyntaxHighlight lang=bash>
<SyntaxHighlight lang=bash>
xuartctl --port 0 --speed 115200
xuartctl --port 0 --speed 115200

Revision as of 13:08, 23 May 2011

xuartctl
Xuartctl-diagram.png

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

Overview

XUART TTL 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

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

Common Usage

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 port 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, 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.