Jibeji said:
Hello,
I have tried remmie1972's code with a Leonardo Can Bus, but I get the following answer from the rectifier:
Received : 05014400 06 12 71 00 40 81 00 00 Serial Number is : 061271004081
TRANSMIT : 05004804 06 12 71 00 40 81 00 00 Log in with SrNr : 061271004081
Received : 05000081 3C 06 12 71 00 40 81 00 UNKNOWN COMMAND
Received : 05000081 5B 06 12 71 00 40 81 00 UNKNOWN COMMAND
Received : 05000081 5B 06 12 71 00 40 81 00 UNKNOWN COMMAND
Received : 05000081 5B 06 12 71 00 40 81 00 UNKNOWN COMMAND
Received : 05000081 5B 06 12 71 00 40 81 00 UNKNOWN COMMAND
Received : 05000081 5B 06 12 71 00 40 81 00 UNKNOWN COMMAND
Would you please help me to figure out what's going wrong?
Hi,
It looks like the rectifier does not send the last two bytes of the serial number in the header but does something with it.
the last two bytes of your serial number are 40 81. So in my code i assumed that when the rectifier sends : 05004081, it would require the controller to respond and log in. BUT, your rectifier sends 05000081 instead of 05004081. Therefore the code does not recognise it and sends it back as a unknown command.
In the code, find the line where it says :
else if(canId==(0x05000000+256*buf[5]+buf[6])) //if CANID = 0500xxyy where xxyy the last 2 digits of the serial nr
and change it to :
else if(canId==(0x05000000+buf[6])) //if CANID = 050000yy where yy is the last 2 digits of the serial nr
That should work for your rectifier but for other serial numbers it may be different, for some it wil work for others not. that depends on what eltek has programmed. I would have to have a number of serial numbers and the responses of the rectifier to determine the precise formula the rectifier requires. It COULD be something like 0500xxyy and FFFFAFFF (this changes the '4' bit in the fifth byte to zero. In your serial number thatit would flip the 4 to a 0 resulting in returning 05000081 instead of 05004081
you could off course also change it to :
else if(canId==(0x05000081)) //if CANID = 05000081
but that would limit the amount of serial numbers the code would work with even further.
Good luck