Bug: telegrams are not received in special cases

Under certain circumstances telegrams with a GA that was successfully programmed with the suite are not received in the application.

Reasen is in KnxTpUart - the telegram is thrown away because IsAddressAssigned returns false.

IsAddressAssigned returns false, because of the binary search in _orderedIndexTable: When KOs have the same GA, only one of them is added to the list. All "unprogrammed" KOs have 0x000.

In an example of a device with 215 KO 37 have a (unique) GA != 0.

Thats the result:

AttachComObject 0 to 0x0000 AttachComObject 1 to 0x0814 AttachComObject 2 to 0x0815 AttachComObject 3 to 0x0818 AttachComObject 4 to 0x0819 AttachComObject 5 to 0x081a AttachComObject 6 to 0x0828 AttachComObject 7 to 0x0829 AttachComObject 8 to 0x082c AttachComObject 9 to 0x082d AttachComObject 10 to 0x082e AttachComObject 11 to 0x0f00 AttachComObject 12 to 0x2014 AttachComObject 13 to 0x2015 AttachComObject 14 to 0x2018 AttachComObject 15 to 0x2019 AttachComObject 16 to 0x201a AttachComObject 17 to 0x380a AttachComObject 18 to 0x380b AttachComObject 19 to 0x380e AttachComObject 20 to 0x380f AttachComObject 21 to 0x3810 AttachComObject 22 to 0x3814 AttachComObject 23 to 0x3815 AttachComObject 24 to 0x3816 AttachComObject 25 to 0x3817 AttachComObject 26 to 0x3819 AttachComObject 27 to 0x381a AttachComObject 28 to 0x381d AttachComObject 29 to 0xc800 AttachComObject 30 to 0xc801 AttachComObject 31 to 0xc804 AttachComObject 32 to 0xc805 AttachComObject 33 to 0xc806 AttachComObject 34 to 0xe900 AttachComObject 35 to 0xe901 AttachComObject 36 to 0xe902 AttachComObject 37 to 0xf707 AttachComObject 38 to 0x0000 AttachComObject 39 to 0x0000 AttachComObject 40 to 0x0814 AttachComObject 41 to 0x0815 AttachComObject 42 to 0x0818 AttachComObject 43 to 0x0819 AttachComObject 44 to 0x081a AttachComObject 45 to 0x0828 AttachComObject 46 to 0x0829 AttachComObject 47 to 0x082c AttachComObject 48 to 0x082d AttachComObject 49 to 0x082e AttachComObject 50 to 0x0f00 AttachComObject 51 to 0x2014 AttachComObject 52 to 0x2015 AttachComObject 53 to 0x2018 AttachComObject 54 to 0x2019 AttachComObject 55 to 0x201a AttachComObject 56 to 0x380a AttachComObject 57 to 0x380b AttachComObject 58 to 0x380e AttachComObject 59 to 0x380f AttachComObject 60 to 0x3810 AttachComObject 61 to 0x3814 AttachComObject 62 to 0x3815 AttachComObject 63 to 0x3816 AttachComObject 64 to 0x3817 AttachComObject 65 to 0x3819 AttachComObject 66 to 0x381a AttachComObject 67 to 0x381d AttachComObject 68 to 0xc800 AttachComObject 69 to 0xc801 AttachComObject 70 to 0xc804 AttachComObject 71 to 0xc805 AttachComObject 72 to 0xc806 AttachComObject 73 to 0xe900 AttachComObject 74 to 0xe901 AttachComObject 75 to 0xe902 AttachComObject 76 to 0xf707 AttachComObject 77 to 0x0000 AttachComObject 78 to 0x0000 AttachComObject 79 to 0x0814 AttachComObject 80 to 0x0815 AttachComObject 81 to 0x0818 AttachComObject 82 to 0x0819 AttachComObject 83 to 0x081a AttachComObject 84 to 0x0828 AttachComObject 85 to 0x0829 AttachComObject 86 to 0x082c AttachComObject 87 to 0x082d AttachComObject 88 to 0x082e AttachComObject 89 to 0x0f00 AttachComObject 90 to 0x2014 AttachComObject 91 to 0x2015 AttachComObject 92 to 0x2018 AttachComObject 93 to 0x2019 AttachComObject 94 to 0x201a AttachComObject 95 to 0x380a AttachComObject 96 to 0x380b AttachComObject 97 to 0x380e AttachComObject 98 to 0x380f AttachComObject 99 to 0x3810 AttachComObject 100 to 0x3814 AttachComObject 101 to 0x3815 AttachComObject 102 to 0x3816 AttachComObject 103 to 0x3817 AttachComObject 104 to 0x3819 AttachComObject 105 to 0x381a AttachComObject 106 to 0x381d AttachComObject 107 to 0xc800 AttachComObject 108 to 0xc801 AttachComObject 109 to 0xc804 AttachComObject 110 to 0xc805 AttachComObject 111 to 0xc806 AttachComObject 112 to 0xe900 AttachComObject 113 to 0xe901 AttachComObject 114 to 0xe902 AttachComObject 115 to 0xf707 AttachComObject 116 to 0x2000 AttachComObject 117 to 0x0000 AttachComObject 118 to 0x0814 AttachComObject 119 to 0x0815 AttachComObject 120 to 0x0818 AttachComObject 121 to 0x0819 AttachComObject 122 to 0x081a AttachComObject 123 to 0x0828 AttachComObject 124 to 0x0829 AttachComObject 125 to 0x082c AttachComObject 126 to 0x082d AttachComObject 127 to 0x082e AttachComObject 128 to 0x0f00 AttachComObject 129 to 0x2014 AttachComObject 130 to 0x2015 AttachComObject 131 to 0x2018 AttachComObject 132 to 0x2019 AttachComObject 133 to 0x201a AttachComObject 134 to 0x380a AttachComObject 135 to 0x380b AttachComObject 136 to 0x380e AttachComObject 137 to 0x380f AttachComObject 138 to 0x3810 AttachComObject 139 to 0x3814 AttachComObject 140 to 0x3815 AttachComObject 141 to 0x3816 AttachComObject 142 to 0x3817 AttachComObject 143 to 0x3819 AttachComObject 144 to 0x381a AttachComObject 145 to 0x381d AttachComObject 146 to 0xc800 AttachComObject 147 to 0xc801 AttachComObject 148 to 0xc804 AttachComObject 149 to 0xc805 AttachComObject 150 to 0xc806 AttachComObject 151 to 0xe900 AttachComObject 152 to 0xe901 AttachComObject 153 to 0xe902 AttachComObject 154 to 0xf707 AttachComObject 155 to 0x00a5 AttachComObject 156 to 0x0000 AttachComObject 157 to 0x0814 AttachComObject 158 to 0x0815 AttachComObject 159 to 0x0818 AttachComObject 160 to 0x0819 AttachComObject 161 to 0x081a AttachComObject 162 to 0x0828 AttachComObject 163 to 0x0829 AttachComObject 164 to 0x082c AttachComObject 165 to 0x082d AttachComObject 166 to 0x082e AttachComObject 167 to 0x0f00 AttachComObject 168 to 0x2014 AttachComObject 169 to 0x2015 AttachComObject 170 to 0x2018 AttachComObject 171 to 0x2019 AttachComObject 172 to 0x201a AttachComObject 173 to 0x380a AttachComObject 174 to 0x380b AttachComObject 175 to 0x380e AttachComObject 176 to 0x380f AttachComObject 177 to 0x3810 AttachComObject 178 to 0x3814 AttachComObject 179 to 0x3815 AttachComObject 180 to 0x3816 AttachComObject 181 to 0x3817 AttachComObject 182 to 0x3819 AttachComObject 183 to 0x381a AttachComObject 184 to 0x381d AttachComObject 185 to 0xc800 AttachComObject 186 to 0xc801 AttachComObject 187 to 0xc804 AttachComObject 188 to 0xc805 AttachComObject 189 to 0xc806 AttachComObject 190 to 0xe900 AttachComObject 191 to 0xe901 AttachComObject 192 to 0xe902 AttachComObject 193 to 0xf707 AttachComObject 194 to 0x0000 AttachComObject 195 to 0x0000 AttachComObject 196 to 0x0814 AttachComObject 197 to 0x0815 AttachComObject 198 to 0x0818 AttachComObject 199 to 0x0819 AttachComObject 200 to 0x081a AttachComObject 201 to 0x0828 AttachComObject 202 to 0x0829 AttachComObject 203 to 0x082c AttachComObject 204 to 0x082d AttachComObject 205 to 0x082e AttachComObject 206 to 0x0f00 AttachComObject 207 to 0x2014 AttachComObject 208 to 0x2015 AttachComObject 209 to 0x2018 AttachComObject 210 to 0x2019 AttachComObject 211 to 0x201a AttachComObject 212 to 0x380a AttachComObject 213 to 0x380b AttachComObject 214 to 0x380e

You can see, after the "biggest" GA 0xf707 is found and attached to pos. 37 of the ordered list, the algorithm goes rampage and starts from bottom up...

_orderedIndexTable = (byte*) malloc(_assignedComObjectsNb); word minMin = 0x0000; // minimum min value searched word foundMin = 0xFFFF; // min value found so far for (byte i = 0; i < _assignedComObjectsNb; i++) { for (byte j = 0; j < listSize; j++) { if ((IS_COM(j)) && (ADDR(j) >= minMin) && (ADDR(j) <= foundMin)) { foundMin = ADDR(j); _orderedIndexTable[i] = j; } } minMin = foundMin + 1; foundMin = 0xFFFF; } The problem is, that after the biggest ga is found, in the next outer for loop foundMin stays 0xffff. after the inner loop, minMin is set to foundMin + 1 what is 0x0000 due to overflow. => the sorting repeats from bottom up. => the list is not any more sorted, so the binary search fails at some cases.

the former Deduct of duplicate addresses reducedes the length of _orderedIndexTable / _assignedComObjectsNb to the unique ones, so that atfer the biggest GA was found, the tabled ended anyway.

=> I recommend adding the old code as it was.

Edited by SirSydom