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 println();                          
00059 
00060 extern void println(const char * str);          
00061 
00062 extern void println(const u8 * str, u32 len);   
00063 
00064 extern void println(int decimal);               
00065 
00066 extern void println(unsigned int decimal);      
00067 
00068 extern void println(long decimal);              
00069 
00070 extern void println(unsigned long decimal);     
00071 
00072 extern void println(long decimal, int code);    
00073 
00074 extern void println(double val);                
00075 
00076 extern void printlnCheckByte();                 
00077 
00078 
00079 extern void facePrint(u8 face, const char * str);
00080 extern void facePrint(u8 face, const u8 * str, u32 len);
00081 extern void facePrint(u8 face, int decimal); 
00082 extern void facePrint(u8 face, unsigned int decimal);
00083 extern void facePrint(u8 face, long decimal);
00084 extern void facePrint(u8 face, unsigned long decimal);
00085 //extern void facePrint(u8 face, long decimal, int code);
00086 extern void facePrint(u8 face, unsigned long decimal, int code);
00087 extern void facePrint(u8 face, unsigned long decimal, int code, bool printneg, int width, bool zerofill);
00088 extern void facePrint(u8 face, double val);
00089 extern void facePrint(u8 face, double val);
00090 extern void facePrintFace(u8 face);
00091 
00092 extern void facePrintln(u8 face); 
00093 extern void facePrintln(u8 face, const char * str);        
00094 
00095 extern void facePrintln(u8 face, const u8 * str, u32 len); 
00096 
00097 extern void facePrintln(u8 face, int decimal);             
00098 
00099 extern void facePrintln(u8 face, unsigned int decimal);    
00100 
00101 extern void facePrintln(u8 face, long decimal);            
00102 
00103 extern void facePrintln(u8 face, unsigned long decimal);   
00104 
00105 extern void facePrintln(u8 face, unsigned long decimal, int code);
00108 extern void facePrintln(u8 face, double val);              
00109 
00110 extern void facePrintlnCheckByte(u8 face);
00111 
00124 struct FacePrinter {
00125   void (*print)(u8 face, u8 byte);  
00126   void (*println)(u8 face);         
00127   void (*printFaceCode)(u8 face);   
00128 
00129   const char * (*getFaceName)(u8 face); 
00130 
00131 };
00132 
00133 extern bool faceHasPrinter(u8 face);     
00134 
00135 
00142 extern const FacePrinter * faceGetPrinter(u8 face);
00143 
00154 extern bool faceFindFreeFace(u8 & foundFace);
00155 
00170 extern void faceSetPrinter(u8 face, const FacePrinter * handler) ;
00171 
00180 extern void faceUnsetPrinter(u8 face) ;
00181 
00186 struct PacketPrinterHeader {
00187   FacePrinter fp;
00188   u8 maxLen;
00189   u8 usedLen;
00190   u8 sourceFace;                // WARNING! sourceFace must be the last field of the struct!
00191   // u8 packetBuffer[0]; /* Illegal ISO C++, but just so you know: Packet buffer starts here. */
00192 };
00193 
00201 #define PACKET_PRINTER_BUFFER_OVERHEAD_BYTES \
00202   (sizeof(PacketPrinterHeader)+sizeof(PacketHeader)+3+1) // (up to) 3 for alignment + 1 null terminator
00203 
00207 #define PACKET_PRINTER_PACKET_BUFFER_SIZE \
00208   (PACKET_PRINTER_BUFFER_OVERHEAD_BYTES+MAX_PACKET_LENGTH) // room for a full packet
00209 
00254 extern u8 * makePacketPrinter(u8 & assignedFace, u8 * buffer, u32 bufferLength, u8 sourceFace) ;
00255 
00256 /* The one-time serial startup code */
00257 extern void print_startup_initialization() ;
00258 
00259 #endif  /* SFBPRINT_H */
00260 

Generated on Sun Oct 18 09:58:55 2009 for SFB by doxygen 1.5.9