the old reader gives me this for example: 0x30, 0x31, 0x30, 0x39, 0x36, 0x38, 0x32, 0x44, 0x43, 0x36.
10 bytes and on my lcd-display it gives me: 0109682DC6.
the new reader gives me this instead: 0x01, 0x09, 0x68, 0x2D, 0xC6
which are only 5 bytes, but as you can see, it are the same numbers. again it is: 0109682DC6.
my problem is, i need the numbers to be as i got them from the first reader.
this is because i send them to an other device which expects them that way and i dont have the opportunity to change that.
for the letters i had to add 40 but i have no idea how to detect when i need to add 30 and when i need to add 40.
(testspeicher3[4] & 0x0f) or ((testspeicher3[4] & 0xf0 ) >> 4 ) will be between 0 and 9 or between a and f. If the value is between 0 and 9, add 0x30. If it is between a and f, add 0x40.
Your best bet would be to store each nibble in a temporary variable, manipulate that temporary variable, and then store the modified temporary variable into the destination variable.
the old reader gives me this for example: 0x30, 0x31, 0x30, 0x39, 0x36, 0x38, 0x32, 0x44, 0x43, 0x36.
10 bytes and on my lcd-display it gives me: 0109682DC6.
the new reader gives me this instead: 0x01, 0x09, 0x68, 0x2D, 0xC6
The first is giving a string of ASCII characters representing the code.
The second is giving the numeric value of the code in hexadecimal.
Just "print" the new value as hex and it will result in the old value:
if (test_speicher[b]<16){
lcd.print("0");
lcd.print( (byte)test_speicher[b],HEX);
}
else lcd.print( (byte)test_speicher[b],HEX);
}
now i dont get 01096846**0ffffff**8f, but i still get 01096846**0**8f instead of 010968468f.
one zero to much.
Same problem, but further up. You're comparing a signed value with 16, and if it's lower then put a 0 - the same 7th bit of 0x8f that caused the fffff to appear is making it a negative number, so it will be less than 16.
It would be better to use a byte array not a char array right from the start.