source: drsdaq/VME/struck/sis1100/V2.02/test/glinktest_local_rw.c@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 1.3 KB
Line 
1#define _GNU_SOURCE
2#include <stdio.h>
3#include <errno.h>
4#include <sys/types.h>
5#include <unistd.h>
6#include <stdlib.h>
7#include <string.h>
8#include <fcntl.h>
9#include <sys/mman.h>
10#include <sys/ioctl.h>
11
12#include "dev/pci/sis1100_var.h"
13
14int main(int argc, char* argv[])
15{
16 int p;
17 struct sis1100_ident ident;
18
19 if (argc!=2)
20 {
21 fprintf(stderr, "usage: %s path\n", argv[0]);
22 return 1;
23 }
24
25 if ((p=open(argv[1], O_RDWR, 0))<0) {
26 fprintf(stderr, "open \"%s\": %s\n", argv[1], strerror(errno));
27 return 1;
28 }
29
30 if (ioctl(p, SIS1100_IDENT, &ident)<0) {
31 fprintf(stderr, "ioctl(SIS1100_IDENT): %s\n", strerror(errno));
32 return 2;
33 }
34
35 if ((ident.local.hw_type!=1)||(ident.local.hw_version!=1)||
36 (ident.local.fw_type!=1)) {
37 fprintf(stderr, "unsupported bord version:\n");
38 fprintf(stderr, " hw_type : %d\n", ident.local.hw_type);
39 fprintf(stderr, " hw_version: %d\n", ident.local.hw_version);
40 fprintf(stderr, " fw_type : %d\n", ident.local.fw_type);
41 fprintf(stderr, " fw_version: %d\n\n", ident.local.fw_version);
42 return 2;
43 }
44
45
46
47
48 if (close(p)<0) {
49 fprintf(stderr, "close: %s\n", strerror(errno));
50 return 2;
51 }
52 return 0;
53}
Note: See TracBrowser for help on using the repository browser.