SNMP agent attached to SPI slave

Dependencies:   mbed

Committer:
lorcansmith
Date:
Mon Aug 13 15:07:40 2012 +0000
Revision:
0:2a53a4c3238c
Child:
1:bbae6f16a449
v1.1 release includes ioAlarm traps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lorcansmith 0:2a53a4c3238c 1 /*****************************************************************************
lorcansmith 0:2a53a4c3238c 2 * Copyright Field Electronics Ltd
lorcansmith 0:2a53a4c3238c 3 * File: IO_file.h
lorcansmith 0:2a53a4c3238c 4 * Reference: 1000PX-BM1660-HDR-IO_file
lorcansmith 0:2a53a4c3238c 5 * Content: Defines & declarations for HTTP server
lorcansmith 0:2a53a4c3238c 6 * Version: 1.1
lorcansmith 0:2a53a4c3238c 7 * System: mbed
lorcansmith 0:2a53a4c3238c 8 * Target Hardware: mbed
lorcansmith 0:2a53a4c3238c 9 * Amendment Record:
lorcansmith 0:2a53a4c3238c 10 * Author: L. Smith for all versions unless otherwise specified
lorcansmith 0:2a53a4c3238c 11 0.0: 18/10/11 Initial tests
lorcansmith 0:2a53a4c3238c 12 0.1: 27/10/11 File IO handled by SPI_server class
lorcansmith 0:2a53a4c3238c 13 0.2: 23/11/11 Add SNMP_FW_VERSION & snmp_fw_version for SNMP enquiry
lorcansmith 0:2a53a4c3238c 14 0.3 22/12/11 Add new_cmd_idx to indicate which parameter has been set.
lorcansmith 0:2a53a4c3238c 15 0.4 27/12/11 Add RUN_SCAN_CMD as index for writing wiring scan enable.
lorcansmith 0:2a53a4c3238c 16 0.5 29/12/11 Add net_addrs_set for writing net address to file.
lorcansmith 0:2a53a4c3238c 17 0.6 06/01/12 Change 3000 index for version & add indices for net addresses
lorcansmith 0:2a53a4c3238c 18 0.7 09/01/12 #define NET_ADDRESS_CHANGE to flag net address changes
lorcansmith 0:2a53a4c3238c 19 0.8 30/01/12 Add get_SPI_count() & #define SPI_COUNT = 1752
lorcansmith 0:2a53a4c3238c 20 0.9 03/05/12 Add definitions used for trap handling
lorcansmith 0:2a53a4c3238c 21 1.0 15/06/12 Make TRAP_HOST_ADDRESS contiguous with SNMP net addresses
lorcansmith 0:2a53a4c3238c 22 1.1 18/06/12 Add get_hex_mask for updates from SNMP
lorcansmith 0:2a53a4c3238c 23 */
lorcansmith 0:2a53a4c3238c 24 /****************************************************************************/
lorcansmith 0:2a53a4c3238c 25
lorcansmith 0:2a53a4c3238c 26 #ifndef IO_FILE_H
lorcansmith 0:2a53a4c3238c 27 #define IO_FILE_H
lorcansmith 0:2a53a4c3238c 28
lorcansmith 0:2a53a4c3238c 29 #include <ctype.h>
lorcansmith 0:2a53a4c3238c 30 #define __DEBUG
lorcansmith 0:2a53a4c3238c 31 #include "dbg/dbg.h"
lorcansmith 0:2a53a4c3238c 32 #include "ipaddr.h"
lorcansmith 0:2a53a4c3238c 33 #include "private_mib.h"
lorcansmith 0:2a53a4c3238c 34 //#include "rpc.h"
lorcansmith 0:2a53a4c3238c 35
lorcansmith 0:2a53a4c3238c 36 #define H_H_LINK_MSBYTE 62 // index to 3000 head-head link status ms byte
lorcansmith 0:2a53a4c3238c 37 #define H_H_LINK_LSBYTE 63 // DEBUG head-head link status ls byte should be 63
lorcansmith 0:2a53a4c3238c 38 #define MAX_IO_REG_BYTE 63 // Maximum I/O byte checked for changes
lorcansmith 0:2a53a4c3238c 39
lorcansmith 0:2a53a4c3238c 40 #define NET_IP_ADDRESS 1704 // index to 3000 firmware IP addresses
lorcansmith 0:2a53a4c3238c 41 #define NET_ADDRESS_MASK 1708 // index to 3000 firmware address mask
lorcansmith 0:2a53a4c3238c 42 #define NET_GATEWAY_ADDRS 1712 // index to 3000 firmware gateway address
lorcansmith 0:2a53a4c3238c 43 #define NET_DNS_ADDRESS 1716 // index to 3000 firmware DNS address
lorcansmith 0:2a53a4c3238c 44 #define TRAP_HOST_ADDRESS 1720 // index to 3000 firmware address for trap host
lorcansmith 0:2a53a4c3238c 45 #define NET_ADDRESS_CHANGE 1736 // index to 3000 address change flag
lorcansmith 0:2a53a4c3238c 46 #define SPI_COUNT 1752 // index to 3000 SPI write count (activity indicator)
lorcansmith 0:2a53a4c3238c 47 #define VERSION_IDX 1754 // index to 3000 firmware version number
lorcansmith 0:2a53a4c3238c 48 #define RUN_SCAN_IDX 1758 // index to wiring scan enable in 3000 unit
lorcansmith 0:2a53a4c3238c 49 #define NUM_CARD_IDX 2045 // index to number of card in 3000 unit
lorcansmith 0:2a53a4c3238c 50 #define COMMS_IDX 2046 // index to 3000 Modbus comms type and speed
lorcansmith 0:2a53a4c3238c 51 #define UNIT_ID_IDX 2047 // index to 3000 Modbus comms unit ident
lorcansmith 0:2a53a4c3238c 52 #define MAX_RAM 2048 // size of RAM to copy
lorcansmith 0:2a53a4c3238c 53 #define UNIT_ID_CMD 1 // index to command for Modbus comms unit ident
lorcansmith 0:2a53a4c3238c 54 #define RUN_SCAN_CMD 2 // index to command for 1000PX run scan enable
lorcansmith 0:2a53a4c3238c 55
lorcansmith 0:2a53a4c3238c 56 /* v0.9: Trap definitions added */
lorcansmith 0:2a53a4c3238c 57 #define ONLY_TRAP 0 // index for trap when only one used
lorcansmith 0:2a53a4c3238c 58 #define DISABLED 0
lorcansmith 0:2a53a4c3238c 59 #define ENABLED 1
lorcansmith 0:2a53a4c3238c 60
lorcansmith 0:2a53a4c3238c 61 #define MSG_LNGTH 16 // length of strings for alarm & location messages
lorcansmith 0:2a53a4c3238c 62 #define NUM_MASK 8 // MAX_ALARM_ID # of io_masks available for alarms
lorcansmith 0:2a53a4c3238c 63
lorcansmith 0:2a53a4c3238c 64 class SPI_Server
lorcansmith 0:2a53a4c3238c 65 {
lorcansmith 0:2a53a4c3238c 66 public:
lorcansmith 0:2a53a4c3238c 67 ///Instantiates the SPI Server
lorcansmith 0:2a53a4c3238c 68 SPI_Server( const char * name = NULL );
lorcansmith 0:2a53a4c3238c 69 virtual ~SPI_Server();
lorcansmith 0:2a53a4c3238c 70
lorcansmith 0:2a53a4c3238c 71 int update_IO_file();
lorcansmith 0:2a53a4c3238c 72 int read( void );
lorcansmith 0:2a53a4c3238c 73 void write( int new_offset );
lorcansmith 0:2a53a4c3238c 74 unsigned char get_byte( unsigned short idx );
lorcansmith 0:2a53a4c3238c 75 void put_byte( unsigned short idx, unsigned char new_byte );
lorcansmith 0:2a53a4c3238c 76 unsigned short get_error( void );
lorcansmith 0:2a53a4c3238c 77 unsigned short get_SPI_count( void );
lorcansmith 0:2a53a4c3238c 78 unsigned char * net_address_ptr( void );
lorcansmith 0:2a53a4c3238c 79 unsigned char * trap_host_ptr( void );
lorcansmith 0:2a53a4c3238c 80
lorcansmith 0:2a53a4c3238c 81 #if 0
lorcansmith 0:2a53a4c3238c 82 //#ifdef MBED_RPC
lorcansmith 0:2a53a4c3238c 83 virtual const struct rpc_method *get_rpc_methods();
lorcansmith 0:2a53a4c3238c 84 static struct rpc_class *get_rpc_class();
lorcansmith 0:2a53a4c3238c 85 #endif // MBED_RPC
lorcansmith 0:2a53a4c3238c 86
lorcansmith 0:2a53a4c3238c 87 private:
lorcansmith 0:2a53a4c3238c 88 const char *name;
lorcansmith 0:2a53a4c3238c 89 FILE *fp; // handle for file to be created
lorcansmith 0:2a53a4c3238c 90 unsigned short reg_offset; // register offset for HTTP display
lorcansmith 0:2a53a4c3238c 91 unsigned char ram_img[ MAX_RAM ];
lorcansmith 0:2a53a4c3238c 92 };
lorcansmith 0:2a53a4c3238c 93
lorcansmith 0:2a53a4c3238c 94 extern unsigned char cmd_buf[]; // store for commands from Ethernet
lorcansmith 0:2a53a4c3238c 95 extern unsigned char new_cmd_idx;
lorcansmith 0:2a53a4c3238c 96 extern const char * snmp_fw_version;
lorcansmith 0:2a53a4c3238c 97
lorcansmith 0:2a53a4c3238c 98 extern unsigned char ip_ad[];
lorcansmith 0:2a53a4c3238c 99 extern unsigned char msk_ad[];
lorcansmith 0:2a53a4c3238c 100 extern unsigned char gwy_ad[];
lorcansmith 0:2a53a4c3238c 101 extern unsigned char dns_ad[];
lorcansmith 0:2a53a4c3238c 102 extern unsigned char th_ad[];
lorcansmith 0:2a53a4c3238c 103 extern unsigned char net_addrs_set; // flags net address change
lorcansmith 0:2a53a4c3238c 104 extern unsigned char alarm_str_set; // flags alarm string update from SNMP
lorcansmith 0:2a53a4c3238c 105
lorcansmith 0:2a53a4c3238c 106 extern unsigned char blink_led;
lorcansmith 0:2a53a4c3238c 107
lorcansmith 0:2a53a4c3238c 108 extern char alarm_msg[NUM_MASK][MSG_LNGTH]; // alarm messages associated with io_masks
lorcansmith 0:2a53a4c3238c 109 extern unsigned long io_mask[]; // masks for alarms on IO registers
lorcansmith 0:2a53a4c3238c 110 extern unsigned long mask4_IO_registers; // mask for IO regs ignoring IO31 & 32
lorcansmith 0:2a53a4c3238c 111
lorcansmith 0:2a53a4c3238c 112
lorcansmith 0:2a53a4c3238c 113 extern SPI_Server fsvr;
lorcansmith 0:2a53a4c3238c 114 extern void check4write_offset( char * req );
lorcansmith 0:2a53a4c3238c 115 extern char * get_hex_mask( unsigned long bit_mask );
lorcansmith 0:2a53a4c3238c 116 extern char * get_alarm_string(unsigned char alarm_idx);
lorcansmith 0:2a53a4c3238c 117 extern int read_alarm_from_file(unsigned char alarm_idx);
lorcansmith 0:2a53a4c3238c 118
lorcansmith 0:2a53a4c3238c 119 extern IpAddr mip;
lorcansmith 0:2a53a4c3238c 120
lorcansmith 0:2a53a4c3238c 121
lorcansmith 0:2a53a4c3238c 122
lorcansmith 0:2a53a4c3238c 123 #endif // #ifndef IO_FILE_H