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
Checksum for CTX35
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
- RDNZL
- Forum Moderator
- Posts: 1008
- Joined: Sun Sep 24, 2006 1:45 pm
- Location: Dordrecht, The Netherlands
- Contact:
Checksum for CTX35
Ok, you won 
This is my second version, the first one didn't return 2 chars when the checksum was less than 16
Developing DomotiGa - Gambas powered Domotics.

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
Checksum for CTX35
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(]
I know, not very usefull post, just trying to get my mind off of some other things...[xx(]
- RDNZL
- Forum Moderator
- Posts: 1008
- Joined: Sun Sep 24, 2006 1:45 pm
- Location: Dordrecht, The Netherlands
- Contact:
Checksum for CTX35
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.
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
@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.
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.