Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

rtlnml.h

Go to the documentation of this file.
00001 /******************************************************************
00002  * File: rtlnml.h
00003  *
00004  * Introduction:
00005  * This file creates an interface to NML that can be used by both
00006  * real-time and non-realtime C  linux applications. It will be also used
00007  * by the C++ wrapper that makes these messages available to any NML
00008  * application.
00009  *
00010  * Modifications:
00011 31-May-2001 WPS modified to work with rtai as well.
00012  16-Mar-2000 WPS created.
00013 ********************************************************************/
00014 
00015 #ifndef RTLNML_H
00016 #define RTLNML_H
00017 
00018 #ifdef __cplusplus
00019 extern "C"
00020 {
00021 #endif
00022 
00023 #ifndef RTLNML_TYPEDEFED
00024   typedef void *rtlnml_t;       /* This will be redefined in rtlnml.c but is opaque to
00025                                    the rest of the world. */
00026   typedef rtlnml_t rtainml_t;
00027 #endif
00028 
00029   /* All applications should call this before any other rtlnml functions. */
00030   /* In rtlinux, call this only from init_module, never from an RT task
00031      function. */
00032   extern void rtlnml_init (void);
00033 
00034 #if !defined(rtai) && !defined(HAVE_RTAI)
00035   /* This fuction is used to create each channel. */
00036   /* In rtlinux, call this only from init_module, never from an RT task
00037      function. */
00038   extern rtlnml_t rtlnml_open (const char *name,        /* buffer name */
00039                                const char *processname, /* process name (not used) */
00040                                const char *filename,    /* configuration file (not used) */
00041                                unsigned long size,      /* Maximum size of message for buffer, (actual buffer is slightly larger). */
00042                                int master);
00043 #else
00044   /* This fuction is used to create each channel. */
00045   /* In rtai, call this only from init_module, never from an RT task
00046      function. 
00047      This function is identical to rtlnml_open() except that a
00048      integer key has been added.  The name is not used as a key.
00049    */
00050   extern rtainml_t rtainml_open (const char *name,      /* buffer name */
00051                                  const char *processname,       /* process name (not used) */
00052                                  const char *filename,  /* configuration file (not used) */
00053                                  unsigned long size,    /* Maximum size of message for buffer, (actual buffer is slightly larger). */
00054                                  int master, int key);
00055 #endif
00056 
00057 
00058   /* These functions get and release
00059      a direct pointer to the shared memory area.
00060      If a read occurs while the
00061      writer has direct access to the shared memory a split-buffer error will
00062      occur then either  rtlnml_get_direct_pointer_for_read,
00063      rtlnml_release_direct_pointer_for_read or rtlnml_read will return
00064      RTLNML_SPLIT_READ
00065      So the pointer should be released as soon as possible.
00066      Returns:
00067      See  RTLNML_SPECIAL_READ_RETURN_VALUES.
00068    */
00069   extern int rtlnml_get_direct_pointer_for_read (rtlnml_t, void **);
00070   extern int rtlnml_release_direct_pointer_for_read (rtlnml_t, void **);
00071 
00072   extern int rtlnml_get_direct_pointer_for_write (rtlnml_t, void **);
00073   extern int rtlnml_release_direct_pointer_for_write (rtlnml_t, void **,
00074                                                       long msg_type,
00075                                                       unsigned long msg_size);
00076 
00077   /* Reads from the buffer, possibly copying the contents to the location
00078      that can be obtained with rtlnml_get_local_pointer. This is
00079      safer and more flexible than using direct pointers but possibly
00080      slower.
00081      Returns:
00082      >0  -- NML message type of new NML message succesfully retrieved.
00083      otherwise -- See  RTLNML_SPECIAL_READ_RETURN_VALUES.
00084    */
00085   extern long rtlnml_read (rtlnml_t);
00086 
00087 
00088   /* Writes to the buffer, copying the contents from  the location given.
00089      This is safer and more flexible than using direct pointers but possibly
00090      slower.
00091      Return:
00092      See RTLNML_SPECIAL_WRITE_RETURN_VALUES.
00093    */
00094   extern long rtlnml_write (rtlnml_t, void *data,       /* address of data to be copied into nml buffer. */
00095                             long msg_type,      /* NML message type. */
00096                             unsigned long);     /* size of message */
00097 
00098   /* This function should be called after a successful rtlnml_read to
00099      get a pointer to a local copy of the message. */
00100   extern void *rtlnml_get_local_pointer (rtlnml_t);
00101 
00102   /* Use only if you want rtlnml_read to copy data to a special location.
00103      In rtlinux, this should only be done from within init_module never,
00104      never from within a RT task function.
00105    */
00106   extern void rtlnml_set_local_pointer (rtlnml_t, void *);
00107 
00108   /* Close each channel. */
00109   extern void rtlnml_close (rtlnml_t, const char *bufname);
00110 
00111   /* This function should be called after all other rtlnml functions. */
00112   /* In rtlinux call this only from cleanup_module, never from an RT task function. */
00113   extern void rtlnml_exit (void);
00114 
00115   enum RTLNML_SPECIAL_READ_RETURN_VALUES
00116   {
00117     RTLNML_READ_OLD = 0,
00118     RTLNML_READ_ERROR = -1,
00119     RTLNML_SPLIT_READ_ERROR = -2
00120   };
00121 
00122   enum RTLNML_SPECIAL_WRITE_RETURN_VALUES
00123   {
00124     RTLNML_WRITE_ERROR = -1,
00125     RTLNML_WRITE_OK = 0
00126   };
00127 
00128 
00129 #ifdef __cplusplus
00130 }
00131 #endif
00132 
00133 
00134 #endif

Generated on Sun Dec 2 15:56:52 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001