Page 1 of 1
Checksum for CTX35
Posted: Mon Jun 09, 2008 1:11 pm
by RDNZL
Trying to make a driver for the CTX35. Been strugling with the checksum calculating bit, can someone post a vb or other basic code snippet how todo that? That would make my day!
Thanks,
Ron.
Edit:
Did just found out this one:
---
PUBLIC SUB Main()
DIM sCommand AS String
DIM Checksum AS Integer
DIM i AS Integer
sCommand = "$>28001E03E03"
FOR i = 1 TO Len(sCommand)
Checksum = Checksum + Asc(Mid$(sCommand, i, 1)) AND 255
NEXT
PRINT Hex$(Checksum)
END
---
Checksum for CTX35
Posted: Tue Jun 10, 2008 12:25 am
by Bwired
Code: Select all
Private Function CheckSum(x)
Dim q, l, i
x = "$>28001" + x
l = Len(x)
For i = 1 To l
q = q + Asc(Mid(x, i, 1))
Next i
ChSm = Right(Hex(q), 2)
End Function
Checksum for CTX35
Posted: Sat Jun 21, 2008 3:08 pm
by RDNZL
Ok, you won
This is my second version, the first one didn't return 2 chars when the checksum was less than 16
Code: Select all
PUBLIC SUB AddChecksum(sCommand AS String) AS String
DIM iChecksum, iLoop AS Integer
sCommand = "$>28001" & sCommand
FOR iLoop = 1 TO Len(sCommand)
iCheckSum = iChecksum + Asc(Mid$(sCommand, iLoop, 1))
NEXT
RETURN sCommand & Right$(Hex$(iChecksum), 2) & "#"
END
Developing DomotiGa - Gambas powered Domotics.
Checksum for CTX35
Posted: Sat Jun 21, 2008 11:28 pm
by Digit
Yeah, and you saved Len(sCommand) times an AND to execute.[:)]
I know, not very usefull post, just trying to get my mind off of some other things...[xx(]
Checksum for CTX35
Posted: Sun Jun 22, 2008 12:23 am
by RDNZL
Yes, makeing my code more efficient is still on my list.
This helps.
For the past weeks I have been writeing a domotics program in Gambas basic on Linux.
Oh boy, now I have even more respect for builders of sites like Bwired, so many things to want, so little time to code..

And the things you think are the hardest to build are done before you know it, but it's those 'easy things' that costs the most time.
And because I have no written blueprint, I tend to chance the framework every now and then, those periods costs liters of coffee!

I'm thinking about releasing the code under GPL, so other coders can donate their work, or parts of it, to speed up development.
But I guess I'm the only Gambas programmer here...
Regards,
Ron.
Developing DomotiGa - Gambas powered Domotics.
Checksum for CTX35
Posted: Sun Jun 22, 2008 10:06 am
by Jfn
@RDNLZ:
About releasing code, I am always interested in learning how you programmed certain things. How did you end up using Gamba to program stuff? I am developping my domotica system under Linux too. I do not use Gamba. I use perl/php and javascript.