SNMP agent attached to SPI slave

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IO_file.h Source File

IO_file.h

00001 /*****************************************************************************
00002 *                     Copyright SEEC Ltd
00003 * File:             IO_file.h
00004 * Reference:        A3600-HDR-IO_file
00005 * Content:          Defines & declarations for HTTP server
00006 * Version:          1.1
00007 * System:           mbed
00008 * Target Hardware:  mbed                                  
00009 * Amendment Record:    
00010 * Author:   L. Smith for all versions unless otherwise specified
00011   0.0:  18/10/11    Initial tests 
00012   0.1:  27/10/11    File IO handled by SPI_server class
00013   0.2:  23/11/11    Add SNMP_FW_VERSION & snmp_fw_version for SNMP enquiry
00014   0.3   22/12/11    Add new_cmd_idx to indicate which parameter has been set. 
00015   0.4   27/12/11    Add RUN_SCAN_CMD as index for writing wiring scan enable. 
00016   0.5   29/12/11    Add net_addrs_set for writing net address to file. 
00017   0.6   06/01/12    Change main CPU index for version & add indices for net addresses 
00018   0.7   09/01/12    #define NET_ADDRESS_CHANGE to flag net address changes 
00019   0.8   30/01/12    Add get_SPI_count() & #define SPI_COUNT = 1752
00020   0.9   03/05/12    Add definitions used for trap handling
00021   1.0   15/06/12    Make TRAP_HOST_ADDRESS contiguous with SNMP net addresses
00022   1.1   18/06/12    Add get_hex_mask for updates from SNMP
00023 */
00024 /****************************************************************************/
00025 
00026 #ifndef IO_FILE_H
00027 #define IO_FILE_H
00028 
00029 #include <ctype.h>
00030 #define __DEBUG
00031 #include "dbg/dbg.h"
00032 #include "ipaddr.h"
00033 //#include "rpc.h"
00034 
00035 #define H_H_LINK_MSBYTE     62        // index to main CPU head-head link status ms byte
00036 #define H_H_LINK_LSBYTE     63        // DEBUG head-head link status ls byte should be 63
00037 #define MAX_IO_REG_BYTE     63        // Maximum I/O byte checked for changes
00038 
00039 #define NET_IP_ADDRESS      1704      // index to main CPU firmware IP addresses
00040 #define NET_ADDRESS_MASK    1708      // index to main CPU firmware address mask
00041 #define NET_GATEWAY_ADDRS   1712      // index to main CPU firmware gateway address
00042 #define NET_DNS_ADDRESS     1716      // index to main CPU firmware DNS address
00043 #define TRAP_HOST_ADDRESS   1720      // index to main CPU firmware address for trap host
00044 #define NET_ADDRESS_CHANGE  1736      // index to main CPU address change flag
00045 #define SPI_COUNT     1752            // index to main CPU SPI write count (activity indicator)
00046 #define VERSION_IDX   1754            // index to main CPU firmware version number
00047 #define RUN_SCAN_IDX  1758            // index to wiring scan enable in main CPU unit 
00048 #define NUM_CARD_IDX  2045            // index to number of card in main CPU unit
00049 #define COMMS_IDX     2046            // index to main CPU Modbus comms type and speed
00050 #define UNIT_ID_IDX   2047            // index to main CPU Modbus comms unit ident
00051 #define MAX_RAM       2048            // size of RAM to copy
00052 #define UNIT_ID_CMD   1               // index to command for Modbus comms unit ident
00053 #define RUN_SCAN_CMD  2               // index to command for 1000PX run scan enable
00054 
00055 /* v0.9: Trap definitions addeds */
00056 #define ONLY_TRAP       0           // index for trap when only one used
00057 #define DISABLED        0
00058 #define ENABLED         1
00059 
00060 
00061 class SPI_Server
00062 {
00063 public:
00064   ///Instantiates the SPI Server
00065   SPI_Server( const char * name = NULL );
00066   virtual ~SPI_Server();
00067   
00068   int update_IO_file();
00069   int read( void );
00070   void write( int new_offset );
00071   unsigned char get_byte( unsigned short idx );
00072   void put_byte( unsigned short idx, unsigned char new_byte );
00073   unsigned short get_error( void );
00074   unsigned short get_SPI_count( void );
00075   unsigned char * net_address_ptr( void );
00076   unsigned char * trap_host_ptr( void );
00077   
00078 #if 0
00079 //#ifdef MBED_RPC
00080   virtual const struct rpc_method *get_rpc_methods();
00081   static struct rpc_class *get_rpc_class();
00082 #endif    // MBED_RPC
00083 
00084 private:
00085   const char *name;    
00086   FILE *fp;                           // handle for file to be created
00087   unsigned short reg_offset;          // register offset for HTTP display
00088   unsigned char ram_img[ MAX_RAM ];
00089 };
00090 
00091 extern unsigned char cmd_buf[];         // store for commands from Ethernet
00092 extern unsigned char new_cmd_idx;
00093 extern const char * snmp_fw_version;
00094 
00095 extern unsigned char ip_ad[];
00096 extern unsigned char msk_ad[];
00097 extern unsigned char gwy_ad[];
00098 extern unsigned char dns_ad[];
00099 extern unsigned char th_ad[];
00100 extern unsigned char net_addrs_set;     // flags net address change
00101 
00102 extern unsigned char blink_led;
00103 
00104 extern SPI_Server fsvr;
00105 extern void check4write_offset( char * req );
00106 extern char * get_hex_mask( void );
00107 
00108 extern IpAddr mip;
00109 
00110 
00111 
00112 #endif   // #ifndef IO_FILE_H