/usr/share/doc/libcomedi-dev/demo/choose_clock.c is in libcomedi-dev 0.8.1-5ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /*
* INSN_CONFIG_SET_CLOCK_SRC example
* Part of Comedilib
*
* Copyright (c) 1999,2000 David A. Schleef <ds@schleef.org>
* Copyright (c) 2007 Frank Mori Hess <fmhess@users.sourceforge.net>
*
* This file may be freely modified, distributed, and combined with
* other software, as long as proper attribution is given in the
* source code.
*/
/*
* Requirements: A board with a subdevice that supports
* INSN_CONFIG_CLOCK_SRC
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <comedilib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <ctype.h>
#include "examples.h"
comedi_t *device;
int main(int argc, char *argv[])
{
unsigned period_ns;
int retval;
lsampl_t clock_selection;
struct parsed_options options;
init_parsed_options(&options);
options.freq = 0.;
parse_options(&options, argc, argv);
device = comedi_open(options.filename);
if(!device){
comedi_perror(options.filename);
exit(-1);
}
if(options.freq > 0.)
period_ns = 1e9 / options.freq;
else
period_ns = 0;
clock_selection = options.value;
printf("Selecting master clock %d on subdevice %d.\n", clock_selection, options.subdevice);
if(period_ns)
{
printf("Clock period = %d nanoseconds.\n", period_ns);
}else
{
printf("Clock period unspecified.\n");
}
comedi_insn insn;
lsampl_t data[3];
memset(&insn, 0, sizeof(comedi_insn));
insn.insn = INSN_CONFIG;
insn.subdev = options.subdevice;
insn.data = data;
insn.n = sizeof(data) / sizeof(data[0]);
data[0] = INSN_CONFIG_SET_CLOCK_SRC;
data[1] = clock_selection;
data[2] = period_ns;
retval = comedi_do_insn(device, &insn);
if(retval < 0) comedi_perror("comedi_do_insn");
return retval;
}
|