Skip to content

Instantly share code, notes, and snippets.

@aneury1
Created March 17, 2024 23:30
Show Gist options
  • Save aneury1/b92bd69ec3266aa1ae353d984b5d43f5 to your computer and use it in GitHub Desktop.
Save aneury1/b92bd69ec3266aa1ae353d984b5d43f5 to your computer and use it in GitHub Desktop.
pan.cpp
std::string from_pan_to_string(std::string track2){
std::string encoded = "";
uint8_t acc = 0;
bool full = false;
for (uint8_t c : track2)
{
if (!full)
{
acc = c - 0x30;
acc <<= 4;
full = !full;
}
else
{
acc |= c - 0x30;
std::cout
<<std::hex<< unsigned(acc) << " ";
encoded.append(1, acc);
acc = 0;
full = !full;
}
}
return encoded;
}
std::string pan_decoded(std::vector<uint8_t> encoded){
std::string decoded = "";
uint8_t left = 0;
uint8_t right = 0;
for (uint8_t c : encoded)
{
left = c >> 4;
right = c & 0b00001111;
decoded.append(1, left + 0x30);
decoded.append(1, right + 0x30);
}
std::cout << decoded << std::endl;
}
int main(int argc, char *argv[])
{
std::vector<uint8_t> bitmap{
0x00 , 0xee,
0x60 , 0x00 ,0x14 ,0x00 ,0x00 ,
0x01 , 0x00,
0x30 , 0x20 , 0x05 , 0x80 , 0x20 , 0xC0 , 0x02 , 0x24,
0x38 , 0x00 , 0x00,
0x00 , 0x00 , 0x00, 0x00, 0x23, 0x00,
0x00 , 0x00 , 0x04,
0x00 , 0x52 ,
0x00 , 0x14 , 0X00
};
///from_pan_to_string("377881852768074=211120117105576500001");
std::vector<uint8_t>enc
{0x37 ,0x78 ,0x81 ,0x85 ,0x27 ,0x68 ,0x07 ,0x4d ,0x21 ,0x11 ,0x20,0x11 ,0x71 ,0x05 ,0x57 ,0x65 ,0x00 ,0x00 ,0x1f};
pan_decoded(enc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment