Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Really simple CML driver questions
I am finally moving into CML and have a few simple questions

My driver is compiling and fields are being created - woohoo..

One field I have has over ten variations, eg Counter1 to Counter16.

The problem is that they don't sort properly because of a missing zero on all below 10.

This is the line I am using to append the numbers

fldName.AppendCard4(indexout, Radices.Dec);

Indexout is counting up from 0 to 15 and appedning the number, but I want to append 00, 01, 02 etc (always want it to be two digits).

How do I do this. I am still trying to come to terms with the classes etc on the CQC web page.

The cheap way is just to check the index first and if it's less than 10, append a zero character first.
Dean Roddey
Software Geek Extraordinaire
Is that how you would do it?

or is there a special "function" that will append a two or three character number?
There are such methods, but they are overkill for something that simple. I'd just do it that way.
Dean Roddey
Software Geek Extraordinaire

I have done it. I was just hoping that there was a way to do it in less than the three lines it took to do with an if statement.

I like to keep my code as small as possible

Next question

I need to create a checksum

I start with a value like this 0008002
I need to add the ascii values up and then add three.
eg. 30h + 30h + 30h + 38h + 30h + 30h + 32h + 3h = 15D

The resultant hex value needs to truncated to two characters (5D for the above example) and then appended as ascii values (35 44)

The resulting string will be 00080025D (30 30 30 38 30 30 32 35 44)

I have a macro running to test this out at the moment and I am part way there.

Here is where I am stuck

How do I convert a card or int to a string?

The values add up in decimal (using String.SumChars). The decimal value is correct, but how do i convert it to a hex value?


You mean to append to the end of a string? If so, you'd use the AppendCard4() to take the Card4 value you got from the SumChars method and append it in hex format to the string. If the value is < 0x10, you'll probably want to append a '0' first, since they probably assume the checksum is two hex digits.

You could use the FmtToField() method of the String class, but that's a bit of overkill for something like this. You'd have to format it to another string then append that.
Dean Roddey
Software Geek Extraordinaire
Thanks Dean
I know these are really simple questions, but it is helping me a lot in working all this out.

How do I append a ETX (end of text) to a string - (ASCII code 0x03).

I tried to import the ASCII class but I cant seem to work out how to add the ETX. I also have to prepend STX as well.

The ASCII class just defines a set of literals. So it would be something like:


or something along those lines. That's just from memory.
Dean Roddey
Software Geek Extraordinaire
I tried that, with no luck

I get a "Method AppendChar expected parm 1 to be of type MEng.Char, but got MEng.Card1"

So ASCII.kETX is returning a 3, and not a ETX (which has no printable character).

Possibly Related Threads...
Thread Author Replies Views Last Post
  music & movie driver experiences and or suggestions zane 1 173 Yesterday, 09:33 AM
Last Post: Dean Roddey
  Simple check before setting Elk M1 to Arm State KenC 7 132 10-03-2017, 05:55 PM
Last Post: Dean Roddey
  Kramer Protocol 2000 driver and VS-1616v Help Please! NightLight 6 257 09-12-2017, 05:08 PM
Last Post: Dean Roddey
  Next V2 driver problem kjaerligkatt 9 309 09-05-2017, 01:33 PM
Last Post: kjaerligkatt
  RCS Thermostat Driver help sic0048 10 608 08-19-2017, 08:01 AM
Last Post: Dean Roddey
  Harmony Hub driver tom 43 4,470 08-17-2017, 09:00 AM
Last Post: Dean Roddey
  ISY Driver not able to change value on a specific switch Sendero 9 737 07-18-2017, 09:54 AM
Last Post: Dean Roddey
  If you got a notification from Nest about the CQC driver Dean Roddey 1 337 07-12-2017, 02:44 PM
Last Post: potts.mike
  Variable Driver Trigger Error zra 4 503 07-06-2017, 01:00 PM
Last Post: zra
  Marantz V2 Driver Feature Request zra 21 1,207 07-06-2017, 10:02 AM
Last Post: Dean Roddey

Forum Jump:

Users browsing this thread: 1 Guest(s)