1 /* 2 OW -- One-Wire filesystem 3 version 0.4 7/2/2003 4 5 Written 2003 Paul H Alfille 6 Fuse code based on "fusexmp" {GPL} by Miklos Szeredi, mszeredi@inf.bme.hu 7 Serial code based on "xt" {GPL} by David Querbach, www.realtime.bc.ca 8 in turn based on "miniterm" by Sven Goldt, goldt@math.tu.berlin.de 9 GPL license 10 This program is free software; you can redistribute it and/or 11 modify it under the terms of the GNU General Public License 12 as published by the Free Software Foundation; either version 2 13 of the License, or (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 */ 21 22 #ifndef OW_CONNECTION_IN_H /* tedious wrapper */ 23 #define OW_CONNECTION_IN_H 24 25 /* struct connection_in (for each bus master) as part of ow_connection.h */ 26 27 // For forward references 28 struct connection_in; 29 struct port_in ; 30 31 /* -------------------------------------------- */ 32 /* BUS-MASTER-specific routines ---------------- */ 33 #include "ow_master.h" 34 35 #define CHANGED_USB_SPEED 0x001 36 #define CHANGED_USB_SLEW 0x002 37 #define CHANGED_USB_LOW 0x004 38 #define CHANGED_USB_OFFSET 0x008 39 40 41 enum adapter_type { 42 adapter_DS9097 = 0, 43 adapter_DS1410 = 1, 44 adapter_DS9097U2 = 2, 45 adapter_DS9097U = 3, 46 adapter_LINK = 7, 47 adapter_DS9490 = 8, 48 adapter_tcp = 9, 49 adapter_Bad = 10, 50 adapter_LINK_10, 51 adapter_LINK_11, 52 adapter_LINK_12, 53 adapter_LINK_13, 54 adapter_LINK_14, 55 adapter_LINK_15, 56 adapter_LINK_other, 57 adapter_LINK_E, 58 adapter_masterhub, 59 adapter_DS2482_100, 60 adapter_DS2482_800, 61 adapter_HA7NET, 62 adapter_HA5, 63 adapter_HA7E, 64 adapter_ENET, 65 adapter_EtherWeather, 66 adapter_fake, 67 adapter_tester, 68 adapter_mock, 69 adapter_w1, 70 adapter_w1_monitor, 71 adapter_browse_monitor, 72 adapter_xport, 73 adapter_usb_monitor, 74 adapter_enet_monitor, 75 adapter_masterhub_monitor, 76 adapter_external, 77 adapter_pbm, 78 adapter_ds1wm, 79 adapter_k1wm, 80 }; 81 82 enum e_reconnect { 83 reconnect_bad = -1, 84 reconnect_ok = 0, 85 reconnect_error = 2, 86 }; 87 88 enum e_anydevices { 89 anydevices_no = 0 , 90 anydevices_yes , 91 anydevices_unknown , 92 }; 93 94 enum e_bus_stat { 95 e_bus_reconnects, 96 e_bus_reconnect_errors, 97 e_bus_locks, 98 e_bus_unlocks, 99 e_bus_errors, 100 e_bus_resets, 101 e_bus_reset_errors, 102 e_bus_short_errors, 103 e_bus_program_errors, 104 e_bus_pullup_errors, 105 e_bus_timeouts, 106 e_bus_read_errors, 107 e_bus_write_errors, 108 e_bus_detect_errors, 109 e_bus_open_errors, 110 e_bus_close_errors, 111 e_bus_search_errors1, 112 e_bus_search_errors2, 113 e_bus_search_errors3, 114 e_bus_status_errors, 115 e_bus_select_errors, 116 e_bus_try_overdrive, 117 e_bus_failed_overdrive, 118 e_bus_stat_last_marker 119 }; 120 121 // Add serial/tcp/telnet abstraction 122 #include "ow_communication.h" 123 124 struct connection_in { 125 struct connection_in *next; 126 struct port_in * pown ; // pointer to port_in that owns us. 127 INDEX_OR_ERROR index; // general index number across all ports 128 int channel ; // index (0-based) in this port's channels 129 130 // Formerly Serial / tcp / telnet / i2c abstraction 131 // Now only holds device name since the port manages communication details 132 struct communication soc ; 133 134 pthread_mutex_t bus_mutex; 135 pthread_mutex_t dev_mutex; 136 void *dev_db; // dev-lock tree 137 enum e_reconnect reconnect_state; 138 struct timeval last_lock; /* statistics */ 139 140 UINT bus_stat[e_bus_stat_last_marker]; 141 142 struct timeval bus_time; 143 144 struct interface_routines iroutines; 145 enum adapter_type Adapter; 146 char *adapter_name; 147 enum e_anydevices AnyDevices; 148 int overdrive; 149 int flex ; 150 int changed_bus_settings; 151 int ds2404_found; 152 int ProgramAvailable; 153 size_t last_root_devs; 154 struct ds2409_hubs branch; // ds2409 branch currently selected 155 // or the special eBranch_bad and eBranch_cleared 156 157 // telnet tuning 158 int CRLF_size ; 159 160 unsigned char remembered_sn[SERIAL_NUMBER_SIZE] ; /* last address */ 161 162 size_t bundling_length; 163 164 union master_union master; 165 }; 166 167 #define DEVICENAME( connection ) ( (&( (connection)->soc))->devicename ) 168 169 #define NO_CONNECTION NULL 170 171 /* Defines for flow control */ 172 #define flow_first ( (Globals.serial_hardflow) ? flow_hard : flow_none ) 173 #define flow_second ( (Globals.serial_hardflow) ? flow_none : flow_first ) 174 175 extern struct inbound_control { 176 int active ; // how many "bus" entries are currently in linked list 177 int next_index ; // increasing sequence number 178 struct port_in * head_port ; // head of a linked list of "bus" entries 179 my_rwlock_t lock; // RW lock of linked list 180 int next_fake ; // count of fake buses 181 int next_tester ; // count tester buses 182 int next_mock ; // count mock buses 183 184 struct connection_in * w1_monitor ; 185 struct connection_in * external ; 186 } Inbound_Control ; // Single global struct -- see ow_connect.c 187 188 #endif /* OW_CONNECTION_IN_H */ 189