Click here to Skip to main content
15,886,038 members
Articles / Programming Languages / C++

3G Modem Internet Dialer

Rate me:
Please Sign up or sign in to vote.
4.90/5 (88 votes)
13 Jul 2011CPOL7 min read 773.8K   65.9K   192  
3G Modem Internet Dialer
#pragma once
#include <queue>

class CModem;

class CSerial
{
public:
	CSerial();
	virtual ~CSerial(void);

	void Close(void);
	void ShutDown(void);
	void AddToWriteQueue(std::string sBuffer);
	void ExecuteNextCommand(void);

	BOOL Open(CString szPort);
	BOOL StartThreads(void);
	BOOL Initialize(CModem* pmodem);
	BOOL SetPortSettings(void);

private:

	static UINT ReaderThread(LPVOID pParam);
	static UINT WriterThread(LPVOID pParam);

	struct CommandItem 
	{
		std::string sATCommand; 
		int iNumberOfRetry;
	};

	BOOL m_bIsOpen;

	CModem *m_pModem;

	HANDLE  m_hCOMPort;
	HANDLE m_pReaderThread;
	HANDLE m_pWriteThread;

	CCriticalSection m_cs;

	DCB originaldcb;

	OVERLAPPED m_oReaderThreadExit; 
	OVERLAPPED m_oWriterThreadExit;
	OVERLAPPED m_oWriteNextCommandInQueue;

	COMMTIMEOUTS originalcommtimeouts;

	std::queue<CommandItem> m_qCommandsQueue;

};

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I love coding with C++. I always split my free time between coding and gaming Smile | :)

Comments and Discussions