Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 145 | f9daq | 1 | /* vxi11_user.h | 
        
| 2 |  * Copyright (C) 2006 Steve D. Sharples | 
        ||
| 3 |  * | 
        ||
| 4 |  * User library for opening, closing, sending to and receiving from | 
        ||
| 5 |  * a device enabled with the VXI11 RPC ethernet protocol. Uses the files | 
        ||
| 6 |  * generated by rpcgen vxi11.x. | 
        ||
| 7 |  * | 
        ||
| 8 |  * This program is free software; you can redistribute it and/or | 
        ||
| 9 |  * modify it under the terms of the GNU General Public License | 
        ||
| 10 |  * as published by the Free Software Foundation; either version 2 | 
        ||
| 11 |  * of the License, or (at your option) any later version. | 
        ||
| 12 |  * | 
        ||
| 13 |  * This program is distributed in the hope that it will be useful, | 
        ||
| 14 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
        ||
| 15 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
        ||
| 16 |  * GNU General Public License for more details. | 
        ||
| 17 |  * | 
        ||
| 18 |  * You should have received a copy of the GNU General Public License | 
        ||
| 19 |  * along with this program; if not, write to the Free Software | 
        ||
| 20 |  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
        ||
| 21 |  * | 
        ||
| 22 |  * The author's email address is steve.sharples@nottingham.ac.uk | 
        ||
| 23 |  */ | 
        ||
| 24 | |||
| 25 | #ifndef __VXI11_USER__ | 
        ||
| 26 | #define __VXI11_USER__ | 
        ||
| 27 | #include <stdio.h> | 
        ||
| 28 | #include <stdlib.h> | 
        ||
| 29 | #include <string.h> | 
        ||
| 30 | |||
| 31 | #include <rpc/rpc.h> | 
        ||
| 32 | #include "vxi11.h" | 
        ||
| 33 | |||
| 34 | #define VXI11_DEFAULT_TIMEOUT   10000   /* in ms */ | 
        ||
| 35 | #define VXI11_READ_TIMEOUT      2000    /* in ms */ | 
        ||
| 36 | #define VXI11_CLIENT            CLIENT | 
        ||
| 37 | #define VXI11_LINK              Create_LinkResp | 
        ||
| 38 | #define VXI11_MAX_CLIENTS       256     /* maximum no of unique IP addresses/clients */ | 
        ||
| 39 | #define VXI11_NULL_READ_RESP    50      /* vxi11_receive() return value if a query | 
        ||
| 40 | * times out ON THE INSTRUMENT (and so we have  | 
        ||
| 41 | * to resend the query again) */  | 
        ||
| 42 | #define VXI11_NULL_WRITE_RESP   51      /* vxi11_send() return value if a sent command | 
        ||
| 43 | * times out ON THE INSTURMENT. */  | 
        ||
| 44 | |||
| 45 | struct CLINK {  | 
        ||
| 46 | VXI11_CLIENT *client;  | 
        ||
| 47 | VXI11_LINK *link;  | 
        ||
| 48 | } ;  | 
        ||
| 49 | typedef struct CLINK CLINK;  | 
        ||
| 50 | |||
| 51 | /* The four main functions: open, close, send, receieve (plus a couple of wrappers) */ | 
        ||
| 52 | /* In fact all 6 of these are wrappers to the original functions listed at the | 
        ||
| 53 |  * bottom, that use separate CLIENT and VXI11_LINK structures. It was easier to | 
        ||
| 54 |  * write wrappers for these functions than to re-write the original functions | 
        ||
| 55 |  * themselves. These are the 4 (or 6 if you like) key user functions that you | 
        ||
| 56 |  * should probably be using. They all use the CLINK structure. */ | 
        ||
| 57 | int vxi11_open_device(const char *ip, CLINK *clink);  | 
        ||
| 58 | int vxi11_open_device(const char *ip, CLINK *clink, char *device);  | 
        ||
| 59 | int vxi11_close_device(const char *ip, CLINK *clink);  | 
        ||
| 60 | int vxi11_send(CLINK *clink, const char *cmd);  | 
        ||
| 61 | int vxi11_send(CLINK *clink, const char *cmd, unsigned long len);  | 
        ||
| 62 | long vxi11_receive(CLINK *clink, char *buffer, unsigned long len);  | 
        ||
| 63 | long vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout);  | 
        ||
| 64 | |||
| 65 | /* Utility functions, that use send() and receive(). Use these too. */ | 
        ||
| 66 | int vxi11_send_data_block(CLINK *clink, const char *cmd, char *buffer, unsigned long len);  | 
        ||
| 67 | long vxi11_receive_data_block(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout);  | 
        ||
| 68 | long vxi11_send_and_receive(CLINK *clink, const char *cmd, char *buf, unsigned long buf_len, unsigned long timeout);  | 
        ||
| 69 | long vxi11_obtain_long_value(CLINK *clink, const char *cmd, unsigned long timeout);  | 
        ||
| 70 | double vxi11_obtain_double_value(CLINK *clink, const char *cmd, unsigned long timeout);  | 
        ||
| 71 | long vxi11_obtain_long_value(CLINK *clink, const char *cmd);  | 
        ||
| 72 | double vxi11_obtain_double_value(CLINK *link, const char *cmd);  | 
        ||
| 73 | |||
| 74 | /* When I first wrote this library I used separate client and links. I've | 
        ||
| 75 |  * retained the original functions and just written clink wrappers for them | 
        ||
| 76 |  * (see above) as it's perhaps a little clearer this way. Probably not worth | 
        ||
| 77 |  * delving this deep in use, but it's where the real nitty gritty is. */ | 
        ||
| 78 | int vxi11_open_device(const char *ip, CLIENT **client, VXI11_LINK **link, char *device);  | 
        ||
| 79 | int vxi11_open_link(const char *ip, CLIENT **client, VXI11_LINK **link, char *device);  | 
        ||
| 80 | int vxi11_close_device(const char *ip, CLIENT *client, VXI11_LINK *link);  | 
        ||
| 81 | int vxi11_close_link(const char *ip, CLIENT *client, VXI11_LINK *link);  | 
        ||
| 82 | int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd);  | 
        ||
| 83 | int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len);  | 
        ||
| 84 | long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len);  | 
        ||
| 85 | long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout);  | 
        ||
| 86 | |||
| 87 | #endif |