Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

  1. /* Revision history: */
  2. /* $Id: vxi11_user.h,v 1.10 2007/10/30 12:47:33 sds Exp $ */
  3. /*
  4.  * $Log: vxi11_user.h,v $
  5.  * Revision 1.10  2007/10/30 12:47:33  sds
  6.  * changed a lot of char *'s to const char *'s in an attempt to get
  7.  *  rid of pedantic gcc compiler warnings.
  8.  *
  9.  * Revision 1.9  2007/07/11 14:20:56  sds
  10.  * removed #include <iostream> as not needed
  11.  * removed using namespace std
  12.  *
  13.  * Revision 1.8  2007/07/10 13:54:11  sds
  14.  * Added extra function:
  15.  * int     vxi11_open_device(char *ip, CLINK *clink, char *device);
  16.  * This replaces the original vxi11_open_device fn, which did not pass
  17.  * a char *device. Wrapper fn used for backwards compatibility.
  18.  *
  19.  * Revision 1.7  2007/07/10 11:20:43  sds
  20.  * removed the following function:
  21.  * int   vxi11_open_link(CLIENT **client, VXI11_LINK **link);
  22.  * ...since it was no longer needed, following the patch by
  23.  * Robert Larice.
  24.  *
  25.  * Revision 1.6  2006/12/08 11:47:14  ijc
  26.  * error on last ci, sorted.
  27.  *
  28.  * Revision 1.5  2006/12/08 11:45:29  ijc
  29.  * added #define VXI11_NULL_READ_RESP
  30.  *
  31.  * Revision 1.4  2006/12/07 12:26:17  sds
  32.  * added VXI11_NULL_READ_RESP #define
  33.  *
  34.  * Revision 1.3  2006/07/06 13:03:28  sds
  35.  * Surrounded the whole header with #ifndef __VXI11_USER__.
  36.  * Added a couple of vxi11_open_link() fns and a vxi11_close_link() fn, to
  37.  * separate the link stuff from the client stuff.
  38.  *
  39.  * Revision 1.2  2006/06/26 12:42:54  sds
  40.  * Introduced a new CLINK structure, to reduce the number of arguments
  41.  * passed to functions. Wrote wrappers for open(), close(), send()
  42.  * and receieve() functions, then adjusted all the other functions built
  43.  * on those to make use of the CLINK structure.
  44.  *
  45.  * Revision 1.1  2006/06/26 10:36:02  sds
  46.  * Initial revision
  47.  *
  48.  */
  49.  
  50. /* vxi11_user.h
  51.  * Copyright (C) 2006 Steve D. Sharples
  52.  *
  53.  * User library for opening, closing, sending to and receiving from
  54.  * a device enabled with the VXI11 RPC ethernet protocol. Uses the files
  55.  * generated by rpcgen vxi11.x.
  56.  *
  57.  * This program is free software; you can redistribute it and/or
  58.  * modify it under the terms of the GNU General Public License
  59.  * as published by the Free Software Foundation; either version 2
  60.  * of the License, or (at your option) any later version.
  61.  *
  62.  * This program is distributed in the hope that it will be useful,
  63.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  64.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  65.  * GNU General Public License for more details.
  66.  *
  67.  * You should have received a copy of the GNU General Public License
  68.  * along with this program; if not, write to the Free Software
  69.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  70.  *
  71.  * The author's email address is steve.sharples@nottingham.ac.uk
  72.  */
  73.  
  74. #ifndef __VXI11_USER__
  75. #define __VXI11_USER__
  76. #include <stdio.h>
  77. #include <stdlib.h>
  78. #include <string.h>
  79.  
  80. #include <rpc/rpc.h>
  81. #include "vxi11.h"
  82.  
  83. #define VXI11_DEFAULT_TIMEOUT   10000   /* in ms */
  84. #define VXI11_READ_TIMEOUT      2000    /* in ms */
  85. #define VXI11_CLIENT            CLIENT
  86. #define VXI11_LINK              Create_LinkResp
  87. #define VXI11_MAX_CLIENTS       256     /* maximum no of unique IP addresses/clients */
  88. #define VXI11_NULL_READ_RESP    50      /* vxi11_receive() return value if a query
  89.                                          * times out ON THE INSTRUMENT (and so we have
  90.                                          * to resend the query again) */
  91. #define VXI11_NULL_WRITE_RESP   51      /* vxi11_send() return value if a sent command
  92.                                          * times out ON THE INSTURMENT. */
  93.  
  94. struct  CLINK {
  95.         VXI11_CLIENT    *client;
  96.         VXI11_LINK      *link;
  97.         } ;
  98. typedef struct  CLINK CLINK;
  99.  
  100. /* The four main functions: open, close, send, receieve (plus a couple of wrappers) */
  101. /* In fact all 6 of these are wrappers to the original functions listed at the
  102.  * bottom, that use separate CLIENT and VXI11_LINK structures. It was easier to
  103.  * write wrappers for these functions than to re-write the original functions
  104.  * themselves. These are the 4 (or 6 if you like) key user functions that you
  105.  * should probably be using. They all use the CLINK structure. */
  106. int     vxi11_open_device(const char *ip, CLINK *clink);
  107. int     vxi11_open_device(const char *ip, CLINK *clink, char *device);
  108. int     vxi11_close_device(const char *ip, CLINK *clink);
  109. int     vxi11_send(CLINK *clink, const char *cmd);
  110. int     vxi11_send(CLINK *clink, const char *cmd, unsigned long len);
  111. long    vxi11_receive(CLINK *clink, char *buffer, unsigned long len);
  112. long    vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout);
  113. int vxi11_queryxx(CLINK         *clink, char *mycmd);
  114. /* Utility functions, that use send() and receive(). Use these too. */
  115. int     vxi11_send_data_block(CLINK *clink, const char *cmd, char *buffer, unsigned long len);
  116. long    vxi11_receive_data_block(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout);
  117. long    vxi11_send_and_receive(CLINK *clink, const char *cmd, char *buf, unsigned long buf_len, unsigned long timeout);
  118. long    vxi11_obtain_long_value(CLINK *clink, const char *cmd, unsigned long timeout);
  119. double  vxi11_obtain_double_value(CLINK *clink, const char *cmd, unsigned long timeout);
  120. long    vxi11_obtain_long_value(CLINK *clink, const char *cmd);
  121. double  vxi11_obtain_double_value(CLINK *link, const char *cmd);
  122.  
  123. /* When I first wrote this library I used separate client and links. I've
  124.  * retained the original functions and just written clink wrappers for them
  125.  * (see above) as it's perhaps a little clearer this way. Probably not worth
  126.  * delving this deep in use, but it's where the real nitty gritty is. */
  127. int     vxi11_open_device(const char *ip, CLIENT **client, VXI11_LINK **link, char *device);
  128. int     vxi11_open_link(const char *ip, CLIENT **client, VXI11_LINK **link, char *device);
  129. int     vxi11_close_device(const char *ip, CLIENT *client, VXI11_LINK *link);
  130. int     vxi11_close_link(const char *ip, CLIENT *client, VXI11_LINK *link);
  131. int     vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd);
  132. int     vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len);
  133. long    vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len);
  134. long    vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout);
  135.  
  136. #endif
  137.