Created
January 6, 2017 20:58
-
-
Save daniestevez/1718a74d248e2ed755cb9e8f964a43df to your computer and use it in GitHub Desktop.
BY70-1 AX.25 command generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import binascii | |
import sys | |
def ax25call(callsign): | |
s = callsign.split('-') | |
call = s[0].upper()[:6] | |
call = call + ' '*(6-len(call)) | |
ssid = 0 if len(s) == 1 else int(s[1]) | |
c = bytes(map(lambda c: c << 1, bytes(call, 'ascii'))) | |
ss = bytes([0x60 | (ssid & 0xf) << 1 ]) | |
return c + ss | |
dst = ax25call(sys.argv[1]) | |
src = ax25call(sys.argv[2]) | |
cmd = binascii.a2b_hex(sys.argv[3].replace(' ', '')) | |
packet = dst + src[:-1] + bytes([src[-1] | 1]) + b'\x03\xf0' + cmd | |
kiss = b'\xc0\x00' + packet.replace(b'\xdb', b'\xdb\xdd').replace(b'\xc0', b'\xdb\xdc') + b'\xc0' | |
sys.stdout.buffer.write(kiss) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was looking over your article because I want to build my own program that sends AX.25 frames. I have some questions about this code. On line 11, why are you left shifting the ASCII characters ? What is the operation on line 12 supposed to do ?
Also, where can I find more information about the KISS and AX.25 specification so I can build something like this ?