mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	Corrected BIN_SEARCH
This commit is contained in:
		
							parent
							
								
									bd840098e9
								
							
						
					
					
						commit
						9b79710cd9
					
				| @ -38,11 +38,11 @@ uint16_t AddressTableObject::getTsap(uint16_t addr) | ||||
| { | ||||
|     uint16_t size = entryCount(); | ||||
|     #ifdef USE_BINSEARCH | ||||
|     addr = htons(addr); | ||||
|     addr = ntohs(addr); | ||||
| 
 | ||||
|     uint16_t low,high,i; | ||||
|     low = 0; | ||||
|     high = size-1; | ||||
|     low = 1; | ||||
|     high = size; | ||||
| 
 | ||||
|     while(low <= high) | ||||
|     { | ||||
| @ -77,30 +77,8 @@ const uint8_t* AddressTableObject::restore(const uint8_t* buffer) | ||||
| 
 | ||||
| bool AddressTableObject::contains(uint16_t addr) | ||||
| { | ||||
|     uint16_t size = entryCount(); | ||||
|     #ifdef USE_BINSEARCH | ||||
|     addr = htons(addr); | ||||
| 
 | ||||
|     uint16_t low,high,i; | ||||
|     low = 0; | ||||
|     high = size-1; | ||||
| 
 | ||||
|     while(low <= high) | ||||
|     { | ||||
|         i = (low+high)/2; | ||||
|         if (_groupAddresses[i] == addr) | ||||
|             return true; | ||||
|         if(addr < _groupAddresses[i]) | ||||
|             high = i - 1; | ||||
|         else | ||||
|             low = i + 1 ; | ||||
|     } | ||||
|     #else | ||||
|     for (uint16_t i = 1; i <= size; i++) | ||||
|         if (ntohs(_groupAddresses[i]) == addr) | ||||
|             return true; | ||||
|     #endif | ||||
|     return false; | ||||
|     uint16_t foundTsap = getTsap(addr); | ||||
|     return (foundTsap > 0); | ||||
| } | ||||
| 
 | ||||
| void AddressTableObject::beforeStateChange(LoadState& newState) | ||||
|  | ||||
| @ -65,9 +65,9 @@ int32_t AssociationTableObject::translateAsap(uint16_t asap) | ||||
|              // search downwards to return the first occurence in the table
 | ||||
|             while(getASAP(--i) == asap) | ||||
|                 ; | ||||
|             return getASAP(i+1); | ||||
|             return getTSAP(i+1); | ||||
|         } | ||||
|         if(asap_i < asap) | ||||
|         if(asap_i > asap) | ||||
|             high = i - 1; | ||||
|         else | ||||
|             low = i + 1 ; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user