Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Related Pages  

packet.h

00001 /* *  packet.h  *  Packet processing module header file
00002 * */
00003 
00004 
00005 #define ASCIIPACKETS                    /*uncommented for ascii packets*/
00006 
00007 #ifdef ASCIIPACKETS
00008 #define HEADERSIZE 2
00009 #define DELIMITER  0
00010 
00011 #define MASKNIB    1 
00012 
00013 #define EXT_DELIMITER  2 
00014 
00015 #define EXT_MASKNIB    3 
00016 
00017 #define TRUE  1
00018 #define FALSE 0
00019 #define SUCCESS 1
00020 #define FAILURE 0
00021 
00022 #define DLMIN     'a'
00023 #define DLMAX     'p'
00024 #endif
00025 
00026 #ifdef BINPACKETS
00027 #define HEADERSIZE 1
00028 #endif
00029 
00030 //#define MAXPDATASIZE 32       /*MRKTYP2 16 bytes data*/
00031 
00032 #define MAXPDATASIZE 510    /*MRKTYP2 255 bytes data + extended header information*/
00033 
00034 #define MAXPACKETSIZE (MAXPDATASIZE+HEADERSIZE)
00035 #define TRANSFLIP 9+'a'
00036 
00037 
00038 /*
00039 Data Types
00040 */
00041 #define INVLTYP     0x00        
00042 #define MRKTYP0     0x01        
00043 #define MRKTYP1     0x02        
00044 #define MRKTYP2     0x03        
00045 #define MRKTYP3     0x04        
00046 #define MRKTYP4     0x05        
00047 #define MRKTYP5         0x06        
00048 #define MRKTYP6     0x07        
00049 
00050 /* Packet headers transmitted from the coprocessor*/
00051 /* (The digit is in the upper nibble of the header that is rxed)*/
00052 #define EXTCMD      0       // extended cmd protocol 
00053 #define ADBLK0      1       // a/d block 0 (channels 0-15)
00054 #define ADBLK1      2       // a/d block 1 (channels 16-23
00055 #define PRTIN0      3       // digital port block 0
00056 #define CAN     4       // CAN message
00057 #define KEYPAD      5       // Keypad header
00058 #define DAQ     6       // DAQ header
00059 #define PRTOUT      7       // digital port block 0 out(Rxed by coprocessor)
00060 #define PWMCON      8       // pwm config
00061 /* PWMCON- PWM configuration header*/
00062 
00063 #define PRTCFG0     9       //digital port block 0 configuration
00064 #define LONG_EXT    10      //LCD header
00065 #define SERIAL      11      //Serial Header
00066 #define IRDA        12      //IRDA header
00067 #define ADREQ0      13      //AD request block 0
00068 #define ADREQ1      14      //AD request block 1
00069 #define DREQ        15      //digital port req
00070 
00071 /* extended commands */
00072 
00073 #define EXTNULCMD   16
00074 #define SOFTINFO    17
00075 #define COUNTER     18      //counter read request
00076 #define COUNTERD    19      //counter data or config
00077 #define ICNOTIFY    20      //zero count notification
00078 #define CANCFG      21      //can configuration
00079 #define SERCFG      22      //Serial configuration
00080 #define LCDROWS     23      //change number of LCD rows     
00081 //#define RELAY     24      //relay header
00082 #define LED     25      //LED header
00083 #define TCAPS       26      //test caps
00084 #define BEEPER      27      //beeper
00085 #define LCD             29      //standard LCD
00086 #define VFP     30      //vfp header
00087 
00088 
00089 //long protocol headers start
00090 #define LPHEADERS   VFP
00091 
00092 
00093 //translations for the e12
00094 #define RS232DATA       IRDA
00095 #define RS422DATA       SERIAL
00096 #define SER232                  RS232DATA
00097 #define SER422                  RS422DATA
00098 
00099 #define VERSIONINFO             SOFTINFO
00100 
00101 /*delimiter, uncommenting this means delimiter exists*/
00102 //#define DELIM          ","              // packet delimeter(ascii packets only)
00103 #define NOPACKET        -1              // no packet available error
00104 #define PARSEERROR      -2              // parse error
00105 
00106 /* headers are unsigned bytes(chars) */
00107 typedef unsigned char PcpkHeader;
00108 typedef struct PcpkPacket PcpkPacket;
00109 
00110 struct PcpkPacket {
00111 unsigned char type; 
00112 unsigned char format; 
00113 unsigned char maskcnt; 
00114 unsigned char datasize; 
00115 unsigned int datanum; 
00116 unsigned char extended; 
00117 unsigned char mult; 
00118 unsigned char data[MAXPACKETSIZE];
00119 };
00120 
00121 
00122 
00123 /*Make an array of 16 elements of CONST for header decoding */
00124 
00125 
00126 
00127 
00128 
00129 static const PcpkHeader hdrTbl[32] = { MRKTYP5,MRKTYP3,MRKTYP3,MRKTYP0
00130                       ,MRKTYP2,MRKTYP2,MRKTYP1,MRKTYP0
00131                       ,MRKTYP1,MRKTYP0,MRKTYP6,MRKTYP2
00132                       ,MRKTYP2,MRKTYP4,MRKTYP4,MRKTYP4
00133                       ,INVLTYP,MRKTYP2,MRKTYP3,MRKTYP1
00134                       ,MRKTYP1,MRKTYP1,MRKTYP1,MRKTYP3
00135                       ,MRKTYP1,MRKTYP0,MRKTYP2,MRKTYP3
00136                       ,MRKTYP2,MRKTYP2,MRKTYP2,INVLTYP };
00137                 
00138 
00139 
00140  
00141 
00142 
00143 
00144 #define TRANS(head) (asciihead(head))
00145 
00146 #define EXT_TRANS(head) (head + 0x20)
00147 
00148 
00149 
00150 #define PTYPE(headr) (headr >> 4)  
00151 #define FORMAT(Type) (hdrTbl[Type])
00152 
00153 
00154 
00155 #define MASK(headr) (headr & 0x0f)
00156 
00157  
00158 
00159 
00160 
00161 
00162 #ifndef LIBCOMP
00163 extern PcpkHeader PcpkParseHeader(char *, PcpkPacket *);
00164 extern int PcpkParseData(char *, PcpkPacket *);
00165 extern char *PcpkPackGen(__u8 device,__u8 maskcnt,void *data);
00166 #endif
00167 
00168 
00169 //#define GEN_DEBUG
00170 
00171 #undef GENDEBUG
00172 #ifdef GEN_DEBUG
00173 #define GENDEBUG(fmt, args...) printf(fmt, ## args)
00174 #else 
00175 #define GENDEBUG(fmt, args...) 
00176 #endif
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 

Generated on Thu Jan 8 09:51:00 2004 for PCM-37e12 by doxygen1.2.15