@@ -271,27 +271,27 @@ void OLCB_CAN_Alias_Helper::preAllocateAliases(void)
271
271
272
272
void OLCB_CAN_Alias_Helper::allocateAlias (OLCB_NodeID* nodeID)
273
273
{
274
- // Serial.println("Allocating Alias for:");
275
- // nodeID->print();
274
+ Serial.println (" Allocating Alias for:" );
275
+ nodeID->print ();
276
276
private_nodeID_t *slot = 0 ;
277
277
// first, see if this NodeID is already in our list, and if so, don't worry about it.TODO
278
278
uint8_t i;
279
279
for (i = 0 ; i < CAN_ALIAS_BUFFER_SIZE; ++i)
280
280
{
281
- if (nodeID == _nodes[i].node ) // should point to same thing if same NID
281
+ if (_nodes[i].node -> sameNID (nodeID) ) // should point to same thing if same NID
282
282
{
283
- // Serial.println("No need to add duplicate NodeID to alias list");
283
+ Serial.println (" No need to add duplicate NodeID to alias list" );
284
284
return ;
285
285
}
286
286
}
287
- // Serial.println("setting initialized to false");
287
+ Serial.println (" setting initialized to false" );
288
288
nodeID->initialized = false ;
289
289
// find a location for this nodeID in our list
290
290
for (i = 0 ; i < CAN_ALIAS_BUFFER_SIZE; ++i)
291
291
{
292
292
if (_nodes[i].state == ALIAS_HOLDING_STATE)
293
293
{
294
- // Serial.println("allocate: found a slot w/alias!");
294
+ Serial.println (" allocate: found a slot w/alias!" );
295
295
slot = &(_nodes[i]);
296
296
break ;
297
297
}
@@ -300,12 +300,12 @@ void OLCB_CAN_Alias_Helper::allocateAlias(OLCB_NodeID* nodeID)
300
300
{
301
301
for (uint8_t i = 0 ; i < CAN_ALIAS_BUFFER_SIZE; ++i)
302
302
{
303
- // Serial.print("Checking slot ");
304
- // Serial.println(i, DEC);
305
- // Serial.println(_nodes[i].state, DEC);
303
+ Serial.print (" Checking slot " );
304
+ Serial.println (i, DEC);
305
+ Serial.println (_nodes[i].state , DEC);
306
306
if (_nodes[i].state == ALIAS_EMPTY_STATE)
307
307
{
308
- // Serial.println("allocate: found a slot w/o alias!");
308
+ Serial.println (" allocate: found a slot w/o alias!" );
309
309
slot = &(_nodes[i]);
310
310
break ;
311
311
}
@@ -314,25 +314,25 @@ void OLCB_CAN_Alias_Helper::allocateAlias(OLCB_NodeID* nodeID)
314
314
if (!slot)
315
315
// SERIUS ERROR CONDITION! NO SPACE TO CACHE NODEID!!
316
316
{
317
- // Serial.println("allocate: NO MORE SLOTS FOR NODEIDS!");
318
- // Serial.println(CAN_ALIAS_BUFFER_SIZE, DEC);
317
+ Serial.println (" allocate: NO MORE SLOTS FOR NODEIDS!" );
318
+ Serial.println (CAN_ALIAS_BUFFER_SIZE, DEC);
319
319
while (1 );
320
320
}
321
321
322
322
323
- // Serial.println("Assigning nodeid to cache slot");
323
+ Serial.println (" Assigning nodeid to cache slot" );
324
324
slot->node = nodeID;
325
325
// does the slot already have an alias we can reuse?
326
326
if (slot->alias )
327
327
{
328
- // Serial.print("allocate: no need to allocate alias: ");
329
- // Serial.println(slot->alias, DEC);
328
+ Serial.print (" allocate: no need to allocate alias: " );
329
+ Serial.println (slot->alias , DEC);
330
330
slot->node ->alias = slot->alias ; // copy it into the nodeID
331
331
slot->state = ALIAS_AMD_STATE; // ready to go! Just send an AMD
332
332
}
333
333
else // we'll need to generate and allocate an alias
334
334
{
335
- // Serial.println("allocate: moving to CID1!");
335
+ Serial.println (" allocate: moving to CID1!" );
336
336
uint32_t lfsr1 = (((uint32_t )nodeID->val [0 ]) << 16 ) | (((uint32_t )nodeID->val [1 ]) << 8 ) | ((uint32_t )nodeID->val [2 ]);
337
337
uint32_t lfsr2 = (((uint32_t )nodeID->val [3 ]) << 16 ) | (((uint32_t )nodeID->val [4 ]) << 8 ) | ((uint32_t )nodeID->val [5 ]);
338
338
slot->alias = (lfsr1 ^ lfsr2 ^ (lfsr1>>12 ) ^ (lfsr2>>12 ) )&0xFFF ;
@@ -341,9 +341,9 @@ void OLCB_CAN_Alias_Helper::allocateAlias(OLCB_NodeID* nodeID)
341
341
slot->alias = 1 ; // a hack just to avoid a 0 alias.
342
342
slot->state = ALIAS_CID1_STATE;
343
343
}
344
- // Serial.print("New alias = ");
345
- // Serial.println(slot->alias);
346
- // Serial.println("Allocate alias done!");
344
+ Serial.print (" New alias = " );
345
+ Serial.println (slot->alias );
346
+ Serial.println (" Allocate alias done!" );
347
347
}
348
348
349
349
void OLCB_CAN_Alias_Helper::reAllocateAlias (private_nodeID_t* nodeID)
0 commit comments