ADICON Support Forum Applied Digital, Inc.
Page 1 of 1 1
Topic Options
#21980 - 07/15/10 01:03 PM Check Sum Question
Wild Bill Offline
newbie


Registered: 08/02/04
Posts: 8
Loc: Suffolk, VA
I have automation software I wrote many years ago in Visual Basic. I sends to the Ocelot a request string for variables and receives that string, occasionly with errors. Does anyone have some vb code to calculate the checksum of the data stream when requesting variables. It would save me a lot of time figuring it out.

Thanks

Top
#21984 - 07/16/10 02:25 PM Re: Check Sum Question [Re: Wild Bill]
Wild Bill Offline
newbie


Registered: 08/02/04
Posts: 8
Loc: Suffolk, VA
How do you calculate a two byte CRC?
Top
#21986 - 07/16/10 03:34 PM Re: Check Sum Question [Re: Wild Bill]
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
The sample programs (see the VB5 example at the bottom) shown here might be useful to you:

http://www.appdig.com/Activexcmax/activexcmax.html
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#21990 - 07/17/10 04:12 AM Re: Check Sum Question [Re: Guy Lavoie]
Wild Bill Offline
newbie


Registered: 08/02/04
Posts: 8
Loc: Suffolk, VA
Guy,
The VB5 example seems to show how to use the active X but does not show how the 2 byte CRC is calculated.
Do you have any other examples?

Top
#21991 - 07/17/10 02:46 PM Re: Check Sum Question [Re: Wild Bill]
Barry Parr Offline
journeyman


Registered: 02/15/04
Posts: 98
Loc: NZ
hi
this was in the activex example

 Quote:


Public Function calc_crc(ByRef Buffer() As Byte, Size_Less_One As Integer) As Long
Dim A As Long, B As Long, crcc As Long, i As Integer
Dim lcl As Byte
Dim C As Long
crcc = 65535
For i = 0 To Size_Less_One
A = 0
B = 0

lcl = CByte(Buffer(i))
'A = crcc Xor (lcl * 256)
A = lcl * 16
A = A * 16

A = A Xor crcc

B = A
'A = (((A And &HF000) / 16) Xor B)
A = A And &HF000
A = A \ 16
A = A Xor B

B = A
C = B
' B = ((B / 256) And &HFF) + ((B And &HFF) * 256)
B = (B \ 256)
C = (C And &HFF) * 256
B = B + C


A = A And &HFF00
A = (A \ 8) + ((A And 7) * 8192)
B = B Xor A
A = A \ 2
C = A
' A = ((A / 256) And &HFF) + ((A And &HFF) * 256)
A = (A \ 256) And &HFF
C = (C And &HFF) * 256
A = A + C


A = (A And &HF000) Xor B
crcc = A And &HFFFF
Next i
calc_crc = crcc

End Function

Top
#22032 - 08/10/10 06:41 AM Re: Check Sum Question [Re: Barry Parr]
Wild Bill Offline
newbie


Registered: 08/02/04
Posts: 8
Loc: Suffolk, VA
Thank you gentlemen. The info above solved my problem and I now have a much more reliable program.
Top
#23445 - 01/17/13 09:48 PM Re: Check Sum Question [Re: Wild Bill]
Allyson Offline
newbie


Registered: 01/15/13
Posts: 5
Hi, you all shared really nice information here about the sum question, Actually I also want to a tutorial for the same purposes because I want to learn asp so please suggest any tutorial.I must say thanks to MR:Barryparr for sharing code. thanks in advance.
_________________________
home alarm monitoring brisbane

Top
Page 1 of 1 1


Moderator:  Dan Smith, Monte G, ADI Tech Support, Guy Lavoie 
Hop to:
Who's Online
0 registered and 46 anonymous users online.
Recent Posts
Shout Box

Newest Members
brigiel, vevevie, zhutree, 416, saiqul
3003 Registered Users
Forum Stats
3003 Members
19 Forums
3998 Topics
23424 Posts

Max Online: 132 @ 11/13/16 10:07 AM
April
Su M Tu W Th F Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30