Update:
Item #3 of my original post I am wrong it is correct.
There is a Bug in J1939_AddressClaimHandling(). Only if you Have 3 or more fixed addresses. The code as written will only arbitrate 1 one time. Not as many as it needs to to go through the full address list. The other Address Arbitration modes work. Note this affect the original C18 Code too.
here is my fix, but I did not test it with the other modes. So do not add it unless you need it, or test it well
Code:
SendAddressClaim:
// Send Address Claim message for CommandedAddress
CopyName();
OneMessage.Msg.SourceAddress = CommandedAddress;
SET_NETWORK_WINDOW_BITS;
SendOneMessage( (J1939_MESSAGE *) &OneMessage );
if (((CommandedAddress & 0x80) == 0) || // Addresses 0-127
((CommandedAddress & 0xF8) == 0xF8)) // Addresses 248-253 (254,255 illegal)
{
J1939_Flags.Flags.CannotClaimAddress = 0;
J1939_Address = CommandedAddress;
// Set up filter to receive messages sent to this address
SetAddressFilter( J1939_Address );
}
else
{
// We don't have a proprietary address, so we need to wait.
J1939_Address = CommandedAddress; // ADDED NSK, need this here so we know the last failed address
// if we do several address claims to find an address
J1939_Flags.Flags.WaitingForAddressClaimContention = 1;
ContentionWaitTime = 0;
}
}