📄 do_1753.c
字号:
//*************************************************************************
//
// Copyright (c) 2001 IAG Software Team,
//
// Beijing R&D Center
//
// Advantech Co., Ltd.
//
// User program for Linux comedi device driver
//
// This is An Unpublished Work Containing Confidential And Proprietary
// Information Which Is The Property Of Advantech Automation Corp.
//
// Any Disclosure, Use, Or Reproduction, Without Written Authorization From
// Advantech Automation Corp., Is Strictly Prohibit.
//
//
//*************************************************************************
// Program : do_1753.c
// Revision: 1.0
// Author : Luosheng Li
// Date : 10/20/01
//
// Description: Perform digital output testing of 1753
//-------------------------------------------------------------------------
#include <stdio.h> //standard input output library
#include <stdlib.h>
#include <comedilib.h> //comedilib library
#include <fcntl.h> //file control library
#include <unistd.h> //standard symbolic constants and types library
#include <errno.h> //error codes report library
#include <getopt.h> //argument analyse function library
#include <ctype.h> //c languge type library
char *filename="/dev/comedi0"; //comedi device file name
comedi_t *device; //comedi device
int subdevice = 3; //subdevice number,3 = digital output subdevice
int main(int argc, char *argv[])
{
int stype; //subdevice type number
lsampl_t data ;
device=comedi_open(filename); //open comedi device
if(!device){
comedi_perror(filename);
exit(0);
}
data = 0;
stype = comedi_get_subdevice_type(device,subdevice); //get subdevice number
if(stype!=COMEDI_SUBD_DO){
printf("%d is not a digital I/O subdevice\n",subdevice);
exit(0);
}
printf("\nSubdevice %d channels %d\n",subdevice, comedi_get_n_channels(device,subdevice));
comedi_data_write(device,3,0,0,0,0);//
comedi_data_write(device,3,16,0,0,0x8b);//write the pattern match value
comedi_data_write(device,3,20,0,0,1);//write the pattern match value
usleep(10000);
comedi_data_write(device,3,24,0,0,1);//write the pattern match enable value
usleep(10000);
usleep(1000000);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -