Click here to Skip to main content
15,886,067 members
Articles / Desktop Programming / Win32

Simple Serial Port Monitor

Rate me:
Please Sign up or sign in to vote.
4.94/5 (35 votes)
1 May 2012CPOL9 min read 245.3K   52.7K   123  
Very simple serial port monitor.
#pragma once

#include "windows.h"
#include "strsafe.h"
#include "devioctl.h"

#include "..\Inc\Shared.h"

#define DKPORT_NAME_STR		L"\\\\.\\DkPortMon2"

#define DKPORTCLIENT_MAX_STR_LEN	128

class CDkPortClient
{
public:
	DKPORT_DAT			m_Dat;

	CDkPortClient(void);
	~CDkPortClient(void);
	bool Start(TCHAR *pSzDevName);
	bool Stop(void);
	bool IsActive(void);

	void (* OnDataReceived)(void);

private:
	HANDLE				m_hPort;
	bool				m_bReqStop;
	OVERLAPPED			m_RdOvr;
	HANDLE				m_hThread;

	static DWORD GetData(PVOID pDat);

	void TriggerOnDataReceived(void);
};

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
Indonesia Indonesia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions