PDA

View Full Version : how to specific crc ?



phoenix_1
- 16th March 2010, 22:00
I have RS485 (900 devices with displays and work 100% ok) now I need to implementa 9 more displays as terminals on network and pc send to my pic next:

Chr$(4) + Adr1 + Adr1 + Adr2 + Adr2 + Chr$(2) + Adr3 + "W" + "Q" + "PRESS INTERNATIONAL" + Chr$(3) + Chr$(crc) ' vb6 code

adr1 = number 0-9
adr2 = number 0-9
adr3 = number 0-9
and dat 1 to 4 are numbers 0-255

crc calculation on pc work fine with next:

crc = Dat1 Xor Dat2 Xor Dat3 Xor Dat4 Xor Hex(Adr3) ' vb6 code

I was probe in pbp : crc = Dat1 ^ Dat2 ^ Dat3 ^ Dat4 ^ Hex(Adr3)
but not success ....

Any idea for XOR for these crc calculation in pbp ?

And second question is any way to index variables ?
let we have :
a1 var byte[18]
a2 var byte[18]
a3 var byte[18]
... and up to a40

how can I say a(index) var byte[18]
and call in program loop "a" from 1 to 40 ....
sorry maybe i dont know to write good my question's.
example:


loop:
for i = 1 to 40
hserin [str a(i)/18]
next i
goto loop
end

phoenix_1
- 17th March 2010, 09:26
I have RS485 (900 devices with displays and work 100% ok) now I need to implementa 9 more displays as terminals on network and pc send to my pic next:

Chr$(4) + Adr1 + Adr1 + Adr2 + Adr2 + Chr$(2) + Adr3 + "W" + "Q" + "PRESS INTERNATIONAL" + Chr$(3) + Chr$(crc) ' vb6 code

adr1 = number 0-9
adr2 = number 0-9
adr3 = number 0-9
and dat 1 to 4 are numbers 0-255

crc calculation on pc work fine with next:

crc = Dat1 Xor Dat2 Xor Dat3 Xor Dat4 Xor Hex(Adr3) ' vb6 code

I was probe in pbp : crc = Dat1 ^ Dat2 ^ Dat3 ^ Dat4 ^ Hex(Adr3)
but not success ....

Any idea for XOR for these crc calculation in pbp ?]
Sorry I wasnt look as I must here in forum.
I found and work ok with :

crc = Dat1 ^^ Dat2 ^^ Dat3 ^^ Dat4 ^^ Hex(Adr3)

And second question now is first ;-) is any way to index variables ?
let we have :
a1 var byte[18]
a2 var byte[18]
a3 var byte[18]
... and up to a40

how can I say a(index) var byte[18]
and call in program loop "a" from 1 to 40 ....
sorry maybe i dont know to write good my question's.
example:


loop:
for i = 1 to 40
hserin [str a(i)/18]
next i
goto loop
end

mackrackit
- 17th March 2010, 10:31
Hi Robert,

Maybe this will help?
http://www.picbasic.co.uk/forum/showthread.php?t=544