Skip to content

Commit

Permalink
Merge pull request #56 from jontio/dev-zmq
Browse files Browse the repository at this point in the history
Dev zmq
  • Loading branch information
jontio authored Jul 30, 2021
2 parents 246f2cb + 8c7ec7e commit 2837bbb
Show file tree
Hide file tree
Showing 30 changed files with 1,005 additions and 286 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
msystem: MINGW64
update: true
install: git mingw-w64-x86_64-toolchain autoconf libtool mingw-w64-x86_64-cpputest mingw-w64-x86_64-qt5 mingw-w64-x86_64-cmake mingw-w64-x86_64-libvorbis zip p7zip unzip
install: git mingw-w64-x86_64-toolchain autoconf libtool mingw-w64-x86_64-cpputest mingw-w64-x86_64-qt5 mingw-w64-x86_64-cmake mingw-w64-x86_64-libvorbis mingw-w64-x86_64-zeromq zip p7zip unzip
# build for windows
- name: Windows-CI-Build
if: ${{ matrix.os == 'windows-latest' }}
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
.qmake.cache
.qmake.stash

# qtcreator generated files
*.pro.user*
Expand Down
18 changes: 12 additions & 6 deletions JAERO/JAERO.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#if you are having trubbles focus on things like "LIBS += -L$$OGG_PATH/src/.libs"
#remember to compile libvorbis,libogg, and libcorrect before compiling this

DEFINES += JAERO_VERSION=\\\"v1.0.4.12-alpha\\\"
DEFINES += JAERO_VERSION=\\\"v1.0.4.13-alpha\\\"

QT += multimedia core network gui svg sql

Expand Down Expand Up @@ -85,7 +85,10 @@ SOURCES += mainwindow.cpp \
$$JFFT_PATH/jfft.cpp \
util/stdio_utils.cpp \
util/file_utils.cpp \
util/RuntimeError.cpp
util/RuntimeError.cpp \
zmq_audiosender.cpp \
zmq_audioreceiver.cpp


HEADERS += mainwindow.h \
coarsefreqestimate.h \
Expand Down Expand Up @@ -119,17 +122,20 @@ HEADERS += mainwindow.h \
$$JFFT_PATH/jfft.h \
util/stdio_utils.h \
util/file_utils.h \
util/RuntimeError.h
util/RuntimeError.h \
zmq_audioreceiver.h \
zmq_audiosender.h


# Tell the qcustomplot header that it will be used as library:
DEFINES += QCUSTOMPLOT_USE_LIBRARY
#qcustom plot is called different names on different systems
win32 {
#message("windows")
LIBS += -lqcustomplot2
LIBS += -lqcustomplot2 -llibzmq
} else {
#message("not windows")
LIBS += -lqcustomplot
LIBS += -lqcustomplot -lzmq
}

FORMS += mainwindow.ui \
Expand Down Expand Up @@ -159,7 +165,7 @@ QMAKE_CXXFLAGS_RELEASE += -O3
#QMAKE_CXXFLAGS_RELEASE *= -O3

#for static building order seems to matter
LIBS += -lcorrect -lvorbis -lvorbisenc -logg -lacars
LIBS += -lcorrect -lvorbis -lvorbisenc -logg -lacars

#desktop
desktop.path = /usr/share/applications
Expand Down
38 changes: 31 additions & 7 deletions JAERO/aerol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1407,8 +1407,6 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit

uchar SEQINDICATOR=((byte1&0xF0)>>4);
uchar SUTYPE=byte1&0x0F;
uchar QNO=((byte2&0xF0)>>4);
uchar REFNO=byte2&0x07;
quint32 AESID=byte3<<8*2|byte4<<8*1|byte5<<8*0;
int GES=byte6;

Expand Down Expand Up @@ -1446,8 +1444,6 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit

int BytesInSU=0;
if((SUTYPE>=1)&&(SUTYPE<=11))BytesInSU=SUTYPE;
bool SignalingInfoSU=false;
if(SUTYPE==15)SignalingInfoSU=true;

