MCPcopy Create free account
hub / github.com/CANopenNode/CANopenNode / OD_find

Function OD_find

301/CO_ODinterface.c:139–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139OD_entry_t*
140OD_find(OD_t* od, uint16_t index) {
141 if ((od == NULL) || (od->size == 0U)) {
142 return NULL;
143 }
144
145 uint16_t min = 0;
146 uint16_t max = od->size - 1U;
147
148 /* Fast search in ordered Object Dictionary. If indexes are mixed, this won't work. If Object
149 * Dictionary has up to N entries, then the max number of loop passes is log2(N) */
150 while (min < max) {
151 /* get entry between min and max */
152 uint16_t cur = (min + max) >> 1;
153 OD_entry_t* entry = &od->list[cur];
154
155 if (index == entry->index) {
156 return entry;
157 }
158
159 if (index < entry->index) {
160 max = (cur > 0U) ? (cur - 1U) : cur;
161 } else {
162 min = cur + 1U;
163 }
164 }
165
166 if (min == max) {
167 OD_entry_t* entry = &od->list[min];
168 if (index == entry->index) {
169 return entry;
170 }
171 }
172
173 return NULL; /* entry does not exist in OD */
174}
175
176ODR_t
177OD_getSub(const OD_entry_t* entry, uint8_t subIndex, OD_IO_t* io, bool_t odOrig) {

Callers 5

CO_SRDO_configFunction · 0.85
CO_SDOserver_processFunction · 0.85
CO_PDO.cFile · 0.85
PDO_initMappingFunction · 0.85
ifFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected