1 /* 2 OW -- One-Wire filesystem 3 version 0.4 7/2/2003 4 5 Function naming scheme: 6 OW -- Generic call to interaface 7 LI -- LINK commands 8 L1 -- 2480B commands 9 FS -- filesystem commands 10 UT -- utility functions 11 12 LICENSE (As of version 2.5p4 2-Oct-2006) 13 owlib: GPL v2 14 owfs, owhttpd, owftpd, owserver: GPL v2 15 owshell(owdir owread owwrite owpresent): GPL v2 16 owcapi (libowcapi): GPL v2 17 owperl: GPL v2 18 owtcl: LGPL v2 19 owphp: GPL v2 20 owpython: GPL v2 21 owsim.tcl: GPL v2 22 where GPL v2 is the "Gnu General License version 2" 23 and "LGPL v2" is the "Lesser Gnu General License version 2" 24 25 26 Written 2003 Paul H Alfille 27 */ 28 29 #ifndef OW_FILETYPE_H /* tedious wrapper */ 30 #define OW_FILETYPE_H 31 32 /* Define our understanding of integers, floats, ... */ 33 #include "ow_localtypes.h" 34 35 /* Several different structures: 36 device -- one for each type of 1-wire device 37 filetype -- one for each type of file 38 parsedname -- translates a path into usable form 39 */ 40 41 /* --------------------------------------------------------- */ 42 /* Filetypes -- directory entries for each 1-wire chip found */ 43 /* 44 Filetype is the most elaborate of the internal structures, though 45 simple in concept. 46 47 Actually a little misnamed. Each filetype corresponds to a device 48 property, and to a file in the file system (though there are Filetype 49 entries for some directory elements too) 50 51 Filetypes belong to a particular device. (i.e. each device has it's list 52 of filetypes) and have a name and pointers to processing functions. Filetypes 53 also have a data format (integer, ascii,...) and a data length, and an indication 54 of whether the property is static, changes only on command, or is volatile. 55 56 Some properties occur are arrays (pages of memory, logs of temperature 57 values). The "aggregate" structure holds to allowable size, and the method 58 of access. -- Aggregate properties are either accessed all at once, then 59 split, or accessed individually. The choice depends on the device hardware. 60 There is even a further wrinkle: mixed. In cases where the handling can be either, 61 mixed causes separate handling of individual items are querried, and combined 62 if ALL are requested. This is useful for the DS2450 quad A/D where volt and PIO functions 63 step on each other, but the conversion time for individual is rather costly. 64 */ 65 66 enum ag_index { ag_numbers, ag_letters, }; 67 68 enum ag_combined { 69 ag_separate, 70 ag_aggregate, 71 ag_mixed, 72 ag_sparse, 73 }; 74 75 /* aggregate defines array properties */ 76 struct aggregate { 77 int elements; /* Maximum number of elements */ 78 enum ag_index letters; /* name them with letters or numbers */ 79 enum ag_combined combined; /* Combined bitmaps properties, or separately addressed */ 80 }; 81 82 /* property format, controls web display */ 83 /* Some explanation of ft_format: 84 Each file type is either a device (physical 1-wire chip or virtual statistics container). 85 or a file (property). 86 The devices act as directories of properties. 87 The files are either properties of the device, or sometimes special directories themselves. 88 If properties, they can be integer, text, etc or special directory types. 89 There is also the directory type, ft_directory reflects a branch type, 90 * which restarts the parsing process. 91 */ 92 enum ft_format { 93 ft_unknown, 94 ft_directory, 95 ft_subdir, 96 ft_integer, 97 ft_unsigned, 98 ft_float, 99 ft_alias, // A human readable name in lue of numeric ID 100 ft_ascii, 101 ft_vascii, // variable length ascii -- must be read and measured. 102 ft_binary, 103 ft_yesno, 104 ft_date, 105 ft_bitfield, 106 ft_temperature, 107 ft_tempgap, 108 ft_pressure, 109 }; 110 111 /* property changability. Static unchanged, Stable we change, Volatile changes */ 112 enum fc_change { 113 fc_static, // doesn't change (e.g. chip property) 114 fc_stable, // only changes if we write to the chip 115 fc_read_stable, // stable after a read, not a write 116 fc_volatile, // changes on it's own (e.g. external pin voltage) 117 fc_simultaneous_temperature, // volatile with a twist 118 fc_simultaneous_voltage, // volatile with a twist 119 fc_uncached, // Don't cache (because the read and write interpretation are different) 120 fc_second, // timer (changes every second) 121 fc_statistic, // internally held statistic 122 fc_persistent, // internal cumulative counter 123 fc_directory, // directory listing 124 fc_presence, // chip <-> bus pairing 125 fc_link, // a link to another property -- cache that one instead 126 fc_page, // cache a page of memory 127 fc_subdir, // really a NOP, but makes code clearer 128 }; 129 130 /* Predeclare one_wire_query */ 131 struct one_wire_query; 132 /* Predeclare parsedname */ 133 struct parsedname; 134 135 #define PROPERTY_LENGTH_INTEGER 12 136 #define PROPERTY_LENGTH_UNSIGNED 12 137 #define PROPERTY_LENGTH_BITFIELD 12 138 #define PROPERTY_LENGTH_FLOAT 12 139 #define PROPERTY_LENGTH_PRESSURE 12 140 #define PROPERTY_LENGTH_TEMP 12 141 #define PROPERTY_LENGTH_TEMPGAP 12 142 #define PROPERTY_LENGTH_DATE 24 143 #define PROPERTY_LENGTH_YESNO 1 144 #define PROPERTY_LENGTH_STRUCTURE 32 145 #define PROPERTY_LENGTH_DIRECTORY 8 146 #define PROPERTY_LENGTH_SUBDIR 0 147 #define PROPERTY_LENGTH_ALIAS 256 148 #define PROPERTY_LENGTH_ADDRESS 16 149 #define PROPERTY_LENGTH_TYPE 32 150 151 #define NON_AGGREGATE NULL 152 153 #define NO_FILETYPE_DATA {.v=NULL} 154 155 #define NO_READ_FUNCTION NULL 156 #define NO_WRITE_FUNCTION NULL 157 158 #include "ow_visibility.h" 159 160 /* filetype gives -file types- for chip properties */ 161 struct filetype { 162 char *name; 163 int suglen; // length of field 164 struct aggregate *ag; // struct pointer for aggregate 165 enum ft_format format; // type of data 166 enum fc_change change; // volatility 167 ZERO_OR_ERROR (*read) (struct one_wire_query *); // read callback function 168 ZERO_OR_ERROR (*write) (struct one_wire_query *); // write callback function 169 enum e_visibility (*visible) (const struct parsedname *); // Show in a directory listing? 170 union { 171 void * v; 172 int i; 173 UINT u; 174 _FLOAT f; 175 size_t s; 176 BYTE c; 177 ASCII *a; 178 } data; // extra data pointer (used for separating similar but differently named functions) 179 }; 180 #define NO_FILETYPE_DATA {.v=NULL} 181 182 #include "ow_bitfield.h" // read/write bit fields 183 184 /* --------- end Filetype -------------------- */ 185 186 #endif /* OW_FILETYPE_H */ 187