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
  "Client Side Driver Directory Could Not be Cleaned Out" TurboSam 12 183 09-20-2018, 06:08 PM
Last Post: Dean Roddey
  CML Driver IDE docs - where? rbroders 1 49 09-18-2018, 05:41 PM
Last Post: Dean Roddey
  Timer Driver Question kblagron 5 123 09-14-2018, 02:43 AM
Last Post: znelbok
  reset driver statistics? rbroders 9 347 09-11-2018, 07:50 PM
Last Post: Dean Roddey
  Driver Configuration w/8 prompts rbroders 1 260 09-03-2018, 09:28 PM
Last Post: Dean Roddey
  Driver info/stats rbroders 6 367 09-02-2018, 08:34 PM
Last Post: Dean Roddey
  Sonos Driver zra 3 198 09-01-2018, 03:09 PM
Last Post: Dean Roddey
  HTTP Get driver not working znelbok 10 544 08-28-2018, 10:10 AM
Last Post: Dean Roddey
  Can't add fields to ElkDev driver rbroders 4 292 08-07-2018, 06:24 PM
Last Post: Dean Roddey
  Possible to copy all the name in a driver so can paste is elsewhere? ghurty 11 672 07-14-2018, 05:24 PM
Last Post: Dean Roddey

Forum Jump:

Users browsing this thread: 1 Guest(s)