decline+=((QString)" SU %1 of %2. AES: %3 GES: %4").arg(SUindex+1).arg(SUTotal).arg((((QString)"%1").arg(AESID,6, 16, QChar('0'))).toUpper()).arg((((QString)"%1").arg(GES,2, 16, QChar('0'))).toUpper()) ;
/*decline+=" \"";
Expand Down Expand Up @@ -1735,6 +1731,10 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit
break;
case Log_on_confirm:
decline+="Log_on_confirm";

{
SendLogOnOff(k, "Log on confirm");
}
break;
case Log_control_P_channel_log_off_request:
decline+="Log_control_P_channel_log_off_request";
Expand Down Expand Up @@ -2166,9 +2166,21 @@ void AeroL::SendCAssignment(int k, QString decline)
QString beam = " Global Beam ";
if(byte7&0x80)beam=" Spot Beam ";

item.message = "Receive Freq: " + receive + beam + "Transmit " + transmit + "\r\n" + decline;
emit ACARSsignal(item);
}
void AeroL::SendLogOnOff(int k, QString text)
{
ACARSItem item;
item.isuitem.AESID=((uchar)infofield[k*12-1+2])<<8*2|((uchar)infofield[k*12-1+3])<<8*1|((uchar)infofield[k*12-1+4])<<8*0;
item.isuitem.GESID=infofield[k*12-1+5];

item.hastext = true;
item.downlink = true;
item.nonacars = true;
item.valid = true;

item.message = "Receive Freq: " + receive + beam + "Transmit " + transmit + "\r\n" + decline;
item.message = text;
emit ACARSsignal(item);
}

Expand All @@ -2182,6 +2194,8 @@ QByteArray &AeroL::DecodeC(QVector<short> &bits)
quint16 bit=0;
quint16 soft_bit=0;

QString hex = "000000";

for(int i=0;i<bits.size();i++)
{

Expand Down Expand Up @@ -2394,6 +2408,14 @@ QByteArray &AeroL::DecodeC(QVector<short> &bits)
decline+=" GES = "+infofield.mid(4,1).toHex().toUpper();
decline+=" Call_progress \r\n";
emit Call_progress_Signal(infofield);

QString thex = infofield.mid(1,3).toHex().toUpper();

if(thex.length() == 6)
{
hex = thex;
}

}
break;

Expand Down Expand Up @@ -2457,13 +2479,15 @@ QByteArray &AeroL::DecodeC(QVector<short> &bits)
}
}

// send for external decoding
emit Voicesignal(data, hex);

//25 primary fields. this is where the audio lives in a compressed format
for(int i=0;i<25;i++)
{
emit Voicesignal(data.mid(i*12,12));//send one frame at a time
emit Voicesignal(data.mid(i*12,12));//send one frame at a time
}


// reset for next block
index = -1;
}// end of frame
Expand Down
58 changes: 41 additions & 17 deletions JAERO/aerol.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,26 +397,47 @@ class AeroLScrambler
public:
AeroLScrambler()
{
reset();
}
void reset()
{
QVector<int> state;
position=0;
pre_state.resize(5000);
int tmp[]={1,1,0,1,0,0,1,0,1,0,1,1,0,0,1,-1};
state.clear();
for(int i=0;tmp[i]>=0;i++)state.push_back(tmp[i]);


// populate the vector so we can reuse it
for(int a = 0; a<5000;a++)
{

int val0 = state.at(0)^state.at(14);
pre_state[a]=val0;
for(int i=state.size()-1;i>0;i--)
{
state[i]=state.at(i-1);
}
state[0] =val0;

}
}

void update(QVector<int> &data)
{
for(int j=0;j<data.size();j++)
{
int val0=state.at(0)^state.at(14);
data[j] = data.at(j)^val0;
for(int i=state.size()-1;i>0;i--)state[i]=state.at(i-1);
state[0]=val0;
data[j] = data.at(j)^pre_state.at(position);
position++;
}

}
void reset()
{

position = 0;
}
private:
QVector<int> state;

QVector<int> pre_state;
int position;
};

class PuncturedCode
Expand Down Expand Up @@ -626,7 +647,7 @@ class RTChannelDeleaveFECScram
bool cont = false;


if((((blockptr-(64*5))%(64*3))==0) && (blockptr /64 == 5 || blockptr /64 == targetBlocks || blockptr/64 == 8 || blockptr/64 == 50))
if((((blockptr-(64*5))%(64*3))==0) && (blockptr /64 == 5 || blockptr /64 == targetBlocks || blockptr/64 == 11 || blockptr/64 == 50))
{
cont = true;
}
Expand Down Expand Up @@ -666,6 +687,10 @@ class RTChannelDeleaveFECScram
lastpacketstate=OK_R_Packet;

return OK_R_Packet;
}else{

return Nothing;

}
}

Expand All @@ -682,11 +707,7 @@ class RTChannelDeleaveFECScram
else
{

if(blockptr/64 ==5){
return Nothing;
}

if(blockptr/64 == 8){
if(blockptr/64 == 11){

// we should be able to peek at the SU after the initial SU and figure out the number of SU's in this
// burst
Expand All @@ -703,15 +724,15 @@ class RTChannelDeleaveFECScram

}

targetBlocks = (targetSUSize*3) +2;
targetBlocks = ((targetSUSize+1)*3) +2;

return Nothing;
}

// this should be the target blocks for this T packet
if(blockptr/64 == targetBlocks)
{
for(int i=0;i<targetSUSize;i++)
for(int i=0;i<targetSUSize-3;i++)
{
crcok=crc16.calcusingbitsandcheck(deconvol.data()+(8*6)+(8*12)*i,8*12);

Expand Down Expand Up @@ -890,6 +911,7 @@ class AeroL : public QIODevice
void DataCarrierDetect(bool status);
void ACARSsignal(ACARSItem &acarsitem);
void Errorsignal(QString &error);
void Voicesignal(QByteArray &data, QString &hex);
void Voicesignal(const QByteArray &data);
void CChannelAssignmentSignal(CChannelAssignmentItem &item);
void Call_progress_Signal(QByteArray infofield);
Expand All @@ -915,6 +937,8 @@ public slots:
bool Start();
void Stop();
void SendCAssignment(int k, QString decline);
void SendLogOnOff(int k, QString text);

CChannelAssignmentItem CreateCAssignmentItem(QByteArray su);
QByteArray &Decode(QVector<short> &bits, bool soft = false);
QByteArray &DecodeC(QVector<short> &bits);
Expand Down
11 changes: 7 additions & 4 deletions JAERO/audioburstmskdemodulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
#include <QDebug>

AudioBurstMskDemodulator::AudioBurstMskDemodulator(QObject *parent)
: BurstMskDemodulator(parent),
m_audioInput(NULL)
: BurstMskDemodulator(parent),
m_audioInput(NULL)
{
//
//
}

void AudioBurstMskDemodulator::start()
{
BurstMskDemodulator::start();
if(m_audioInput)m_audioInput->start(this);
if(!settings.zmqAudio)
{
if(m_audioInput)m_audioInput->start(this);
}
}

void AudioBurstMskDemodulator::stop()
Expand Down
11 changes: 7 additions & 4 deletions JAERO/audioburstoqpskdemodulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <QDebug>

AudioBurstOqpskDemodulator::AudioBurstOqpskDemodulator(QObject *parent)
: BurstOqpskDemodulator(parent),
m_audioInput(NULL)
: BurstOqpskDemodulator(parent),
m_audioInput(NULL)
{
demod2=new BurstOqpskDemodulator(this);
demod2->channel_select_other=true;
Expand All @@ -15,7 +15,10 @@ void AudioBurstOqpskDemodulator::start()
{
BurstOqpskDemodulator::start();
demod2->start();
if(m_audioInput)m_audioInput->start(this);
if(!settings.zmqAudio)
{
if(m_audioInput)m_audioInput->start(this);
}
}

void AudioBurstOqpskDemodulator::stop()
Expand All @@ -40,7 +43,7 @@ void AudioBurstOqpskDemodulator::setSettings(Settings _settings)
//set the format
m_format.setSampleRate(settings.Fs);
if(settings.channel_stereo)m_format.setChannelCount(2);
else m_format.setChannelCount(1);
else m_format.setChannelCount(1);
m_format.setSampleSize(16);
m_format.setCodec("audio/pcm");
m_format.setByteOrder(QAudioFormat::LittleEndian);
Expand Down
11 changes: 7 additions & 4 deletions JAERO/audiomskdemodulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
#include <QDebug>

AudioMskDemodulator::AudioMskDemodulator(QObject *parent)
: MskDemodulator(parent),
m_audioInput(NULL)
: MskDemodulator(parent),
m_audioInput(NULL)
{
//
//
}

void AudioMskDemodulator::start()
{
MskDemodulator::start();
if(m_audioInput)m_audioInput->start(this);
if(!settings.zmqAudio)
{
if(m_audioInput)m_audioInput->start(this);
}
}

void AudioMskDemodulator::stop()
Expand Down
13 changes: 9 additions & 4 deletions JAERO/audiooqpskdemodulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
#include <QDebug>

AudioOqpskDemodulator::AudioOqpskDemodulator(QObject *parent)
: OqpskDemodulator(parent),
m_audioInput(NULL)
: OqpskDemodulator(parent),
m_audioInput(NULL)
{
//
//
}

void AudioOqpskDemodulator::start()
{
OqpskDemodulator::start();
if(m_audioInput)m_audioInput->start(this);

if(!settings.zmqAudio)
{
if(m_audioInput)m_audioInput->start(this);
}

}

void AudioOqpskDemodulator::stop()
Expand Down
Loading

0 comments on commit 2837bbb

Please sign in to comment.