View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Sat Feb 20, 2021 12:55 pm |
|
|
Yes, those are only warnings. Caused because the modbus code calls the
CRC calculation functions both inside and outside the interrupt.
Now this means the PIC code is accepting the incoming data request.
So has to be accepting this and it's checksum.
It is then replying. So serial RX and TX have to be working.
What is failing is that the PC code is saying the packet checksum is wrong.
Suspect one will have to dismantle the packet and calculate the check
oneself and see what is wrong. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Sat Feb 20, 2021 1:36 pm |
|
|
What's very odd is that it works using the 4520 PIC and not the 46K22. Since all the modbus stuff, like CRC, is in the 'modbus.c' file and the hardware (RS485) is the same, it's hard to understand what is causing the problem... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Sun Feb 21, 2021 3:03 am |
|
|
Question.
Was the 'working' 4520 code, compiled with the same compiler version?.
I ask, because I don't have 5.076. Now this is potentially interesting, because
as compiler versions come along, I don't save them, when I have had
significant 'issues' with a version. The fact that I didn't save 5.076, means
that for me, it had some significant issue(s).
Looking at the data packet shown, the checksum is wrong, so the PC
is reporting correctly. The data looks completely correct except for the
checksum. So I'm going to take a little while and generate the same
packet, and try putting this through the checksum calculation on 5.078,
and see if I get the result being shown here. If not, then it implies there
is some fault in the arithmetic on this compiler version.
Will come back when I have done this. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Sun Feb 21, 2021 3:46 am |
|
|
Looking at it, something very odd is going on with his compiler version.
If you look, the code as posted has 0x1D 05 loaded into the bottom holding
register, but the reply being shown has 00 01 being sent for this.
I've changed what is loaded to the holding registers to match what he
shows being sent, then run the code compiled with 5.078, and this generates
the CRC as D8FC, not the DF08 he has. I then tried again with 5.075, and this
too gives the right CRC. A look at the 'compiler changes' list shows that
5.076, had a bug with the -- operator on certain types of variable,
fixed in 5.077 I'd suspect the modbus code is actually being damaged by this
fault.
This was obviously 'why' I did not keep this version....
D8FC is the correct checksum for the data shown.
So the reason it is failing is that he has a compiler issue. |
|
|
yvzd
Joined: 16 Feb 2021 Posts: 9
|
|
Posted: Sun Feb 21, 2021 6:31 am |
|
|
Ttelmah wrote: | Looking at it, something very odd is going on with his compiler version.
If you look, the code as posted has 0x1D 05 loaded into the bottom holding
register, but the reply being shown has 00 01 being sent for this.
I've changed what is loaded to the holding registers to match what he
shows being sent, then run the code compiled with 5.078, and this generates
the CRC as D8FC, not the DF08 he has. I then tried again with 5.075, and this
too gives the right CRC. A look at the 'compiler changes' list shows that
5.076, had a bug with the -- operator on certain types of variable,
fixed in 5.077 I'd suspect the modbus code is actually being damaged by this
fault.
This was obviously 'why' I did not keep this version....
D8FC is the correct checksum for the data shown.
So the reason it is failing is that he has a compiler issue. |
Dear Ttelmah and also other friends thanks a lot for your valuable help. As you point out to compiler I try 5.092 and guess what everything is ok now crc calculation is right now.
Thak you all again for your valuable help I am so happy now
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Sun Feb 21, 2021 7:27 am |
|
|
You can also see 'why' we often have to ask for people to give the compiler
version. You nicely did, so I 'went looking' to see if there might be a compiler
issue. Sadly there was...
Glad you have it working now. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Sun Feb 21, 2021 8:52 am |
|
|
He must have updated the compiler between the 4520 working and 46k22 not working ?? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Sun Feb 21, 2021 12:00 pm |
|
|
That's why I asked:
Quote: |
Was the 'working' 4520 code, compiled with the same compiler version?.
|
The problem didn't exist on the previous version, and was fixed on the
next one.... |
|
|
yvzd
Joined: 16 Feb 2021 Posts: 9
|
|
Posted: Sun Feb 21, 2021 12:30 pm |
|
|
Ttelmah wrote: |
You can also see 'why' we often have to ask for people to give the compiler
version. You nicely did, so I 'went looking' to see if there might be a compiler
issue. Sadly there was...
Glad you have it working now. |
Dear Ttelmah thank you so much again yes normally I don't want to change version because I managed some header files according to my easypic board (like lcd) but I had another laptop for free so when I tried on it ohh thanks got |
|
|
|