<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://monnier.astro.lsa.umich.edu/research/index.php?action=history&amp;feed=atom&amp;title=RT_System</id>
	<title>RT System - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://monnier.astro.lsa.umich.edu/research/index.php?action=history&amp;feed=atom&amp;title=RT_System"/>
	<link rel="alternate" type="text/html" href="https://monnier.astro.lsa.umich.edu/research/index.php?title=RT_System&amp;action=history"/>
	<updated>2026-08-04T10:37:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://monnier.astro.lsa.umich.edu/research/index.php?title=RT_System&amp;diff=1137&amp;oldid=prev</id>
		<title>Monnier: New page: Real-time System ---++ Xenomai ---+++ Install Debian network install using debian-503-i386-businesscard.iso  I used linux.csua.berkrley.edu as a mirror for Debian archive. The install is p...</title>
		<link rel="alternate" type="text/html" href="https://monnier.astro.lsa.umich.edu/research/index.php?title=RT_System&amp;diff=1137&amp;oldid=prev"/>
		<updated>2010-06-02T14:38:34Z</updated>

		<summary type="html">&lt;p&gt;New page: Real-time System ---++ Xenomai ---+++ Install Debian network install using debian-503-i386-businesscard.iso  I used linux.csua.berkrley.edu as a mirror for Debian archive. The install is p...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Real-time System&lt;br /&gt;
---++ Xenomai&lt;br /&gt;
---+++ Install&lt;br /&gt;
Debian network install using debian-503-i386-businesscard.iso&lt;br /&gt;
&lt;br /&gt;
I used linux.csua.berkrley.edu as a mirror for Debian archive.&lt;br /&gt;
The install is pretty straightforward. I used guided partitioning using entire disc.&lt;br /&gt;
 &lt;br /&gt;
After install and reboot edit /etc/network/interfaces to look like this:&lt;br /&gt;
&lt;br /&gt;
# This file describes the network interfaces available on your system&lt;br /&gt;
# and how to activate them. For more information, see interfaces(5).&lt;br /&gt;
&lt;br /&gt;
# The loopback network interface&lt;br /&gt;
auto lo&lt;br /&gt;
iface lo inet loopback&lt;br /&gt;
&lt;br /&gt;
# The primary network interface&lt;br /&gt;
allow-hotplug eth0&lt;br /&gt;
iface eth0 inet static&lt;br /&gt;
        address 192.168.3.136&lt;br /&gt;
        netmask 255.255.255.0&lt;br /&gt;
        network 192.168.3.0&lt;br /&gt;
        broadcast 192.168.3.255&lt;br /&gt;
        gateway 192.168.3.1&lt;br /&gt;
        # dns-* options are implemented by the resolvconf package, if installed&lt;br /&gt;
        dns-nameservers 192.153.157.142&lt;br /&gt;
        dns-search chara-array.org&lt;br /&gt;
&lt;br /&gt;
if you want to work remotely install ssh server&lt;br /&gt;
aptitude install openssh-server&lt;br /&gt;
&lt;br /&gt;
aptitude search package will search a package in the debian archive.&lt;br /&gt;
&lt;br /&gt;
Once installation finished create a file called  preference in /etc/apt&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=stable&lt;br /&gt;
Pin-Priority: 700&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=testing&lt;br /&gt;
Pin-Priority: 650&lt;br /&gt;
&lt;br /&gt;
Package: *&lt;br /&gt;
Pin: release a=unstable&lt;br /&gt;
Pin-Priority: 600&lt;br /&gt;
&lt;br /&gt;
Then modify /etc/apt/sources.list to look like this:&lt;br /&gt;
&lt;br /&gt;
# &lt;br /&gt;
# deb cdrom:[Debian GNU/Linux 5.0.2 _Lenny_ - Official i386 NETINST Binary-1 20090629-11:06]/ lenny main&lt;br /&gt;
&lt;br /&gt;
#deb cdrom:[Debian GNU/Linux 5.0.2 _Lenny_ - Official i386 NETINST Binary-1 20090629-11:06]/ lenny main&lt;br /&gt;
&lt;br /&gt;
#stable&lt;br /&gt;
deb http://linux.csua.berkeley.edu/debian/ lenny main non-free contrib&lt;br /&gt;
deb-src http://linux.csua.berkeley.edu/debian/ lenny main non-free contrib&lt;br /&gt;
deb http://security.debian.org/ lenny/updates main non-free contrib&lt;br /&gt;
deb-src http://security.debian.org/ lenny/updates main non-free contrib&lt;br /&gt;
deb http://volatile.debian.org/debian-volatile lenny/volatile main non-free contrib&lt;br /&gt;
deb-src http://volatile.debian.org/debian-volatile lenny/volatile main non-free contrib&lt;br /&gt;
&lt;br /&gt;
#testing&lt;br /&gt;
deb http://ftp.us.debian.org/debian testing main non-free contrib&lt;br /&gt;
deb-src http://ftp.us.debian.org/debian testing main non-free contrib&lt;br /&gt;
&lt;br /&gt;
#unstable&lt;br /&gt;
deb http://ftp.us.debian.org/debian unstable main non-free contrib&lt;br /&gt;
deb-src http://ftp.us.debian.org/debian unstable main non-free contrib&lt;br /&gt;
&lt;br /&gt;
aptitude update&lt;br /&gt;
aptitude safe-upgrade&lt;br /&gt;
aptitude full-upgrade&lt;br /&gt;
&lt;br /&gt;
if you get this:&lt;br /&gt;
E: Dynamic MMap ran out of room&lt;br /&gt;
&lt;br /&gt;
Add the following line to /etc/apt/apt.conf&lt;br /&gt;
&lt;br /&gt;
APT::Cache-Limit &amp;quot;8388608&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will be on debian STABLE. you can install packages from testing or unstable by typing:&lt;br /&gt;
&lt;br /&gt;
aptitude install &amp;lt;package&amp;gt; /unstable&lt;br /&gt;
(or /testing)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install screen (useful when compiling remotely if ssh connection dies)&lt;br /&gt;
&lt;br /&gt;
aptitude install screen&lt;br /&gt;
&lt;br /&gt;
run screen&lt;br /&gt;
&lt;br /&gt;
Now install the latest xenomai&lt;br /&gt;
&lt;br /&gt;
cd /usr/src&lt;br /&gt;
&lt;br /&gt;
Install the packages necessary to compile the kernel.&lt;br /&gt;
aptitude install kernel-package ncurses-dev fakeroot bzip2&lt;br /&gt;
&lt;br /&gt;
Install package to retrieve latest stable xenomai from the git repository  &lt;br /&gt;
aptitude install git-buildpackage&lt;br /&gt;
aptitude install pbuilder&lt;br /&gt;
&lt;br /&gt;
Using new howto on: http://www.xenomai.org/index.php/Building_Debian_packages&lt;br /&gt;
&lt;br /&gt;
aptitude install devscripts debhelper dh-kpatches findutils&lt;br /&gt;
&lt;br /&gt;
rom a Git repository&lt;br /&gt;
&lt;br /&gt;
To build from a git Repository install these additional packages and clone the Git repository:&lt;br /&gt;
&lt;br /&gt;
# apt-get install git-core git-buildpackage&lt;br /&gt;
# cd /usr/src&lt;br /&gt;
$ git clone git://xenomai.org/xenomai-2.5.git&lt;br /&gt;
&lt;br /&gt;
Change to the Xenomai Git working tree and update the repository:&lt;br /&gt;
&lt;br /&gt;
$ cd xenomai-2.5 &amp;amp;&amp;amp; git fetch origin&lt;br /&gt;
&lt;br /&gt;
Create and checkout a new branch based on a git treeish object. In this example, we create a branch v2.5.3-deb based on git tag v2.5.3:&lt;br /&gt;
&lt;br /&gt;
xenomai-2.5$ git checkout -b v2.5.3-deb v2.5.3&lt;br /&gt;
&lt;br /&gt;
Create a new debian changelog entry:&lt;br /&gt;
&lt;br /&gt;
xenomai-2.5$ DEBEMAIL=&amp;quot;your@email&amp;quot; DEBFULLNAME=&amp;quot;Your Name&amp;quot; debchange -v 2.5.3-0.1 Release 2.5.3&lt;br /&gt;
&lt;br /&gt;
Commit the changelog to the v2.5.3-deb branch:&lt;br /&gt;
&lt;br /&gt;
xenomai-2.5$ git commit -a --author=&amp;quot;Your Name &amp;lt;your@email&amp;gt;&amp;quot; -m 2.5.3-0.1&lt;br /&gt;
&lt;br /&gt;
Build the packages in the parent directory:&lt;br /&gt;
&lt;br /&gt;
xenomai-2.5$ git-buildpackage \&lt;br /&gt;
 --git-upstream-branch=v2.5.3 \&lt;br /&gt;
 --git-debian-branch=v2.5.3-deb \&lt;br /&gt;
 --git-export-dir=.. \&lt;br /&gt;
 -uc -us&lt;br /&gt;
