SFBPrint.h

Go to the documentation of this file.
00001 /*                                              -*- mode:C++; fill-column:100 -*-
00002   SFBPrint.h - Generalized print formatting routines
00003   Copyright (C) 2009 The Regents of the University of New Mexico.  All rights reserved.
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this library; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
00018   USA
00019 
00020   $Id$
00021 */
00022 
00029 #ifndef SFBPRINT_H
00030 #define SFBPRINT_H
00031 
00032 #include "SFBConstants.h"       /* For FACE_COUNT */
00033 #include "SFBAlarm.h"           /* For SFBAlarmIndexType */ 
00034 #include "SFBReactor.h"         /* For PacketHandler, Body */ 
00035 #include "SFBFrame.h"
00036 
00037 /* The 'plain function' print methods dish to all reflex-controlled faces! */
00038 
00039 extern void print(const char * str);            
00040 
00041 extern void print(const u8 * str, u32 len);     
00042 
00043 extern void print(int decimal);                 
00044 
00045 extern void print(unsigned int decimal);        
00046 
00047 extern void print(long decimal);                
00048 
00049 extern void print(unsigned long decimal);       
00050 
00051 extern void print(long decimal, int code);      
00052 
00053 extern void print(double val);                  
00054 
00055 extern void printFace();                        
00056 
00057 
00058 extern void printPacket(u8 * packet);           
00059 
00060 
00061 extern void println();                          
00062 
00063 extern void println(const char * str);          
00064 
00065 extern void println(const u8 * str, u32 len);   
00066 
00067 extern void println(int decimal);               
00068 
00069 extern void println(unsigned int decimal);      
00070 
00071 extern void println(long decimal);              
00072 
00073 extern void println(unsigned long decimal);     
00074 
00075 extern void println(long decimal, int code);    
00076 
00077 extern void println(double val);                
00078 
00079 extern void printlnCheckByte();                 
00080 
00081 
00082 extern void facePrint(u8 face, const char * str);
00083 extern void facePrint(u8 face, const u8 * str, u32 len);
00084 extern void facePrint(u8 face, int decimal); 
00085 extern void facePrint(u8 face, unsigned int decimal);
00086 extern void facePrint(u8 face, long decimal);
00087 extern void facePrint(u8 face, unsigned long decimal);
00088 extern void facePrintBinary(u8 face, u64 value);
00089 //extern void facePrint(u8 face, long decimal, int code);
00090 extern void facePrint(u8 face, unsigned long decimal, int code);
00091 extern void facePrint(u8 face, unsigned long decimal, int code, bool printneg, int width, bool zerofill);
00092 extern void facePrint(u8 face, double val);
00093 extern void facePrint(u8 face, double val);
00094 extern void facePrintFace(u8 face);
00095 extern void facePrintPacket(u8 face, const u8 * packet);
00096 extern void facePrintPacketHeader(u8 face, u32 packetLen, u8 sourceFace = NORTH, u8 cursor = 0, u8 flags = 0);
00097 
00098 extern void facePrintln(u8 face); 
00099 extern void facePrintln(u8 face, const char * str);        
00100 
00101 extern void facePrintln(u8 face, const u8 * str, u32 len); 
00102 
00103 extern void facePrintln(u8 face, int decimal);             
00104 
00105 extern void facePrintln(u8 face, unsigned int decimal);    
00106 
00107 extern void facePrintln(u8 face, long decimal);            
00108 
00109 extern void facePrintln(u8 face, unsigned long decimal);   
00110 
00111 extern void facePrintln(u8 face, unsigned long decimal, int code);
00114 extern void facePrintln(u8 face, double val);              
00115 
00116 extern void facePrintlnCheckByte(u8 face);
00117 
00130 struct FacePrinter {
00131   void (*print)(u8 face, u8 byte);  
00132   void (*println)(u8 face);         
00133   void (*printFaceCode)(u8 face);   
00134 
00135   const char * (*getFaceName)(u8 face); 
00136 
00137 };
00138 
00139 extern bool faceHasPrinter(u8 face);     
00140 
00141 
00148 extern const FacePrinter * faceGetPrinter(u8 face);
00149 
00160 extern bool faceFindFreeFace(u8 & foundFace);
00161 
00176 extern void faceSetPrinter(u8 face, const FacePrinter * handler) ;
00177 
00186 extern void faceUnsetPrinter(u8 face) ;
00187 
00192 struct PacketPrinterHeader {
00193   FacePrinter fp;               // A FacePrinter instance must be first (to allow bogus casting)
00194   u8 maxLen;
00195   u8 usedLen;
00196   u8 sourceFace;                // WARNING! sourceFace must be the last field of the struct!
00197   // u8 packetBuffer[0]; /* Illegal ISO C++, but just so you know: Packet buffer starts here. */
00198 };
00199 
00209 extern void packetPrinterStoreDataByte(PacketPrinterHeader *pph, u8 byte) ;
00210 
00220 extern void packetPrinterTerminatePacket(PacketPrinterHeader *pph) ;
00221 
00228 extern u8 * packetPrinterPrintedPacket(PacketPrinterHeader *pph) ;
00229 
00237 #define PACKET_PRINTER_BUFFER_OVERHEAD_BYTES \
00238   (sizeof(PacketPrinterHeader)+sizeof(PacketHeader)+3+1) // (up to) 3 for alignment + 1 null terminator
00239 
00243 #define PACKET_PRINTER_PACKET_BUFFER_SIZE \
00244   (PACKET_PRINTER_BUFFER_OVERHEAD_BYTES+MAX_PACKET_LENGTH) // room for a full packet
00245 
00290 extern u8 * makePacketPrinter(u8 & assignedFace, u8 * buffer, u32 bufferLength, u8 sourceFace) ;
00291 
00292 extern PacketPrinterHeader * initializePacketPrinterBuffer(const FacePrinter * fp, u8 onFace, u8 * buffer, u32 bufferLength, u8 sourceFace) ;
00293 
00294 /* The one-time serial startup code */
00295 extern void print_startup_initialization() ;
00296 
00297 #endif  /* SFBPRINT_H */
00298 

Generated on Fri Apr 22 06:54:12 2011 for SFB by doxygen 1.5.9