source: drsdaq/VME/struck/sis1100/V2.02/examples/camac_simple_routines/camac_naf.c~@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#define _GNU_SOURCE
2#include <stdio.h>
3#include <errno.h>
4#include <string.h>
5#include <sys/types.h>
6#include <unistd.h>
7#include <stdlib.h>
8#include <fcntl.h>
9#include <sys/ioctl.h>
10
11
12#include "dev/pci/sis1100_var.h"
13#include "sis5100_camac_calls.h"
14
15
16/****************************************************************************/
17int main(int argc, char* argv[])
18{
19
20int p;
21u_int16_t A,N,F;
22int Q=0,X=0;
23u_int32_t datum ;
24int res;
25
26if (argc<6) {
27 fprintf(stderr, "usage: %s path N A F datum\n", argv[0]);
28 return 1;
29}
30
31if ((p=open(argv[1], O_RDWR, 0))<0) {
32 perror("open");
33 return 1;
34}
35
36N = strtoul(argv[2],NULL,0) ;
37A = strtoul(argv[3],NULL,0) ;
38F = strtoul(argv[4],NULL,0) ;
39datum = strtoul(argv[5],NULL,0) ;
40
41printf("Station: %d Address: %d Function: %d\n",N,A,F);
42
43
44if (F>15) {
45 res=camac_naf_write(p,N,A,F,datum);
46 Q=(~res&0x80)>>7;
47 X=(~res&0x40)>>6;
48}
49else {
50 res=camac_naf_read(p,N,A,F,&datum);
51 Q=(datum&0x80000000)>31;
52 X=(datum&0x40000000)>30;
53 datum=datum&0xFFFFFF;
54}
55
56if (res&~0x2c0) {
57 printf("camac NAF: error=0x%x\n", res);
58 return -1;
59}
60
61printf("NAF: datum = 0x%04x\n", (int) datum );
62printf("Q: %d X: %d\n",Q,X);
63close(p);
64return 0;
65}
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Note: See TracBrowser for help on using the repository browser.