&lt;br /&gt;
Switch back to the master branch and delete the branch v2.5.3-deb:&lt;br /&gt;
&lt;br /&gt;
xenomai-2.5$ git checkout master &amp;amp;&amp;amp; git branch -D v2.5.3-deb&lt;br /&gt;
&lt;br /&gt;
use dpkg to install the packages:&lt;br /&gt;
&lt;br /&gt;
# dpkg -i *.deb&lt;br /&gt;
&lt;br /&gt;
dpkg-query -W -f&amp;#039;${Description}\n&amp;#039; linux-patch-xenomai | grep Patch-file&lt;br /&gt;
&lt;br /&gt;
Apply the Xenomai adeos-ipipe patch and compile kernel:&lt;br /&gt;
&lt;br /&gt;
tar -jxf linux-2.6.32.11.tar.bz2 &amp;amp;&amp;amp; cd linux-2.6.32.11&lt;br /&gt;
&lt;br /&gt;
remember to copy to this directory the .config file used in the previous kernel&lt;br /&gt;
cp /boot/config-2.6.32.11-xenomai-2.5.3 .config (note: this file  could be called differently).&lt;br /&gt;
&lt;br /&gt;
since we copied the old .config file we can use --config oldconfig&lt;br /&gt;
if you want to edit the kernel configuration use --config menuconfig (NEVER edit .config manually).&lt;br /&gt;
&lt;br /&gt;
Compile and patch the kernel:&lt;br /&gt;
&lt;br /&gt;
CONCURRENCY_LEVEL=2 fakeroot make-kpkg --initrd --added-patches xenomai --append-to-version -xenomai-2.5.3 --revision 1.0 --config oldconfig binary-arch&lt;br /&gt;
&lt;br /&gt;
If you need to recompile the kernel additional times, avoid reapplying the xenomai patch:&lt;br /&gt;
&lt;br /&gt;
CONCURRENCY_LEVEL=2 fakeroot make-kpkg --initrd --revision=ipipe.2.0.05  binary-arch&lt;br /&gt;
&lt;br /&gt;
install the kernel&lt;br /&gt;
&lt;br /&gt;
dpkg -i linux-image-2.6.31.1_ipipe.2.0.05_i386.deb&lt;br /&gt;
&lt;br /&gt;
modify /boot/grub/menu.lst &lt;br /&gt;
root= should not use the device (/dev/sda1) since that may change. Use the UUID (obtained typing blkid) or the label of the disc&lt;br /&gt;
&lt;br /&gt;
Also append &amp;quot;noht mem=2048M memmap=1024M&amp;quot; to the real time kernel using the asgtropci board.&lt;br /&gt;
&lt;br /&gt;
install kernel and headers&lt;br /&gt;
dpkg -i linux-image*.deb&lt;br /&gt;
&lt;br /&gt;
emacs /boot/grub/menu.lst&lt;br /&gt;
&lt;br /&gt;
title           Debian GNU/Linux, kernel 2.6.32.11-xenomai-2.5.3&lt;br /&gt;
root            (hd0,0)&lt;br /&gt;
kernel          /boot/vmlinuz-2.6.32.11-xenomai-2.5.3 root=LABEL=ROOTFS_TEST ro noht mem=2048M memmap=1024M pci=routeirq&lt;br /&gt;
initrd          /boot/initrd.img-2.6.32.11-xenomai-2.5.3&lt;br /&gt;
&lt;br /&gt;
title           Debian GNU/Linux, kernel 2.6.32.11-xenomai-2.5.3 (single-user mode)&lt;br /&gt;
root            (hd0,0)&lt;br /&gt;
kernel          /boot/vmlinuz-2.6.32.11-xenomai-2.5.3 root=LABEL=ROOTFS_TEST ro single&lt;br /&gt;
initrd          /boot/initrd.img-2.6.32.11-xenomai-2.5.3&lt;br /&gt;
&lt;br /&gt;
title           Debian GNU/Linux, kernel 2.6.26-2-686&lt;br /&gt;
root            (hd0,0)&lt;br /&gt;
kernel          /boot/vmlinuz-2.6.26-2-686 root=LABEL=ROOTFS_TEST ro quiet&lt;br /&gt;
initrd          /boot/initrd.img-2.6.26-2-686&lt;br /&gt;
&lt;br /&gt;
Also modify /etc/fstab to use UUID or LABEL instead of devices. Label names have to be unique:&lt;br /&gt;
&lt;br /&gt;
# /etc/fstab: static file system information.&lt;br /&gt;
#&lt;br /&gt;
# &amp;lt;file system&amp;gt;         &amp;lt;mount point&amp;gt;   &amp;lt;type&amp;gt;          &amp;lt;options&amp;gt;               &amp;lt;dump&amp;gt;  &amp;lt;pass&amp;gt;&lt;br /&gt;
proc                    /proc           proc            defaults                0       0&lt;br /&gt;
LABEL=ROOTFS-XENO       /               ext3            errors=remount-ro       0       1&lt;br /&gt;
LABEL=SWAP-XENO         none            swap            sw                      0       0&lt;br /&gt;
/dev/scd0               /media/cdrom0   udf,iso9660     user,noauto             0       0&lt;br /&gt;
/dev/fd0                /media/floppy0  auto            rw,user,noauto          0       0&lt;br /&gt;
&lt;br /&gt;
Modify /etc/modules to look like this:&lt;br /&gt;
&lt;br /&gt;
# /etc/modules: kernel modules to load at boot time.&lt;br /&gt;
#&lt;br /&gt;
# This file contains the names of kernel modules that should be loaded&lt;br /&gt;
# at boot time, one per line. Lines beginning with &amp;quot;#&amp;quot; are ignored.&lt;br /&gt;
# Parameters can be specified after the module name.&lt;br /&gt;
&lt;br /&gt;
loop&lt;br /&gt;
xeno_native&lt;br /&gt;
xeno_rtdm&lt;br /&gt;
&lt;br /&gt;
In this way the xenomai modules are loaded at boot time.&lt;br /&gt;
&lt;br /&gt;
and reboot&lt;br /&gt;
&lt;br /&gt;
Type lsmod to see the kernel modules loaded.&lt;br /&gt;
It should show:&lt;br /&gt;
&lt;br /&gt;
Module                  Size  Used by&lt;br /&gt;
xeno_native           105088  0 &lt;br /&gt;
analogy_ni_pcimio      15644  0 &lt;br /&gt;
analogy_ni_mio         44860  1 analogy_ni_pcimio&lt;br /&gt;
analogy_ni_tio         24956  1 analogy_ni_mio&lt;br /&gt;
analogy_8255            3900  1 analogy_ni_mio&lt;br /&gt;
analogy_ni_mite        10140  3 analogy_ni_pcimio,analogy_ni_mio,analogy_ni_tio&lt;br /&gt;
xeno_analogy           40220  5 analogy_ni_pcimio,analogy_ni_mio,analogy_ni_tio,analogy_8255,analogy_ni_mite&lt;br /&gt;
xeno_rtdm              28436  2 analogy_ni_mio,xeno_analogy&lt;br /&gt;
ext3                  109636  1 &lt;br /&gt;
jbd                    43920  1 ext3&lt;br /&gt;
mbcache                 6272  1 ext3&lt;br /&gt;
ide_pci_generic         3712  0 &lt;br /&gt;
ide_core               74204  1 ide_pci_generic&lt;br /&gt;
ata_piix               15748  2 &lt;br /&gt;
sata_mv                26448  0 &lt;br /&gt;
e1000                 114208  0 &lt;br /&gt;
libata                142156  2 ata_piix,sata_mv&lt;br /&gt;
unix                   22992  10 &lt;br /&gt;
&lt;br /&gt;
all the analogy drives are the real-time comedi drivers (not present in mirkwood).&lt;br /&gt;
&lt;br /&gt;
Obtain the astropci driver from the Bob Leach site. For kernel 2.6.30 is astropciFC11.tar.bz2.&lt;br /&gt;
&lt;br /&gt;
tar xjf astropciFC11.tar.bz2 &lt;br /&gt;
cd /usr/src/astropci/FC11/&lt;br /&gt;
make default&lt;br /&gt;
make install&lt;br /&gt;
&lt;br /&gt;
reboot&lt;br /&gt;
&lt;br /&gt;
Now with lsmod you should see an extra module:&lt;br /&gt;
astropci               10944  0&lt;br /&gt;
&lt;br /&gt;
I have not figured out how to create the node /dev/astropci automatically. &lt;br /&gt;
&lt;br /&gt;
execute this command to create the node:&lt;br /&gt;
&lt;br /&gt;
astropci_make_node&lt;br /&gt;
&lt;br /&gt;
you can test the RTOS with xeno-test&lt;br /&gt;
&lt;br /&gt;
xeno-test was  broken but I fixed it doing the following links:&lt;br /&gt;
&lt;br /&gt;
 ln -s /usr/lib/xenomai/clocktest /usr/bin/clocktest&lt;br /&gt;
 ln -s /usr/lib/xenomai/cyclictest /usr/bin/cyclictest&lt;br /&gt;
 ln -s /usr/lib/xenomai/irqloop /usr/bin/irqloop&lt;br /&gt;
 ln -s /usr/lib/xenomai/klatency /usr/bin/klatency&lt;br /&gt;
 ln -s /usr/lib/xenomai/latency /usr/bin/latency&lt;br /&gt;
 ln -s /usr/lib/xenomai/sigtest /usr/bin/sigtest&lt;br /&gt;
 ln -s /usr/lib/xenomai/switchtest /usr/bin/switchtest&lt;br /&gt;
 ln -s /usr/lib/xenomai/unit /usr/bin/unit&lt;br /&gt;
&lt;br /&gt;
Install CVS and SVN to retrieve MIRC anc CHAMP trees.&lt;br /&gt;
&lt;br /&gt;
aptitude install cvs subversion&lt;br /&gt;
&lt;br /&gt;
Now test compile of old mirkwood code&lt;br /&gt;
&lt;br /&gt;
install dependencies&lt;br /&gt;
&lt;br /&gt;
aptitude install fftw3&lt;br /&gt;
aptitude install fftw3-dev&lt;br /&gt;
aptitude install fftw3-doc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---+++ RTNET&lt;br /&gt;
Building RTNET&lt;br /&gt;
&lt;br /&gt;
Download git tree in /usr/src/&lt;br /&gt;
&lt;br /&gt;
git clone git://rtnet.git.sourceforge.net/gitroot/rtnet/rtnet&lt;br /&gt;
&lt;br /&gt;
Change name of directory to a tag name (otherwise dhmake refuses to write debian info to dir)&lt;br /&gt;
&lt;br /&gt;
mv rtnet rtnet-0.9.11&lt;br /&gt;
&lt;br /&gt;
Install the package dh_make&lt;br /&gt;
&lt;br /&gt;
aptitude install dh-make&lt;br /&gt;
&lt;br /&gt;
cd rtnet-0.9.11/&lt;br /&gt;
&lt;br /&gt;
dh_make --createorig&lt;br /&gt;
&lt;br /&gt;
Type of package: single binary, multiple binary, library, kernel module or cdbs?&lt;br /&gt;
 [s/m/l/k/b] b&lt;br /&gt;
&lt;br /&gt;
Maintainer name : root&lt;br /&gt;
Email-Address   : root@fangorn.chara-array.org &lt;br /&gt;
Date            : Fri, 27 Nov 2009 03:15:25 -0800&lt;br /&gt;
Package Name    : rtnet&lt;br /&gt;
Version         : 0.9.11&lt;br /&gt;
License         : blank&lt;br /&gt;
Using dpatch    : no&lt;br /&gt;
Type of Package : cdbs&lt;br /&gt;
Hit &amp;lt;enter&amp;gt; to confirm: &lt;br /&gt;
Done. Please edit the files in the debian/ subdirectory now. rtnet&lt;br /&gt;
uses a configure script, so you probably don&amp;#039;t have to edit the Makefiles.&lt;br /&gt;
fangorn:/usr/src/rtnet-0.9.11# git clone git://rtnet.git.sourceforge.net/gitroot/rtnet/rtnet&lt;br /&gt;
Initialized empty Git repository in /usr/src/rtnet-0.9.11/rtnet/.git/&lt;br /&gt;
&lt;br /&gt;
&amp;#039;b&amp;#039; option worked when I compiled the package.&lt;br /&gt;
&lt;br /&gt;
Need to run this script for building dependencies:&lt;br /&gt;
/usr/lib/pbuilder/pbuilder-satisfydepends&lt;br /&gt;
&lt;br /&gt;
Then run:&lt;br /&gt;
&lt;br /&gt;
git-buildpackage -us -uc -rfakeroot --git-debian-branch=master --git-upstream-branch=origin/master --git-ignore-new &lt;br /&gt;
&lt;br /&gt;
The following packages are created:&lt;br /&gt;
&lt;br /&gt;
rtnet_0.9.11-1.diff.gz	rtnet_0.9.11-1.dsc  rtnet_0.9.11-1_i386.build  rtnet_0.9.11-1_i386.changes  rtnet_0.9.11-1_i386.deb  rtnet_0.9.11.orig.tar.gz&lt;br /&gt;
&lt;br /&gt;
install debian package:&lt;br /&gt;
&lt;br /&gt;
dpkg -i rtnet_0.9.11-1_i386.deb&lt;br /&gt;
&lt;br /&gt;
edit /etc/rtnet.conf&lt;br /&gt;
&lt;br /&gt;
need to change:&lt;br /&gt;
&lt;br /&gt;
RT_DRIVER=&amp;quot;rt_e1000&amp;quot;           #driver for our intel chipset&lt;br /&gt;
RT_DRIVER_OPTIONS=&amp;quot;cards=0,1&amp;quot;  #This loads RT driver for eth1 &lt;br /&gt;
&lt;br /&gt;
IPADDR=&amp;quot;10.0.0.10&amp;quot;             &lt;br /&gt;
&lt;br /&gt;
# Simple setup: List of TDMA slaves&lt;br /&gt;
TDMA_SLAVES=&amp;quot;10.0.0.9&amp;quot;         # this is the VME address (could add mirkwood too as 10.0.0.8)&lt;br /&gt;
&lt;br /&gt;
To test RTNET do the following&lt;br /&gt;
&lt;br /&gt;
Shutdown network interface/s&lt;br /&gt;
&lt;br /&gt;
ifdown eth0&lt;br /&gt;
&lt;br /&gt;
remove standard network driver for ethernet cards:&lt;br /&gt;
modprobe -r e1000&lt;br /&gt;
&lt;br /&gt;
start rtnet:&lt;br /&gt;
&lt;br /&gt;
rtnet start&lt;br /&gt;
&lt;br /&gt;
add a route to the VME CPU&lt;br /&gt;
&lt;br /&gt;
rtroute add 10.0.0.9 00:01:af:17:a4:53 dev rteth0&lt;br /&gt;
&lt;br /&gt;
reinsert non-RT ethernet driver&lt;br /&gt;
&lt;br /&gt;
modprobe e1000&lt;br /&gt;
&lt;br /&gt;
Test connection:&lt;br /&gt;
&lt;br /&gt;
rtping 10.0.0.9&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
---+++ Analogy (comedi) &lt;br /&gt;
&lt;br /&gt;
Example programme:&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * @file&lt;br /&gt;
 * Analogy for Linux, output command test program&lt;br /&gt;
 *&lt;br /&gt;
 * @note Copyright (C) 1997-2000 David A. Schleef &amp;lt;ds@schleef.org&amp;gt;&lt;br /&gt;
 * @note Copyright (C) 2008 Alexis Berlemont &amp;lt;alexis.berlemont@free.fr&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * Xenomai is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU General Public License as published by&lt;br /&gt;
 * the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
 * (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * Xenomai is distributed in the hope that it will be useful, but&lt;br /&gt;
 * WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
 * General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU General Public License&lt;br /&gt;
 * along with Xenomai; if not, write to the Free Software Foundation,&lt;br /&gt;
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/mman.h&amp;gt;&lt;br /&gt;
#include &amp;lt;errno.h&amp;gt;&lt;br /&gt;
#include &amp;lt;getopt.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;native/task.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;analogy/analogy.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Default command&amp;#039;s parameters */&lt;br /&gt;
&lt;br /&gt;
/* For write operation, we consider &lt;br /&gt;
   the default subdevice index is 1 */&lt;br /&gt;
#define ID_SUBD 1&lt;br /&gt;
/* For simplicity sake, a maximum channel &lt;br /&gt;
   count is defined */&lt;br /&gt;
#define MAX_NB_CHAN 10&lt;br /&gt;
/* Four channels used by default */&lt;br /&gt;
#define NB_CHAN 4&lt;br /&gt;
/* One hundred triggered scans by default */&lt;br /&gt;
#define NB_SCAN 100&lt;br /&gt;
&lt;br /&gt;
#define FILENAME &amp;quot;analogy0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#define BUF_SIZE 10000&lt;br /&gt;
&lt;br /&gt;
static unsigned char buf[BUF_SIZE];&lt;br /&gt;
static char *filename = FILENAME;&lt;br /&gt;
static char *str_chans = &amp;quot;0,1&amp;quot;;&lt;br /&gt;
static unsigned int chans[MAX_NB_CHAN];&lt;br /&gt;
static int verbose = 0;&lt;br /&gt;
static int real_time = 0;&lt;br /&gt;
static int use_mmap = 0;&lt;br /&gt;
&lt;br /&gt;
static RT_TASK rt_task_desc;&lt;br /&gt;
&lt;br /&gt;
/* The command to send by default */&lt;br /&gt;
a4l_cmd_t cmd = {&lt;br /&gt;
  .idx_subd = ID_SUBD,&lt;br /&gt;
  .flags = 0,&lt;br /&gt;
  .start_src = TRIG_INT,&lt;br /&gt;
  .start_arg = 0,&lt;br /&gt;
  .scan_begin_src = TRIG_TIMER,&lt;br /&gt;
  .scan_begin_arg = 2000000, /* in ns */&lt;br /&gt;
  .convert_src = TRIG_NOW,&lt;br /&gt;
  .convert_arg = 0, /* in ns */&lt;br /&gt;
  .scan_end_src = TRIG_COUNT,&lt;br /&gt;
  .scan_end_arg = 0,&lt;br /&gt;
  .stop_src = TRIG_COUNT,&lt;br /&gt;
  .stop_arg = NB_SCAN,&lt;br /&gt;
  .nb_chan = 0,&lt;br /&gt;
  .chan_descs = chans,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
a4l_insn_t insn = {&lt;br /&gt;
  .type = A4L_INSN_INTTRIG,&lt;br /&gt;
  .idx_subd = ID_SUBD,&lt;br /&gt;
  .data_size = 0,&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
struct option cmd_write_opts[] = {&lt;br /&gt;
  {&amp;quot;verbose&amp;quot;, no_argument, NULL, &amp;#039;v&amp;#039;},&lt;br /&gt;
  {&amp;quot;real-time&amp;quot;, no_argument, NULL, &amp;#039;r&amp;#039;},&lt;br /&gt;
  {&amp;quot;device&amp;quot;, required_argument, NULL, &amp;#039;d&amp;#039;},&lt;br /&gt;
  {&amp;quot;subdevice&amp;quot;, required_argument, NULL, &amp;#039;s&amp;#039;},&lt;br /&gt;
  {&amp;quot;scan-count&amp;quot;, required_argument, NULL, &amp;#039;S&amp;#039;},&lt;br /&gt;
  {&amp;quot;channels&amp;quot;, required_argument, NULL, &amp;#039;c&amp;#039;},&lt;br /&gt;
  {&amp;quot;mmap&amp;quot;, no_argument, NULL, &amp;#039;m&amp;#039;},&lt;br /&gt;
  {&amp;quot;help&amp;quot;, no_argument, NULL, &amp;#039;h&amp;#039;},&lt;br /&gt;
  {0},&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void do_print_usage(void)&lt;br /&gt;
{&lt;br /&gt;
  fprintf(stdout, &amp;quot;usage:\tcmd_write [OPTS]\n&amp;quot;);&lt;br /&gt;
  fprintf(stdout, &amp;quot;\tOPTS:\t -v, --verbose: verbose output\n&amp;quot;);&lt;br /&gt;
  fprintf(stdout,&lt;br /&gt;
	  &amp;quot;\t\t -d, --device: &amp;quot;&lt;br /&gt;
	  &amp;quot;device filename (analogy0, analogy1, ...)\n&amp;quot;);&lt;br /&gt;
  fprintf(stdout, &amp;quot;\t\t -s, --subdevice: subdevice index\n&amp;quot;);&lt;br /&gt;
  fprintf(stdout, &amp;quot;\t\t -S, --scan-count: count of scan to perform\n&amp;quot;);&lt;br /&gt;
  fprintf(stdout, &amp;quot;\t\t -c, --channels: channels to use (ex.: -c 0,1)\n&amp;quot;);&lt;br /&gt;
  fprintf(stdout, &amp;quot;\t\t -m, --mmap: mmap the buffer\n&amp;quot;);&lt;br /&gt;
  fprintf(stdout, &amp;quot;\t\t -h, --help: print this help\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
  int ret = 0, len, ofs;&lt;br /&gt;
  unsigned int i, scan_size = 0, cnt = 0;&lt;br /&gt;
  unsigned long buf_size;&lt;br /&gt;
  void *map = NULL;&lt;br /&gt;
  a4l_desc_t dsc = { .sbdata = NULL };&lt;br /&gt;
&lt;br /&gt;
  /* Compute arguments */&lt;br /&gt;
  while ((ret = getopt_long(argc,&lt;br /&gt;
			    argv,&lt;br /&gt;
			    &amp;quot;vrd:s:S:c:mh&amp;quot;, cmd_write_opts, NULL)) &amp;gt;= 0) {&lt;br /&gt;
    switch (ret) {&lt;br /&gt;
    case &amp;#039;v&amp;#039;:&lt;br /&gt;
      verbose = 1;&lt;br /&gt;
      break;&lt;br /&gt;
    case &amp;#039;r&amp;#039;:&lt;br /&gt;
      real_time = 1;&lt;br /&gt;
      break;&lt;br /&gt;
    case &amp;#039;d&amp;#039;:&lt;br /&gt;
      filename = optarg;&lt;br /&gt;
      break;&lt;br /&gt;
    case &amp;#039;s&amp;#039;:&lt;br /&gt;
      cmd.idx_subd = insn.idx_subd = strtoul(optarg, NULL, 0);&lt;br /&gt;
      break;&lt;br /&gt;
    case &amp;#039;S&amp;#039;:&lt;br /&gt;
      cmd.stop_arg = strtoul(optarg, NULL, 0);&lt;br /&gt;
      break;&lt;br /&gt;
    case &amp;#039;c&amp;#039;:&lt;br /&gt;
      str_chans = optarg;&lt;br /&gt;
      break;&lt;br /&gt;
    case &amp;#039;m&amp;#039;:&lt;br /&gt;
      use_mmap = 1;&lt;br /&gt;
      break;&lt;br /&gt;
    case &amp;#039;h&amp;#039;:&lt;br /&gt;
    default:&lt;br /&gt;
      do_print_usage();&lt;br /&gt;
    return 0;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /* Recover the channels to compute */&lt;br /&gt;
  do {&lt;br /&gt;
    cmd.nb_chan++;&lt;br /&gt;
    len = strlen(str_chans);&lt;br /&gt;
    ofs = strcspn(str_chans, &amp;quot;,&amp;quot;);&lt;br /&gt;
    if (sscanf(str_chans, &amp;quot;%u&amp;quot;, &amp;amp;chans[cmd.nb_chan - 1]) == 0) {&lt;br /&gt;
      fprintf(stderr, &amp;quot;cmd_write: bad channels argument\n&amp;quot;);&lt;br /&gt;
      return -EINVAL;&lt;br /&gt;
    }&lt;br /&gt;
    str_chans += ofs + 1;&lt;br /&gt;
  } while (len != ofs);&lt;br /&gt;
&lt;br /&gt;
  /* Update the command structure */&lt;br /&gt;
  cmd.scan_end_arg = cmd.nb_chan;&lt;br /&gt;
&lt;br /&gt;
  if (real_time != 0) {&lt;br /&gt;
&lt;br /&gt;
    if (verbose != 0)&lt;br /&gt;
      printf(&amp;quot;cmd_write: switching to real-time mode\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* Prevent any memory-swapping for this program */&lt;br /&gt;
    ret = mlockall(MCL_CURRENT | MCL_FUTURE);&lt;br /&gt;
    if (ret &amp;lt; 0) {&lt;br /&gt;
      ret = errno;&lt;br /&gt;
      fprintf(stderr, &amp;quot;cmd_write: mlockall failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
	      ret);&lt;br /&gt;
      goto out_main;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /* Turn the current process into an RT task */&lt;br /&gt;
    ret = rt_task_shadow(&amp;amp;rt_task_desc, NULL, 1, 0);&lt;br /&gt;
    if (ret &amp;lt; 0) {&lt;br /&gt;
      fprintf(stderr,&lt;br /&gt;
	      &amp;quot;cmd_write: rt_task_shadow failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
	      ret);&lt;br /&gt;
      goto out_main;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /* Open the device */&lt;br /&gt;
  ret = a4l_open(&amp;amp;dsc, filename);&lt;br /&gt;
  if (ret &amp;lt; 0) {&lt;br /&gt;
    fprintf(stderr,&lt;br /&gt;
	    &amp;quot;cmd_write: a4l_open %s failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
	    FILENAME, ret);&lt;br /&gt;
    return ret;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  if (verbose != 0) {&lt;br /&gt;
    printf(&amp;quot;cmd_write: device %s opened (fd=%d)\n&amp;quot;,&lt;br /&gt;
	   filename, dsc.fd);&lt;br /&gt;
    printf(&amp;quot;cmd_write: basic descriptor retrieved\n&amp;quot;);&lt;br /&gt;
    printf(&amp;quot;\t subdevices count = %d\n&amp;quot;, dsc.nb_subd);&lt;br /&gt;
    printf(&amp;quot;\t read subdevice index = %d\n&amp;quot;, dsc.idx_read_subd);&lt;br /&gt;
    printf(&amp;quot;\t write subdevice index = %d\n&amp;quot;, dsc.idx_write_subd);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /* Allocate a buffer so as to get more info (subd, chan, rng) */&lt;br /&gt;
  dsc.sbdata = malloc(dsc.sbsize);&lt;br /&gt;
  if (dsc.sbdata == NULL) {&lt;br /&gt;
    fprintf(stderr, &amp;quot;cmd_write: malloc failed \n&amp;quot;);&lt;br /&gt;
    return -ENOMEM;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /* Get this data */&lt;br /&gt;
  ret = a4l_fill_desc(&amp;amp;dsc);&lt;br /&gt;
  if (ret &amp;lt; 0) {&lt;br /&gt;
    fprintf(stderr,&lt;br /&gt;
	    &amp;quot;cmd_write: a4l_get_desc failed (ret=%d)\n&amp;quot;, ret);&lt;br /&gt;
    goto out_main;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  if (verbose != 0)&lt;br /&gt;
    printf(&amp;quot;cmd_write: complex descriptor retrieved\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  /* Get the size of a single acquisition */&lt;br /&gt;
  for (i = 0; i &amp;lt; cmd.nb_chan; i++) {&lt;br /&gt;
    a4l_chinfo_t *info;&lt;br /&gt;
&lt;br /&gt;
    ret = a4l_get_chinfo(&amp;amp;dsc,&lt;br /&gt;
			 cmd.idx_subd, cmd.chan_descs[i], &amp;amp;info);&lt;br /&gt;
    if (ret &amp;lt; 0) {&lt;br /&gt;
      fprintf(stderr,&lt;br /&gt;
	      &amp;quot;cmd_write: a4l_get_chinfo failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
	      ret);&lt;br /&gt;
      goto out_main;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (verbose != 0) {&lt;br /&gt;
      printf(&amp;quot;cmd_write: channel %x\n&amp;quot;, cmd.chan_descs[i]);&lt;br /&gt;
      printf(&amp;quot;\t ranges count = %d\n&amp;quot;, info-&amp;gt;nb_rng);&lt;br /&gt;
      printf(&amp;quot;\t range&amp;#039;s size = %d (bits)\n&amp;quot;, info-&amp;gt;nb_bits);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    scan_size += (info-&amp;gt;nb_bits % 8 == 0) ? &lt;br /&gt;
      info-&amp;gt;nb_bits / 8 : (info-&amp;gt;nb_bits / 8) + 1;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  if (verbose != 0) {&lt;br /&gt;
    printf(&amp;quot;cmd_write: scan size = %u\n&amp;quot;, scan_size);&lt;br /&gt;
    printf(&amp;quot;cmd_write: size to write  = %u\n&amp;quot;,&lt;br /&gt;
	   scan_size * cmd.stop_arg);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /* Cancel any former command which might be in progress */&lt;br /&gt;
  a4l_snd_cancel(&amp;amp;dsc, cmd.idx_subd);&lt;br /&gt;
&lt;br /&gt;
  if (use_mmap != 0) {&lt;br /&gt;
&lt;br /&gt;
    /* Get the buffer size to map */&lt;br /&gt;
    ret = a4l_get_bufsize(&amp;amp;dsc, cmd.idx_subd, &amp;amp;buf_size);&lt;br /&gt;
    if (ret &amp;lt; 0) {&lt;br /&gt;
      fprintf(stderr,&lt;br /&gt;
	      &amp;quot;cmd_write: a4l_get_bufsize() failed &amp;quot;&lt;br /&gt;
	      &amp;quot;(ret=%d)\n&amp;quot;, ret);&lt;br /&gt;
      goto out_main;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (verbose != 0)&lt;br /&gt;
      printf(&amp;quot;cmd_write: buffer size = %lu bytes\n&amp;quot;,&lt;br /&gt;
	     buf_size);&lt;br /&gt;
&lt;br /&gt;
    /* Map the analog input subdevice buffer */&lt;br /&gt;
    ret = a4l_mmap(&amp;amp;dsc, cmd.idx_subd, buf_size, &amp;amp;map);&lt;br /&gt;
    if (ret &amp;lt; 0) {&lt;br /&gt;
      fprintf(stderr,&lt;br /&gt;
	      &amp;quot;cmd_write: a4l_mmap() failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
	      ret);&lt;br /&gt;
      goto out_main;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (verbose != 0)&lt;br /&gt;
      printf(&amp;quot;cmd_write: mmap performed successfully &amp;quot;&lt;br /&gt;
	     &amp;quot;(map=0x%p)\n&amp;quot;, map);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  /* Send the command to the output device */&lt;br /&gt;
  ret = a4l_snd_command(&amp;amp;dsc, &amp;amp;cmd);&lt;br /&gt;
  if (ret &amp;lt; 0) {&lt;br /&gt;
    fprintf(stderr,&lt;br /&gt;
	    &amp;quot;cmd_write: a4l_snd_command failed (ret=%d)\n&amp;quot;, ret);&lt;br /&gt;
    goto out_main;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  if (verbose != 0)&lt;br /&gt;
    printf(&amp;quot;cmd_write: command successfully sent\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  /* Set up the buffer to be written */&lt;br /&gt;
  for (i = 0; i &amp;lt; BUF_SIZE; i++)&lt;br /&gt;
    buf[i] = i;&lt;br /&gt;
&lt;br /&gt;
  if (use_mmap == 0) {&lt;br /&gt;
&lt;br /&gt;
    /* Send data */&lt;br /&gt;
    while (cnt &amp;lt; scan_size * cmd.stop_arg) {&lt;br /&gt;
      unsigned int tmp = &lt;br /&gt;
	(scan_size * cmd.stop_arg - cnt) &amp;gt; BUF_SIZE ? &lt;br /&gt;
	BUF_SIZE : (scan_size * cmd.stop_arg - cnt);&lt;br /&gt;
&lt;br /&gt;
      ret = a4l_async_write(&amp;amp;dsc, buf, tmp, A4L_INFINITE);&lt;br /&gt;
      if (ret &amp;lt; 0) {&lt;br /&gt;
	fprintf(stderr,&lt;br /&gt;
		&amp;quot;cmd_write: a4l_write failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
		ret);&lt;br /&gt;
	goto out_main;&lt;br /&gt;
      }&lt;br /&gt;
      cnt += ret;&lt;br /&gt;
&lt;br /&gt;
      if (cnt == ret &amp;amp;&amp;amp; cnt != 0) {&lt;br /&gt;
	ret = a4l_snd_insn(&amp;amp;dsc, &amp;amp;insn);&lt;br /&gt;
	if (ret &amp;lt; 0) {&lt;br /&gt;
	  fprintf(stderr,&lt;br /&gt;
		  &amp;quot;cmd_write: triggering failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
		  ret);&lt;br /&gt;
	  goto out_main;					&lt;br /&gt;
	}&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  } else {&lt;br /&gt;
    unsigned long front = 0;&lt;br /&gt;
&lt;br /&gt;
    /* Send data through the shared buffer */&lt;br /&gt;
    while (cnt &amp;lt; cmd.stop_arg * scan_size) {&lt;br /&gt;
&lt;br /&gt;
      /* If the buffer is full, wait for an event&lt;br /&gt;
	 (Note that a4l_poll() also retrieves the data amount&lt;br /&gt;
	 to read; in our case it is useless as we have to update&lt;br /&gt;
	 the data read counter) */&lt;br /&gt;
      if (front == 0) {&lt;br /&gt;
	ret = a4l_poll(&amp;amp;dsc, cmd.idx_subd, A4L_INFINITE);&lt;br /&gt;
	if (ret &amp;lt; 0) {&lt;br /&gt;
	  fprintf(stderr,&lt;br /&gt;
		  &amp;quot;cmd_write: a4l_mark_bufrw() failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
		  ret);&lt;br /&gt;
	  goto out_main;&lt;br /&gt;
	} else&lt;br /&gt;
	  front = (unsigned long)ret;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      /* Update the variable front according to the data amount&lt;br /&gt;
	 we still have to send */&lt;br /&gt;
      if (front &amp;gt; (scan_size * cmd.stop_arg - cnt))&lt;br /&gt;
	front = scan_size * cmd.stop_arg - cnt;&lt;br /&gt;
&lt;br /&gt;
      /* Perform the copy &lt;br /&gt;
	 (Usually, such an operation should be avoided: the shared&lt;br /&gt;
	 buffer should be used without any intermediate buffer,&lt;br /&gt;
	 the &amp;quot;mmaped&amp;quot; buffer is interesting for saving data copy) */&lt;br /&gt;
      memcpy(map + (cnt % buf_size),&lt;br /&gt;
	     buf + (cnt % BUF_SIZE), front);&lt;br /&gt;
&lt;br /&gt;
      /* Update the counter */&lt;br /&gt;
      cnt += front;&lt;br /&gt;
&lt;br /&gt;
      /* Retrieve and update the buffer&amp;#039;s state&lt;br /&gt;
	 (In output case, we recover how many bytes can be&lt;br /&gt;
	 written into the shared buffer) */&lt;br /&gt;
      ret = a4l_mark_bufrw(&amp;amp;dsc, cmd.idx_subd, front, &amp;amp;front);&lt;br /&gt;
      if (ret &amp;lt; 0) {&lt;br /&gt;
	fprintf(stderr,&lt;br /&gt;
		&amp;quot;cmd_write: a4l_mark_bufrw() failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
		ret);&lt;br /&gt;
	goto out_main;&lt;br /&gt;
      }&lt;br /&gt;
			&lt;br /&gt;
      if (cnt == front &amp;amp;&amp;amp; cnt != 0) {&lt;br /&gt;
	ret = a4l_snd_insn(&amp;amp;dsc, &amp;amp;insn);&lt;br /&gt;
	if (ret &amp;lt; 0) {&lt;br /&gt;
	  fprintf(stderr,&lt;br /&gt;
		  &amp;quot;cmd_write: triggering failed (ret=%d)\n&amp;quot;,&lt;br /&gt;
		  ret);&lt;br /&gt;
	  goto out_main;					&lt;br /&gt;
	}				&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  if (verbose != 0)&lt;br /&gt;
    printf(&amp;quot;cmd_write: %d bytes successfully written\n&amp;quot;, cnt);&lt;br /&gt;
&lt;br /&gt;
  ret = 0;&lt;br /&gt;
&lt;br /&gt;
 out_main:&lt;br /&gt;
&lt;br /&gt;
  /* Free the buffer used as device descriptor */&lt;br /&gt;
  if (dsc.sbdata != NULL)&lt;br /&gt;
    free(dsc.sbdata);&lt;br /&gt;
&lt;br /&gt;
  /* Release the file descriptor */&lt;br /&gt;
  a4l_close(&amp;amp;dsc);&lt;br /&gt;
&lt;br /&gt;
  return ret;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Makefile for programme:&lt;br /&gt;
&lt;br /&gt;
CC = $(shell /usr/bin/xeno-config --cc)&lt;br /&gt;
LXRT_CFLAGS = $(shell /usr/bin/xeno-config --skin=native --cflags)  &lt;br /&gt;
LXRT_LDFLAGS = $(shell /usr/bin/xeno-config --skin=native --ldflags)&lt;br /&gt;
EXTRA_LDFLAGS = -lanalogy -lrtdm&lt;br /&gt;
OBJ = cmd_write&lt;br /&gt;
SRC     :=  $(OBJ).c&lt;br /&gt;
&lt;br /&gt;
all: $(OBJ)&lt;br /&gt;
&lt;br /&gt;
$(OBJ): $(SRC)&lt;br /&gt;
	 $(CC) $(SRC) $(LXRT_CFLAGS) $(LXRT_LDFLAGS) $(EXTRA_LDFLAGS) -o $(OBJ) &lt;br /&gt;
&lt;br /&gt;
clean:&lt;br /&gt;
	rm -fr *.mod.c *.o *.ko $(OBJ) *~ .$(OBJ) .tmp_versions&lt;br /&gt;
&lt;br /&gt;
install:&lt;br /&gt;
	install -m 0755 $(OBJ) /usr/local/bin&lt;br /&gt;
&lt;br /&gt;
.PHONY: clean&lt;/div&gt;</summary>
		<author><name>Monnier</name></author>
	</entry>
</feed>