# 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 facePrint(u8 face, long decimal, int code);
    00089 extern void facePrint(u8 face, unsigned long decimal, int code);
    00090 extern void facePrint(u8 face, unsigned long decimal, int code, bool printneg, int width, bool zerofill);
    00091 extern void facePrint(u8 face, double val);
    00092 extern void facePrint(u8 face, double val);
    00093 extern void facePrintFace(u8 face);
    00094 extern void facePrintPacket(u8 face, const u8 * packet);
    00095
    00096 extern void facePrintln(u8 face);
    00097 extern void facePrintln(u8 face, const char * str);
    00098
    00099 extern void facePrintln(u8 face, const u8 * str, u32 len);
    00100
    00101 extern void facePrintln(u8 face, int decimal);
    00102
    00103 extern void facePrintln(u8 face, unsigned int decimal);
    00104
    00105 extern void facePrintln(u8 face, long decimal);
    00106
    00107 extern void facePrintln(u8 face, unsigned long decimal);
    00108
    00109 extern void facePrintln(u8 face, unsigned long decimal, int code);
    00112 extern void facePrintln(u8 face, double val);
    00113
    00114 extern void facePrintlnCheckByte(u8 face);
    00115
    00128 struct FacePrinter {
    00129   void (*print)(u8 face, u8 byte);
    00130   void (*println)(u8 face);
    00131   void (*printFaceCode)(u8 face);
    00132
    00133   const char * (*getFaceName)(u8 face);
    00134
    00135 };
    00136
    00137 extern bool faceHasPrinter(u8 face);
    00138
    00139
    00146 extern const FacePrinter * faceGetPrinter(u8 face);
    00147
    00158 extern bool faceFindFreeFace(u8 & foundFace);
    00159
    00174 extern void faceSetPrinter(u8 face, const FacePrinter * handler) ;
    00175
    00184 extern void faceUnsetPrinter(u8 face) ;
    00185
    00190 struct PacketPrinterHeader {
    00191   FacePrinter fp;
    00192   u8 maxLen;
    00193   u8 usedLen;
    00194   u8 sourceFace;                // WARNING! sourceFace must be the last field of the struct!
    00195   // u8 packetBuffer[0]; /* Illegal ISO C++, but just so you know: Packet buffer starts here. */
    00196 };
    00197
    00205 #define PACKET_PRINTER_BUFFER_OVERHEAD_BYTES \
    00206   (sizeof(PacketPrinterHeader)+sizeof(PacketHeader)+3+1) // (up to) 3 for alignment + 1 null terminator
    00207
    00211 #define PACKET_PRINTER_PACKET_BUFFER_SIZE \
    00212   (PACKET_PRINTER_BUFFER_OVERHEAD_BYTES+MAX_PACKET_LENGTH) // room for a full packet
    00213
    00258 extern u8 * makePacketPrinter(u8 & assignedFace, u8 * buffer, u32 bufferLength, u8 sourceFace) ;
    00259
    00260 /* The one-time serial startup code */
    00261 extern void print_startup_initialization() ;
    00262
    00263 #endif  /* SFBPRINT_H */
    00264