1 /*****************************************************************************/ 2 /* */ 3 /* ICCOM.H */ 4 /* */ 5 /* (C) 1995-97 Ullrich von Bassewitz */ 6 /* Wacholderweg 14 */ 7 /* D-70597 Stuttgart */ 8 /* EMail: uz@ibb.schwaben.com */ 9 /* */ 10 /*****************************************************************************/ 11 12 13 14 // $Id$ 15 // 16 // $Log$ 17 // 18 // 19 20 21 22 #ifndef _ICCOM_H 23 #define _ICCOM_H 24 25 26 27 #include "str.h" 28 29 #include "icconfig.h" 30 #include "icshort.h" 31 32 33 34 /*****************************************************************************/ 35 /* Data */ 36 /*****************************************************************************/ 37 38 39 40 // Port address and irq used 41 extern unsigned PortBase; 42 extern unsigned PortIRQ; 43 44 // Flag for short or long wait after sending a message 45 extern int ShortWaitAfterMsg; 46 47 // Version of the config program (for firmware 2.0 and above) 48 extern unsigned char ConfigVersionHigh; 49 extern unsigned char ConfigVersionLow; 50 51 // Current ISTEC charges and a flag that is set to 1 on an update 52 extern IstecCharges Charges; 53 54 55 56 /*****************************************************************************/ 57 /* Com port related code */ 58 /*****************************************************************************/ 59 60 61 62 void CloseComPort (); 63 // Close the com port 64 65 int OpenComPort (const String& PortName); 66 // Try to open the com port. If the port is already open, it is closed and 67 // reopened. The function returns 0 on success and an error code on failure. 68 69 int ComPortAvail (); 70 // Return 1 if the com port is open, 0 if not 71 72 73 74 /*****************************************************************************/ 75 /* Low level ISTEC specific code */ 76 /*****************************************************************************/ 77 78 79 80 void IstecPoll (); 81 // Poll the istec for incoming debug messages. If we get a real message, store 82 // it in LastIstecMsg (there should be only one outstanding real message at a 83 // time). 84 85 86 87 /*****************************************************************************/ 88 /* High level ISTEC specific code */ 89 /*****************************************************************************/ 90 91 92 93 // All of the following functions may return a return code as specified below: 94 // 95 // 0 Done 96 // 1 Receive buffer overlow (ESTIC error - should not happen) 97 // 2 Receive buffer underflow (ESTIC error - should not happen) 98 // 3 Wrong device number in reply 99 // 4 Invalid reply code 100 // 5 Port is not open 101 // 6 Timeout 102 // 7 CTI error 103 // 104 const int ieDone = 0; 105 const int ieRecBufOverflow = 1; 106 const int ieRecBufUnderflow = 2; 107 const int ieWrongDevice = 3; 108 const int ieInvalidReply = 4; 109 const int iePortNotOpen = 5; 110 const int ieTimeout = 6; 111 const int ieCTIError = 7; 112 const int ieEEPROMInUse = 8; 113 114 115 116 void IstecErrorSync (); 117 // Try to resync the istec after an error 118 119 int IstecReady (); 120 // Check if the istec answers the "Ready" message. 121 122 void IstecRequestCharges (); 123 // Request the device charges from the istec. This function is different from 124 // the "Get" functions as it does not wait for a reply. The charge messages 125 // from the ISTEC are handled by the IstecPoll function in the background. 126 // If new charges are available, they are copied to Charges and the 127 // ChargeUpdate flag is set. 128 129 int IstecGetCharges (); 130 // Get the device charges from the istec. This function calls the "Request" 131 // function and waits until a timeout occurs or we get a reply. 132 133 void IstecPutCharges (const IstecCharges& Charges); 134 // Write the given charges to the istec and to Charges 135 136 int IstecGetConfig (IstecConfig& Config); 137 // Get the complete configuration from the istec 138 139 int IstecPutConfig (const IstecConfig& Config); 140 // Write the complete configuration to the istec. 141 142 int IstecGetShortNumbers (ShortNumberColl& ShortNumbers); 143 // Read the short numbers from the istec. The function may not be called if 144 // the firmware version is < 2.00! 145 146 int IstecPutShortNumbers (const ShortNumberColl& ShortNumbers); 147 // Store the short numbers into the istec. The function may not be called if 148 // the firmware version is < 2.00! 149 150 int IstecGetDayNight (unsigned& DayNight); 151 // Read the day/night setting from the istec. If the current firmware does 152 // not support this, return CTI_VAL_DAY, else return the setting 153 154 int IstecPutDayNight (unsigned DayNight); 155 // Set the active configuration. If the current firmware does not support 156 // this, ignore the command (return ieDone). 157 158 int IstecPutAlarm (unsigned Alarm); 159 // Set the alarm byte. If the current firmware does not support this, ignore 160 // the command (return ieDone). 161 162 void EnableDiagMode (); 163 // This will decrement the diag mode counter. If it is zero, the command for 164 // diag mode enable will be sent to the istec. 165 166 void UpdateDiagMode (); 167 // Send a "diag mode on" command to the istec if diag mode is currently 168 // enabled. 169 170 void DisableDiagMode (); 171 // Increment the diag mode counter. If there is a transition from 0 to 1, 172 // send the "diag mode off" command to the istec. 173 174 void IstecRingOn (unsigned char Device); 175 // Ring a phone. Device is 0..n 176 177 void IstecRingOff (unsigned char Device); 178 // Bell off. Device is 0..n 179 180 181 182 // End of ICCOM.H 183 184 #endif 185 186 187 188