Xuartctl: Difference between revisions
No edit summary |
|||
Line 12: | Line 12: | ||
== Overview == | == Overview == | ||
The the | 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 == | == Command line options == |
Revision as of 12:47, 23 May 2011
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.
Command line options
-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)
Available modes are: 8n1, raw, 8n2, dmx, 8e1, 8o1, 8e2, 8o2, 7n1, 7n2, 7e1, 7o1, 7e2, 7o2, 9n1
dmx will also set the baud rate to 250k
-d, --server
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
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.