Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
BY70-1 AX.25 command generator
#!/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'

This comment has been minimized.

Copy link

paunstefan commented Jan 22, 2019

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.