Friday, April 22, 2011

Compiling comedi sample programs

First thing you will have to do is install the "comedi" library. Under Ubuntu the package name is "libcomedi0" and "libcomedi-dev". Both packages are available in the Ubuntu "universe" repository.

Once you have the comedi library installed, the command to compile comedi programs using gcc/linux is

$gcc -Wall -O2 <program_name>.c -lcomedi -lm

Sample program :

#include <stdio.h>   /* for printf() */
#include <comedilib.h>
int subdev = 0;         /* change this to your input subdevice */
int chan = 0;           /* change this to your channel */
int range = 0;          /* more on this later */
int aref = AREF_GROUND; /* more on this later */

int main(int argc,char *argv[])
{
  comedi_t *it;
  lsampl_t data;
  it=comedi_open("/dev/comedi0");
  comedi_data_read(it,subdev,chan,range,aref, & data);
  printf("%d\n",data);
  return 0;
}

Monday, April 11, 2011

Develop against linux-next

First thing is to download the git tree for linux-next

$git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

To follow changes to the linux-tree tree you need to first do a remote update (this will get all the changes from the remote linux-next branch to the local origin/master tracking branch) and then reset the HEAD pointer of current checked out branch to the HEAD of linux-next remote tracking branch (i.e origin/master).

$git remote update
$git reset --hard origin/master

This will make your current branch (master) *exactly* like the remote linux-next tree. You cannot do pull or merge from the remote tracking branch.

Links :
http://lwn.net/Articles/289245/
http://linux.f-seidel.de/linux-next/pmwiki/pmwiki.php?n=Linux-next.Announcement
http://www.gossamer-threads.com/lists/linux/kernel/1363433?page=last