aivdmtable 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python
  2. #
  3. # Generate an asciidoc table of the six-bit encoding used in AIVDM packets.
  4. #
  5. # This file is Copyright (c) 2010-2019 by the GPSD project
  6. # BSD terms apply: see the file COPYING in the distribution root for details.
  7. #
  8. # This code runs compatibly under Python 2 and 3.x for x >= 2.
  9. # Preserve this property!
  10. from __future__ import absolute_import, print_function, division
  11. sixbits = (
  12. "000000", "000001", "000010", "000011", "000100",
  13. "000101", "000110", "000111", "001000", "001001",
  14. "001010", "001011", "001100", "001101", "001110",
  15. "001111", "010000", "010001", "010010", "010011",
  16. "010100", "010101", "010110", "010111", "011000",
  17. "011001", "011010", "011011", "011100", "011101",
  18. "011110", "011111", "100000", "100001", "100010",
  19. "100011", "100100", "100101", "100110", "100111",
  20. "101000", "101001", "101010", "101011", "101100",
  21. "101101", "101110", "101111", "110000", "110001",
  22. "110010", "110011", "110100", "110101", "110110",
  23. "110111", "111000", "111001", "111010", "111011",
  24. "111100", "111101", "111110", "111111",
  25. )
  26. def asciiarmor():
  27. print("`--------`-------`---------`-------")
  28. print(" Char ASCII Decimal Bits")
  29. for ch in list(range(ord('0'), ord('W')+1)) + list(range(ord('`'),
  30. ord('w')+1)):
  31. n = ch - 48
  32. if n >= 40:
  33. n -= 8
  34. print('"%s" %3d %3d %s' % (chr(ch), ch, n, sixbits[n]))
  35. print("---------------------------------------")
  36. if __name__ == "__main__":
  37. asciiarmor()