Shop OBEX P1 Docs P2 Docs Learn Events
new coding scheme to me - is it familiar to you? — Parallax Forums

new coding scheme to me - is it familiar to you?

BitsBits Posts: 414
edited 2013-01-28 13:55 in General Discussion
I am trying to figure out this coding scheme. I send the number 1..300 and I get two

Any idea what is going on? Thanks.

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-01-28 10:13
    Bits wrote: »
    ... I send the number 1..300 and I get two bytes....

    To what are sending you sending the numbers?
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-01-28 10:18
    The number is encoded as two hex digits, where each digit is the hex value + $40. This uses the ASCII characters "@" through "O".
  • Heater.Heater. Posts: 21,230
    edited 2013-01-28 10:21
    Well if you remove the leading "4" digit from each number in square brackets and then remove the spaces within the brackets you get:

    [01] = 1
    [02] = 2
    [03] = 3
    [04] = 4
    [0A] = 10
    [0B] = 11


    [7D] = 125
    [96] = 150
    [AF] = 175
    [C8] = 200
    [E1] = 225
    [FA] = 250
    [FF] = 255
    [2C] = 300


    And here we see the number in brackets is the hexadecimal equivalent of the numbers on the right.

    Except for [2C] which is only 44 in decimal.

    But I note that 12C hex is 300 decimal. Are you sure that last entry [52 4C]?
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-01-28 10:22
    "It" is sort of converting them to hex values. I'm not sure why it is putting 0x40 with it. 255 = 0xFF = 0x4F 0x4F
    ..and the other numbers work out similarly. It's not ASCII, not EBCDIC. It's not carrying or indicating an overflow or a wrap around.
  • BitsBits Posts: 414
    edited 2013-01-28 10:24
    Heater. wrote: »
    Well if you remove the leading "4" digit from each number in square brackets and then remove the spaces within the brackets you get:

    [01] = 1
    [02] = 2
    [03] = 3
    [04] = 4
    [0A] = 10
    [0B] = 11


    [7D] = 125
    [96] = 150
    [AF] = 175
    [C8] = 200
    [E1] = 225
    [FA] = 250
    [FF] = 255
    [2C] = 300


    And here we see the number in brackets is the hexadecimal equivalent of the numbers on the right.

    Except for [2C] which is only 44 in decimal.

    But I note that 12C hex is 300 decimal. Are you sure that last entry [52 4C]?

    Ah I think you nailed it - I bet 255 is max and thus the oddity. Thanks everyone.
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-01-28 10:31
    300 is $12C

    EDIT: Oh, I see that Heater already mentioned that "12C hex is 300 decimal". So it apears it's only encoding the 8 LSBs of the number.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2013-01-28 11:08
    I wonder if it's UTF-7...
  • BitsBits Posts: 414
    edited 2013-01-28 12:28
    Okay i think this converts it
    Pub Numbers(a,b) : out 
    
    
      out := (((A - $40) << 4) | (B - $40))
    

    Thanks all for the help
  • jmgjmg Posts: 15,173
    edited 2013-01-28 12:37
    Dave Hein wrote: »
    The number is encoded as two hex digits, where each digit is the hex value + $40. This uses the ASCII characters "@" through "O".

    Yes, a Quasi-Hex encoding, but one that overlaps std hex Chars.

    The sort of thing you might use if you were desperately short of space to unpack Std Hex ;), or if you wanted a (little) obfuscation, or maybe if you wanted to know it was your unit at the far end ?

    I think the ancient UU64 was quite similar, only it used a 32d base adder, and allowed 6 bit binary fields.

    { We have looked at using an alias-hex scheme here in designs, where we 'duplicate' Hex, but safely away from std hex, to allow control messages to be added to a standard Hex stream. }
  • jmgjmg Posts: 15,173
    edited 2013-01-28 12:42
    Bits wrote: »
    Okay i think this converts it

    Does it never send anything apart from 40H..4FH ?

    Intel hex uses the "':" as a block start indicator, and can skip CrLf, so I would check if this has other characters for block/control indicators.
  • BitsBits Posts: 414
    edited 2013-01-28 13:13
    No it just sends what I listed above except the space. Kind of strange but hacking this device I seen worse.
  • BitsBits Posts: 414
    edited 2013-01-28 13:55
    Now it appears there is a 3rd numbering scheme as well.
    Pub Numbers(a,b,c) : out
    
          out := (A - $40) << 4 | (B - $40)
          out := OUT<<4 |  (C - $40)
    
    

    SOLVED***
Sign In or Register to comment.