source: drsdaq/VME/struck/sis1100/V2.02/test/read_write_driver.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.1 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 <fcntl.h>
8#include <sys/mman.h>
9#include <sys/ioctl.h>
10
11#include "dev/pci/sis1100_var.h"
12
13int mod_base=0xe00000;
14int p;
15
16/****************************************************************************/
17static void printerror(struct sis1100_vme_req* req, int _errno, int write)
18{
19if (write)
20 printf("vme write 0x%08x to 0x%08x", req->data, req->addr);
21else
22 printf("vme read 0x%08x", req->addr);
23
24printf(": %s", strerror(_errno));
25if (_errno==EIO) printf("; protocoll error 0x%x", req->error);
26printf("\n");
27}
28/****************************************************************************/
29int main(int argc, char* argv[])
30{
31struct sis1100_vme_req req;
32
33if (argc<2)
34 {
35 fprintf(stderr, "usage: %s path\n", argv[0]);
36 return 1;
37 }
38if ((p=open(argv[1], O_RDWR, 0))<0) return 1;
39
40req.size=4;
41req.am=0x39;
42req.addr=mod_base+0x2020;
43if (ioctl(p, SIS3100_VME_READ, &req)<0) {
44 printf("SIS3100_VME_READ(2020): %s\n", strerror(errno));
45 return 1;
46}
47printf("*0x2020=0x%08x; error=0x%x\n", req.data, req.error);
48
49close(p);
50return 0;
51}
Note: See TracBrowser for help on using the repository browser.