Hello everyone, I have just finished drafting a working version of AX25
packet generator and AFSK modulator (baseband for the time being). The
ax25 related code is contained in the ax25.py file, that is far from being
nicely written.
I have tested the resulting audiofile with mixw on windoze and it decodes
ok; tests on the air with the usrp will be prabably run in the we.
Best documentation with code examples I have ever found on 1200 AFSK is here:
http://www.tnc-x.com/dcc.doc
http://www.tnc-x.com/dcc2.doc
thanks to W2FS and TAPR/ARRL
Matteo iz2eeq
#!/usr/bin/env python
mark=-1 #2200
space=1 #1200
symbol=space
out=[]
packet=[]
flag=0
fcs=0
stuff=0
fcslo=0
fcshi=0
def sendzero():
global symbol,mark,space,out
if symbol==space:
sym=mark
else:
sym=space
out.append(sym)
symbol=sym
def sendone():
global symbol,out
out.append(symbol)
def fcsbit(bit):
global fcshi,fcslo
b1=fcshi&0x01
fcshi>>=1
b2=fcslo&0x01
fcslo>>=1
fcslo|=(b1<<7)
if b2 != bit:
fcshi=fcshi^0x84
fcslo=fcslo^0x08
def sendbyte(byte):
global flag,fcs,stuff
for k in range(8):
bt=byte & 0x01
if not fcs and not flag: fcsbit(bt)
if bt==0:
stuff=0
sendzero()
else :
stuff+=1
sendone()
if not flag and stuff==5:
stuff=0
sendzero()
byte>>=1
def dumppacket():
global packet
print "length: %d\n" % len(packet)
for byte in packet:
print "%02x %c" % (byte,byte)
def
buildpacket(source,source_ssid,dest,dest_ssid,digi,digi_ssid,control,pid,payload):
global packet
packet=[]
for j in range(6):
if j<len(dest):
c=ord(dest[j])
packet.append(c<<1)
else:
packet.append(0x40)
packet.append(0x60|(dest_ssid<<1))
for j in range(6):
if j<len(source):
c=ord(source[j])
packet.append(c<<1)
else:
packet.append(0x40)
packet.append(0x60|(source_ssid<<1))
for j in range(6):
if j<len(digi):
c=ord(digi[j])
packet.append(c<<1)
else:
packet.append(0x40)
packet.append(0x60|(digi_ssid<<1)|0x01)
packet.append(control)
packet.append(pid)
for j in range(len(payload)):
packet.append(ord(payload[j]))
def sendpacket():
global packet,out,flag,fcs,stuff,fcslo,fcshi
out=[]
fcslo=0xff
fcshi=0xff
stuff=0
flag=True
fcs=False
#head flags
for i in range(40): sendbyte(0x7e)
flag=False
# print len(packet)
for i in range(len(packet)): sendbyte(packet[i])
fcs=True
fcslo=fcslo^0xff
fcshi=fcshi^0xff
sendbyte(fcslo)
sendbyte(fcshi)
fcs=False
flag=True
#tail flags
for i in range(8): sendbyte(0x7e)
return out
def main():
message=":ALL :this is a test";
buildpacket("IZ2EEQ",1,"CQ",0,"RELAY",0,0x03,0xf0,message)
sendpacket()
# print len(out)
# print out
if __name__ == '__main__':
main()
#!/usr/bin/env python
from gnuradio import gr
from gnuradio import audio_oss
from gnuradio import afsk
from math import pi
from gnuradio.wxgui import stdgui, scopesink
import wx
from ax25 import *
import struct
def main():
sf=48000
mark=1200
space=2200
dev=abs(mark-space)/2
cf=min(mark,space)+dev
bitrate=1200
sens=2*pi*dev/sf
interp=sf/bitrate
message=":ALL :this is a wide test";
buildpacket("IZ2EEQ",1,"CQ",0,"RELAY",0,0x03,0xf0,message)
v=sendpacket()
fg = gr.flow_graph ()
src = gr.vector_source_f(v)
sqv = (1,) * interp
fil = gr.interp_fir_filter_fff(interp, sqv)
mod = gr.frequency_modulator_fc(sens)
lo = gr.sig_source_c(sf, gr.GR_SIN_WAVE, cf, 1)
mix = gr.multiply_cc()
c2r = gr.complex_to_real()
dst0 = gr.file_sink(gr.sizeof_gr_complex,"test.raw")
dst1 = gr.vector_sink_f()
dst2 = audio_oss.sink(sf)
fg.connect(lo,(mix,0))
fg.connect(src,fil,mod,(mix,1))
fg.connect(mix,c2r,dst2)
fg.start()
fg.wait()
# print dst1.data()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio