Using JQAMv3 Library


This is a quick example on how to use the JQAMv3 library file (libjqam3.dll or libjqam.so.3) to make custom front ends for JQAMv3.

What can be done:
Make programs that use JQAMv3.

What you will need:
A computer running either Linux or Windows.
A C++ compiler.
JQAMv3 header files. (Downloadable from http://wwwjontio.zapto.org/jqam)
libjqam3.dll or libjqam.so.3. (Downloadable from http://wwwjontio.zapto.org/jqam)
Maybe BOOST header files. (for callbacks)
Some minimal C++ programming skills.

My current programming environments are "Eclipse IDE" for C/C++  from non-graphical things, and QT Creator for mainly GUI stuff. Both of these I can recommend, NetBeans is also pretty good. These are only suggestions though, most environments should work.

To start you off, below is about the simplest JQAMv3 application I can think of. All it does is start up a  modem, modulates what you type on the keyboard, and displays what it demodulates to the screen.

//============================================================================
// Name        : JQAMv3Example.cpp
// Author      : Jonti
// Version     : example version 1.0
// Copyright   : copyright Jonti 2010
// Description : JQAMv3 example C++, Ansi-style
//============================================================================

#include "JQAMLibraryloader.h"
#include "JQAMInterface.h"

JQAMInterface* pModem;
using namespace std;

void OnDecoderStatus(SStatus *pSStatus)
{
	string stat(pSStatus->Status);
	if(stat.length()>0) {cout<<stat<<endl;cout.flush();}
}

void OnDecoderPacket(SPacket *pPacket)
{
	if(pPacket->Type_Of_Packet==ptText) {cout<<pPacket->pBuffer;cout.flush();}
}

int main()
{
	cout<< "JQAMv3 modem example"<<endl;
	JQAMLibraryloader jqamll;
	pModem=jqamll.GetpModem();
	if(!pModem){cerr<<"failed to create modem"<<endl;return 1;}

	pModem->SetEnableModulator(true);
	pModem->SetEnableDemodulator(true);

	/* if pointing to class members something like 					*/
	/* pModem->SetOnDecoderStatus( (boost::function <void(SStatus*)>)boost::bind( ( */
	/*				&MainWindow::OnDecoderStatus ),this, _1) );     */
	/* should do 									*/
	pModem->SetOnDecoderStatus(OnDecoderStatus);
	pModem->SetOnDecoderPacket(OnDecoderPacket);

	pModem->Active(true);

	cout<< "Type \"end\" on a new line to exit."<<endl;
	string str;
        do{
        	getline (cin, str);
	        str+="\n";
		if(!pModem->LoadNextBufferPacket((unsigned char*)str.c_str(),str.length(),ptText))
			cerr<<"\nERROR!! Packet overflow\n\n";
	}while(str!="end\n");
	cout << "Finished. Bye."<<endl;
	return 0;
}

One thing to be aware of are the callbacks like OnDecoderStatus, OnDecoderPacket etc. they are separate threads and really the program above should have an event loop and  OnDecoderStatus, OnDecoderPacket etc. should send a message to the event loop and wait for it to be processed by the event loop before returning. Something like connect(this,SIGNAL(StatusSignal(SStatus*)),this,SLOT(myStatusSlot(SStatus*)),Qt::BlockingQueuedConnection); can be used in QT event loops to do this.

Also, remember that libjqam3.dll or libjqam.so.3 must be either in the system path or the directory where the application is.

This is far from complete but it should be enough to get you going.

Jonti Olds
2 March 2010

HOME

Jonti. Last modified Mon, 31 Aug 2015 07:01:49 GMT.