/*---------------------------------------------------------------------------------------*/ /* dspBuffer.h */ /* Version 1.7 */ /* This header file defines three character buffers used for error reporting, informational messages and diagnostic messages. The buffers may individually be set to be either linear or circular depending on the value of the "mode" data element. They also can either overwrite if the message is longer than the buffer, or truncate the message, depending on the value of the "overwrite" data element. The buffers are contiguous in memory, with the start of the buffer block defined in a header file named xxxMemoryMap, where xxx may be mas, slv0, slv1, slv2, or slv3, for the master DSP and the (up to) four slave DSPs. Users add messages via the routines dspNewBufferEntry (for a new entry) and dspAddBufferEntry to append information to an existing entry. The arguments to both calls are the same: void *buffer: a pointer to the start of the buffer structure to hold the entry char *file: an ASCII string containing the name of the source file of the routine making the call (use the C macro __FILE__) int line: An integer giving the line number within the above file that the buffer routine was called from (use the C macro __LINE__) char *dspMessage: A character string containing arbitrary ASCII data. Usually this will be created by a sprintf call. It may contain text information, error codes, or printouts of variable values. After the buffer has been read, the user calls dspMarkBufferRead to set the pointers appropriately. Written by: Tom Meyer, Iowa State University, meyer@iastate.edu */ /*---------------------------------------------------------------------------------------*/ #ifdef DSPBUFFER /* If already included, make fcns external */ extern int dspNewBufferEntry(struct asciiBuffer *buffer, char* file, int line, char* dspMessage); extern int dspAddBufferEntry(struct asciiBuffer *buffer, char* file, int line, char* dspMessage); extern int dspMarkBufferRead(struct asciiBuffer *buffer); #endif #ifndef DSPBUFFER /* To avoid including it twice */ #define DSPBUFFER #ifdef NOT_DEFINED #define ERR_BUFFER_SIZE 0x8000 /* 32 KB */ #endif #define ERR_BUFFER_SIZE 0x0050 /* 80 Bytes */ #ifdef NOT_DEFINED #define INFO_BUFFER_SIZE 0x8000 /* 32 KB */ #endif #define INFO_BUFFER_SIZE 0x0050 /* 80 Bytes */ #ifdef NOT_DEFINED #define DIAG_BUFFER_SIZE 0x8000 /* 32 KB */ #endif #define DIAG_BUFFER_SIZE 0x0050 /* 80 Bytes */ #define RINGBUFF 0 #define LINBUFF 1 #define NOOVERWRITE 0 #define OVERWRITE 1 #define BUFFER_OVERFLOW_FALSE 0 #define BUFFER_OVERFLOW_TRUE 1 /* Some ASCII characters. Should these be defined elsewhere? Are they used anywhere else? */ #define STX '\002' #define SPC '\000' static char errData[ERR_BUFFER_SIZE]; static char infoData[INFO_BUFFER_SIZE]; static char diagData[DIAG_BUFFER_SIZE]; struct asciiBuffer{ unsigned int dataStart; /* First data byte */ unsigned int dataEnd; /* Last data byte */ unsigned int readPtr; /* Next location to read from */ unsigned int writePtr; /* Next location to write to */ int mode; /* LINEAR or RING */ int overwrite; int overflow; char* data; /* Pointer to data array */ }; static struct asciiBuffer errBuffer={0, /* dataStart */ ERR_BUFFER_SIZE -1, /* dataEnd */ 0, /* writePtr */ 0, /* readPtr */ LINBUFF, /* mode */ NOOVERWRITE, /* overwrite */ BUFFER_OVERFLOW_FALSE, /* overflow */ errData}; /* *data */ static struct asciiBuffer infoBuffer={0, /* dataStart */ INFO_BUFFER_SIZE -1, /* dataEnd */ 0, /* writePtr */ 0, /* readPtr */ LINBUFF, /* mode */ NOOVERWRITE, /* overwrite */ BUFFER_OVERFLOW_FALSE, /* overflow */ infoData}; /* *data */ static struct asciiBuffer diagBuffer={0, /* dataStart */ INFO_BUFFER_SIZE -1, /* dataEnd */ 0, /* writePtr */ 0, /* readPtr */ RINGBUFF, /* mode */ OVERWRITE, /* overwrite */ BUFFER_OVERFLOW_FALSE, /* overflow */ diagData}; /* *data */ int dspNewBufferEntry(struct asciiBuffer *buffer, char* file, int line, char* dspMessage); int dspAddBufferEntry(struct asciiBuffer *buffer, char* file, int line, char* dspMessage); int dspMarkBufferRead(struct asciiBuffer *buffer); #endif /*DSPBUFFER*/