Main Page   Modules   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

txtBuffer.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------*/
00002 /*
00003 *    txtBuffer.h  
00004 *
00005 * This header file defines three character buffers used for error reporting, 
00006 * informational messages and diagnostic messages. The buffers may 
00007 * individually be set to be either linear or circular depending on the value 
00008 * of the "mode" data element.  They also can either overwrite if the message 
00009 * is longer than the buffer, or truncate the message, depending on 
00010 * the value of the "overwrite" data element.
00011 *
00012 * The buffers are contiguous in memory, with the start of the buffer block 
00013 * defined in a loader command file.
00014 *
00015 * Users add messages via the routines txtNewBufferEntry (for a new entry) and 
00016 * txtAddBufferEntry to append information to an existing entry.  The 
00017 * arguments to both calls are the same:
00018 *   void *buffer:     a pointer to the start of the buffer structure to hold 
00019 *                     the entry [INPUT and OUTPUT]
00020 *   char *file:       an ASCII string containing the name of the source file 
00021 *                     of the routine making the call (use  __FILE__ as 
00022 *                     defoned in the ANSI C standard).  [INPUT]
00023 *   INT32 line:         An integer giving the line number within the above file 
00024 *                     that the buffer routine was called from (use the C 
00025 *                     macro __LINE__) [INPUT]
00026 *   char *txtMessage: A character string containing arbitrary ASCII data.  
00027 *                     Usually this will be created by a sprintf call.  It may 
00028 *                     contain text messages, error  codes, and printouts 
00029 *                     of variable values.  [INPUT]
00030 *
00031 * After the buffer has been read, the user calls txtMarkBufferRead to set the 
00032 * pointers appropriately.
00033 *
00034 * Revision history:  
00035   18-Apr-2000: Changed names from dspXxxx to txtXxxxx.
00036   09-May-2000: First CVS release (1.0)
00037   15-Oct-2002: Added Buffer ID so that txtNewBufferEntry can set the appropriate
00038                status register flag, which serves as a signal for the main loop
00039                to call sendTxtBuffs.    dpsf.
00040 * Written by: Tom Meyer, Iowa State University, meyer@iastate.edu                          
00041 */
00042 /*-------------------------------------------------------------------------*/
00043 
00044 #ifndef TXTBUF   /* To avoid including it twice */   
00045 #define TXTBUF
00046 
00047 #define RINGBUFF 0
00048 #define LINBUFF  1
00049 #define NOOVERWRITE   0
00050 #define OVERWRITE     1 
00051 #define NOWRAPAROUND  0       /* Wrap-around means the data continues from */
00052 #define WRAPAROUND    1       /* the end of the buffer back to the start */
00053 #define TXT_BFR_NOOVERFLOW 0  /* Overflow means more data was written to the */
00054 #define TXT_BFR_OVERFLOW   1  /* buffer than it can hold. This is independen */
00055                               /* from the wrap-around condition. */
00056 #define BUFFER_EMPTY 0
00057 #define BUFFER_OCCUPIED 1
00058 
00059 /* 
00060 Some ASCII characters. Should these be defined elsewhere? 
00061 Are they used anywhere else? 
00062 */
00063 #define STX '\002'
00064 #define SPC '\040' 
00065 
00066 /* This is defined in the DAQ c++ software as RodTxtBuff.h; contains a
00067    text buffer class. Any changes made here must be consistent there. */
00068 struct TXTBUFFER{
00069   UINT32 dataEnd;            /* Last data byte */
00070   UINT32 readIndx;           /* Next location to read from */
00071   UINT32 writeIndx;          /* Next location to write to */
00072   INT32  mode;               /* LINEAR or RING */
00073   INT32  overwrite;
00074   INT32  overflow;           /* Did buffer overflow? */
00075   INT32  wrap;               /* Did buffer wrap around? */ 
00076   INT32  state;              /* Is there unread data? */
00077   UINT32 id;                 /* Buffer ID */
00078   char* data;                /* Pointer to data array */       
00079 }; 
00080 
00081 
00082 /* prototype for ping-pong buffers. All fields which are arrays
00083    refer to the 2 ping-pong text buffers */
00084 typedef struct TextBuffer {
00085     UINT32 dataEnd[2];      /* Last data byte */
00086     UINT32 readIndx[2];     /* Next location to read from  */
00087     UINT32 writeIndx[2];    /* Next location to write to */
00088     
00089     UINT8 overflow[2];      /* Did buffer overflow? */
00090     UINT8 state[2];         /* Is there unread data? */
00091 
00092     UINT8 ping;             /* index of current reading buffer */
00093     UINT8 pong;             /* index of current writing buffer */
00094     UINT8 id;               /* Buffer ID */
00095     UINT8 unused;
00096 
00097     char   *base[2];        /* Pointer to data array */       
00098 } TextBuffer; 
00099 
00100 
00101 INT32 txtNewBufferEntry(struct TXTBUFFER *buffer, char *file, 
00102                         INT32 line, char *txtMessage);
00103 INT32 txtAddBufferEntry(struct TXTBUFFER *buffer, char *file, 
00104                         INT32 line, char *txtMessage);
00105 INT32 txtMarkBufferRead(struct TXTBUFFER *buffer);
00106 
00107 #endif      /*TXTBUF*/

Generated on Mon Dec 15 19:36:22 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3