Click here to Skip to main content
15,892,059 members
Articles / Programming Languages / C++

POCSAG Encoder

Rate me:
Please Sign up or sign in to vote.
4.65/5 (10 votes)
23 Feb 20068 min read 121.8K   4.7K   19  
The article is about encoding a text message for pagers using POCSAG encoder.
//	SerialMFC.h - Definition of the CSerialMFC class
//
//	Copyright (C) 1999-2003 Ramon de Klein (Ramon.de.Klein@ict.nl)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


#ifndef __SERIAL_MFC_H
#define __SERIAL_MFC_H


//////////////////////////////////////////////////////////////////////
// Include CSerialWnd base class

#include "SerialWnd.h"


//////////////////////////////////////////////////////////////////////
// Make sure that MFC is already loaded
//
// We don't include it here, because MFC based applications typically
// use a precompiled header file.

#ifndef __AFXWIN_H__
#error "CWnd class isn't included (include AFXWIN.H)"
#endif


//////////////////////////////////////////////////////////////////////
//
// CSerialMFC - MFC wrapper for serial communication handling
//
// CSerialMFC is a very thing wrapper around the CSerialWnd class,
// which makes it more suitable for use in MFC-based applications.
// Unfortenately, the MFC framework isn't very flexible when it comes
// to adding custom message handlers. We cannot add our own types to
// the message handlers, but we're stuck to use 32-bit integers.
//
// Add the following entry to the window's message map to make sure
// that MFC calls your handler, when a serial message comes in.
//
//      DECLARE_MESSAGE_MAP(CMyClass,CWnd)
//          ...
//          ON_WM_SERIAL(OnSerialMsg)
//          ...
//     END_MESSAGE_MAP()
//
// A typical handler could look like this:
//
//     afx_msg LRESULT CMyClass::OnSerialMsg (WPARAM wParam, LPARAM lParam)
//     {
//         CSerial::EEvent eEvent = CSerial::EEvent(LOWORD(wParam));
//         CSerial::EError eError = CSerial::EError(HIWORD(wParam));
//
//         // lParam: User-defined 32-bit integer (type LPARAM)
//         switch (eEvent)
//         {
//         case CSerialMFC::EEventRecv:
//             // TODO: Read data from the port
//             break;
//         ...
//         }
//         
//         // Return successful
//         return 0;
//     }
//
//
// Pros:
// -----
//	- Easy to use
//	- Fully ANSI and Unicode aware
//  - Integrates seamless in MFC applications
//
// Cons:
// -----
//  - No more then CSerialWnd, except that you need MFC
//
// Copyright (C) 1999-2003 Ramon de Klein
//                         (Ramon.de.Klein@ict.nl)

class CSerialMFC : public CSerialWnd
{
// Operations
public:
	// Open the serial communications for a particular COM port. You
	// need to use the full devicename (i.e. "COM1") to open the port.
	virtual LONG Open (LPCTSTR lpszDevice, CWnd* pwndDest, UINT nComMsg = WM_NULL, LPARAM lParam = 0, DWORD dwInQueue = 0, DWORD dwOutQueue = 0)
	{ 
		return CSerialWnd::Open(lpszDevice,pwndDest->GetSafeHwnd(),nComMsg,lParam,dwInQueue,dwOutQueue); 
	}
};


//////////////////////////////////////////////////////////////////////
// Message map macro for the default COM message

#define ON_WM_SERIAL(memberFxn)	\
	ON_REGISTERED_MESSAGE(CSerialMFC::mg_nDefaultComMsg,memberFxn)


//////////////////////////////////////////////////////////////////////
// Don't link to the default runtime libraries, because this will
// give a warning during link-time.

#ifdef _DEBUG
#pragma comment(linker,"/nodefaultlib:LIBCD")
#else
#pragma comment(linker,"/nodefaultlib:LIBC")
#endif


#endif	// __SERIAL_MFC_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Solaris Electronics LLC
United Arab Emirates United Arab Emirates
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acquisition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competition, my articles are:


You can see list of my articles, by clicking here


Comments and Discussions