Thread: 32 Byte Hex Converted To 2 byte??

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2018
    Posts
    9

    32 Byte Hex Converted To 2 byte??

    Hello,
    I have been looking around the Internet and I cant really find what I am looking for. I was wondering if you guys can help me out and I will try to make this as clear as I can.

    I have this long hex string in 2 byte form:
    0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    Binary:
    00000100 00110001,00000000 00000000,00000001 01010100,00000001 01010011,00000001 01010001,00000001 01010111,00000000 01010001,00000000 01010010,00000001 01100000,00010000 00100000,00000000 01110101,00100001 10010111,00000001 01010010,00000001 01011000,00000000 01010111,00000000 01011000,




    Now have this other hex string that controls the long hex string:
    BF FF

    So if you are thinking yes BF controls one half and FF controls the other:
    BF = 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052
    Bin = 00000100 00110001,00000000 00000000,00000001 01010100,00000001 01010011,00000001 01010001,00000001 01010111,00000000 01010001,00000000 01010010,

    FF = 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    Bin= 00000001 01100000,00010000 00100000,00000000 01110101,00100001 10010111,00000001 01010010,00000001 01011000,00000000 01010111,00000000 01011000,

    Now I know for sure if I change BF FF to 00 00 this happens:
    BF to 00 = 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    Bin = All Zeros
    FF to 00 = 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    Bin = All Zeros

    And if I do this 00 FF this happens:
    BF to 00 = 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    Bin = All Zeros
    FF = 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    Bin= 00000001 01100000,00010000 00100000,00000000 01110101,00100001 10010111,00000001 01010010,00000001 01011000,00000000 01010111,00000000 01011000,

    I know this a lot of info but I am trying to be as clear as I can lol. Ok so now my question, is there a C code that can determine the BF sequence?

    If BF = 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052 what does C1 equal?

    Let say I want to do this:
    0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052 change to 0431, 0000, 0154, 0153, 0000, 0157, 0000, 0052 what will I change BF to then??

    0431, 0000, 0154, 0153, 0000, 0157, 0000, 0052 = ??

    If the long hex needs to 1 byte like so, then cool:
    04, 31, 00, 00, 01, 54, 01, 53, 01, 51, 01, 57, 00, 51, 00, 52
    00000100, 00110001, 00000000, 00000000, 00000001, 01010100, 00000001, 01010011, 00000001, 01010001, 00000001, 01010111, 00000000, 01010001, 00000000, 01010010,

    The commas are to help to visual see what bin is goes to which hex. In nutshell I guess, there a way in C to input the hex (or bin if need be) and it will calculate to the correct shortened/converted BF or BF FF?

    Thanks,
    Kevin.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Let me see if I have gathered your relationship correctly.
    You have a bunch of numbers (four bits each). The shorter string is obtained by making any nonzero number into a 1 and any zero into a 0. Yes?

    If so, then you can do something like
    Code:
    int result = 0;
    for (however many numbers)
        result <<= 1;
        if (number)
            result += 1;

  3. #3
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    Let me see if I have gathered your relationship correctly.
    You have a bunch of numbers (four bits each). The shorter string is obtained by making any nonzero number into a 1 and any zero into a 0. Yes?

    If so, then you can do something like
    Code:
    int result = 0;
    for (however many numbers)
        result <<= 1;
        if (number)
            result += 1;
    I would think so, I know 00 changes the whole string to Zeros and I know that BF is 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052. And sorry for my lack of knowledge I am only 2 weeks in learning C. My new job has pulled me back into programming but I have not done so since 2012! Lol If is not a hassle if you could provide a bit more coding? Some changing BF to any range from 00 to FF changes the long hex.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Are you trying to generate the long stuff from BF FF or the other way around? Or do you have a big long number, and a BF FF, and then a new big long number that has some zeroes in it?

  5. #5
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    Are you trying to generate the long stuff from BF FF or the other way around? Or do you have a big long number, and a BF FF, and then a new big long number that has some zeroes in it?
    I have both, there are many that are like this, I just kept it simple. Which ever is the best way. Here is a bit more
    BF FF = 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    Then another
    BF FF = 0421, 0000, 0134, 0133, 0131, 0137, 0031, 0032, 0140, 1022, 1023, 2195, 0132, 0138, 0037, 0038
    EB DB = 0000, 0000, 0401, 0462, 0442, 0000, 0033, 0510, 0551, 0441, 0000, 0451, 0461, 0000, 0128, 0442
    And like before EB controls the first half and DB control the other half. And I 00 00 these the long hex strings change 0000 for each.

    If best to convert for short string to long then cool but of long to short it is better then fine, I have both. I just need too know... You know what... I need long to short i.e.:
    EB DB = 0000, 0000, 0401, 0462, 0442, 0000, 0033, 0510, 0551, 0441, 0000, 0451, 0461, 0000, 0128, 0442

    I input 0000, 0000, 0401, 0462, 0442, 0000, 0033, 0510, 0551, 0441, 0000, 0000, 0000, 0000, 0128, 0000 = what? its not EB DB.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Turbo7 View Post
    I input 0000, 0000, 0401, 0462, 0442, 0000, 0033, 0510, 0551, 0441, 0000, 0000, 0000, 0000, 0128, 0000 = what? its not EB DB.
    Well, if you write 1 if you have a number and 0 if you have zero, you get 00111011 11000010, which is 0x3b c2. This is the code-like object I posted above.

    As you can see, it's not a reversible operation, since we have two different "results" for BF FF; but they must have the 0000 in the same place.

  7. #7
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    Well, if you write 1 if you have a number and 0 if you have zero, you get 00111011 11000010, which is 0x3b c2. This is the code-like object I posted above.

    As you can see, it's not a reversible operation, since we have two different "results" for BF FF; but they must have the 0000 in the same place.
    So if it's not reversible that mean I cant find out what I need?

    If I take:
    0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058
    to
    0431, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    BF FF should be something like B0 00 or 80 00 right? If so, how do I get there.

    I want to put in:
    0431, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    and get
    "The Correct Output"
    Can this not be done in C?

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Turbo7 View Post
    So if it's not reversible that mean I cant find out what I need?
    If you have the original, and the control string, then you can get to the result. But you need both of the inputs.
    Quote Originally Posted by Turbo7 View Post
    I want to put in:
    0431, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000
    and get
    "The Correct Output"
    Can this not be done in C?
    Not without specifying the 0x80 00 (or whatever pattern you need).

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So if changing the right table doesn't affect the left table, and changing the left table doesn't affect the right table, why do you think they are related?

    Most of these lines do follow the right pattern of on-off matching the hex on the left table, but there are a few exceptions.

  10. #10
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    So if changing the right table doesn't affect the left table, and changing the left table doesn't affect the right table, why do you think they are related?

    Most of these lines do follow the right pattern of on-off matching the hex on the left table, but there are a few exceptions.
    I noticed that too so thinking the left needs to be changed a bit. But need the left sequence.

    They are related in the fact the right table is a visual reference (a look up table that is in order with left table controller), I.E. on my bench numbers 0270, 0267, 0264, 0261 are showing, which is Left table 9 rows up from the bottom, 10 to the right, with that you can see the numbers line up with the left table with 0F FF which is 6 up from the bottom, Now when I changed 0F FF to 0F 00 those number turned off on my bench, and noticed that numbers are all in a row. See what I mean? That why said they are related and its a reference table.

    Thank you for all your help and trying to understand I am trying to get done!

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Turbo7 View Post
    I noticed that too so thinking the left needs to be changed a bit. But need the left sequence.

    They are related in the fact the right table is a visual reference (a look up table that is in order with left table controller), I.E. on my bench numbers 0270, 0267, 0264, 0261 are showing, which is Left table 9 rows up from the bottom, 10 to the right, with that you can see the numbers line up with the left table with 0F FF which is 6 up from the bottom, Now when I changed 0F FF to 0F 00 those number turned off on my bench, and noticed that numbers are all in a row. See what I mean? That why said they are related and its a reference table.

    Thank you for all your help and trying to understand I am trying to get done!
    The right-hand table can't depend solely on the left-hand table, since you have several rows that are the same on the left (the top two that are highlighted that odd shade of blue, the several rows of FF FF, a couple of F9 FDs, and some 00 0Fs) but different on the right. So there must be another aspect that is generating those numbers; I have no idea what this system is supposed to be so couldn't begin to guess what. It may be possible that changing the numbers on the left after the numbers on the right are generated may then do the masking, but unless you can be clear about events and sequencing, and what's in your control and what isn't, and why you're only seeing every other number from the table, I don't know where you can go from here.

  12. #12
    Registered User
    Join Date
    Nov 2018
    Posts
    9
    Quote Originally Posted by tabstop View Post
    The right-hand table can't depend solely on the left-hand table, since you have several rows that are the same on the left (the top two that are highlighted that odd shade of blue, the several rows of FF FF, a couple of F9 FDs, and some 00 0Fs) but different on the right. So there must be another aspect that is generating those numbers; I have no idea what this system is supposed to be so couldn't begin to guess what. It may be possible that changing the numbers on the left after the numbers on the right are generated may then do the masking, but unless you can be clear about events and sequencing, and what's in your control and what isn't, and why you're only seeing every other number from the table, I don't know where you can go from here.
    The bench is an ECU, I hook it up and it threw only certain numbers, that is why only a few numbers show up. The table on the left are instructions of adding and sub, but I do not fully understand the ECU language. When changing left table your are changing the instructions of on or off, therefor if done right you can turn off certain numbers not just all at once. So all I know is that right table it just reference table (look up only to match the instruction table on the left) and that visually you can see what numbers the left table will be turning on or off. Its not that left table controls the right table directly, it just there to help understand. Therefore, that why I was thinking if I can match the BF FF to 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058 (because these number are in hex whether its just 1 or 2 byte order). I am thinking that BF FF is just a shorten/combined/converted of 0431, 0000, 0154, 0153, 0151, 0157, 0051, 0052, 0160, 1020, 0075, 2197, 0152, 0158, 0057, 0058 hex. I know I have seen somewhere years back that you do you that, and that what I am thinking.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 01-22-2016, 03:20 AM
  2. File Comparision byte by byte
    By anusha2489 in forum C Programming
    Replies: 12
    Last Post: 05-16-2011, 06:58 AM
  3. reading files byte by byte
    By cpsc in forum C++ Programming
    Replies: 12
    Last Post: 01-07-2011, 03:54 PM

Tags for this Thread