Compare commits
3 Commits
207273236d
...
94c0d7e670
Author | SHA1 | Date |
---|---|---|
Imbis | 94c0d7e670 | 6 months ago |
Imbis | efb86b3cb5 | 6 months ago |
Imbis | 32b27345d6 | 6 months ago |
@ -1 +1,5 @@
|
||||
Project/Objects
|
||||
Window Tool/TimeSet/.vs/TimeSet/v15/ipch
|
||||
*.db
|
||||
*.zip
|
||||
Window Tool/TimeSet/TimeSet/Debug
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,367 @@
|
||||
// Serial.h - Definition of the CSerial 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_H
|
||||
#define __SERIAL_H
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// The SERIAL_DEFAULT_OVERLAPPED defines if the default open mode uses
|
||||
// overlapped I/O. When overlapped I/O is available (normal Win32
|
||||
// platforms) it uses overlapped I/O. Windows CE doesn't allow the use
|
||||
// of overlapped I/O, so it is disabled there by default.
|
||||
|
||||
#ifndef SERIAL_DEFAULT_OVERLAPPED
|
||||
#ifndef SERIAL_NO_OVERLAPPED
|
||||
#define SERIAL_DEFAULT_OVERLAPPED true
|
||||
#else
|
||||
#define SERIAL_DEFAULT_OVERLAPPED false
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CSerial - Win32 wrapper for serial communications
|
||||
//
|
||||
// Serial communication often causes a lot of problems. This class
|
||||
// tries to supply an easy to use interface to deal with serial
|
||||
// devices.
|
||||
//
|
||||
// The class is actually pretty ease to use. You only need to open
|
||||
// the COM-port, where you need to specify the basic serial
|
||||
// communication parameters. You can also choose to setup handshaking
|
||||
// and read timeout behaviour.
|
||||
//
|
||||
// The following serial classes are available:
|
||||
//
|
||||
// CSerial - Serial communication support.
|
||||
// CSerialEx - Serial communication with listener thread for events
|
||||
// CSerialSync - Serial communication with synchronized event handler
|
||||
// CSerialWnd - Asynchronous serial support, which uses the Win32
|
||||
// message queue for event notification.
|
||||
// CSerialMFC - Preferred class to use in MFC-based GUI windows.
|
||||
//
|
||||
//
|
||||
// Pros:
|
||||
// -----
|
||||
// - Easy to use (hides a lot of nasty Win32 stuff)
|
||||
// - Fully ANSI and Unicode aware
|
||||
//
|
||||
// Cons:
|
||||
// -----
|
||||
// - Little less flexibility then native Win32 API, however you can
|
||||
// use this API at the same time for features which are missing
|
||||
// from this class.
|
||||
// - Incompatible with Windows 95 or Windows NT v3.51 (or earlier),
|
||||
// because CancelIo isn't support on these platforms. Define the
|
||||
// SERIAL_NO_CANCELIO macro for support of these platforms as
|
||||
// well. When this macro is defined, then only time-out values of
|
||||
// 0 or INFINITE are valid.
|
||||
//
|
||||
//
|
||||
// Copyright (C) 1999-2003 Ramon de Klein
|
||||
// (Ramon.de.Klein@ict.nl)
|
||||
|
||||
class CSerial
|
||||
{
|
||||
// Class enumerations
|
||||
public:
|
||||
// Communication event
|
||||
typedef enum
|
||||
{
|
||||
EEventUnknown = -1, // Unknown event
|
||||
EEventNone = 0, // Event trigged without cause
|
||||
EEventBreak = EV_BREAK, // A break was detected on input
|
||||
EEventCTS = EV_CTS, // The CTS signal changed state
|
||||
EEventDSR = EV_DSR, // The DSR signal changed state
|
||||
EEventError = EV_ERR, // A line-status error occurred
|
||||
EEventRing = EV_RING, // A ring indicator was detected
|
||||
EEventRLSD = EV_RLSD, // The RLSD signal changed state
|
||||
EEventRecv = EV_RXCHAR, // Data is received on input
|
||||
EEventRcvEv = EV_RXFLAG, // Event character was received on input
|
||||
EEventSend = EV_TXEMPTY, // Last character on output was sent
|
||||
EEventPrinterError = EV_PERR, // Printer error occured
|
||||
EEventRx80Full = EV_RX80FULL, // Receive buffer is 80 percent full
|
||||
EEventProviderEvt1 = EV_EVENT1, // Provider specific event 1
|
||||
EEventProviderEvt2 = EV_EVENT2, // Provider specific event 2
|
||||
}
|
||||
EEvent;
|
||||
|
||||
// Baudrate
|
||||
typedef enum
|
||||
{
|
||||
EBaudUnknown = -1, // Unknown
|
||||
EBaud110 = CBR_110, // 110 bits/sec
|
||||
EBaud300 = CBR_300, // 300 bits/sec
|
||||
EBaud600 = CBR_600, // 600 bits/sec
|
||||
EBaud1200 = CBR_1200, // 1200 bits/sec
|
||||
EBaud2400 = CBR_2400, // 2400 bits/sec
|
||||
EBaud4800 = CBR_4800, // 4800 bits/sec
|
||||
EBaud9600 = CBR_9600, // 9600 bits/sec
|
||||
EBaud14400 = CBR_14400, // 14400 bits/sec
|
||||
EBaud19200 = CBR_19200, // 19200 bits/sec (default)
|
||||
EBaud38400 = CBR_38400, // 38400 bits/sec
|
||||
EBaud56000 = CBR_56000, // 56000 bits/sec
|
||||
EBaud57600 = CBR_57600, // 57600 bits/sec
|
||||
EBaud115200 = CBR_115200, // 115200 bits/sec
|
||||
EBaud128000 = CBR_128000, // 128000 bits/sec
|
||||
EBaud256000 = CBR_256000, // 256000 bits/sec
|
||||
}
|
||||
EBaudrate;
|
||||
|
||||
// Data bits (5-8)
|
||||
typedef enum
|
||||
{
|
||||
EDataUnknown = -1, // Unknown
|
||||
EData5 = 5, // 5 bits per byte
|
||||
EData6 = 6, // 6 bits per byte
|
||||
EData7 = 7, // 7 bits per byte
|
||||
EData8 = 8 // 8 bits per byte (default)
|
||||
}
|
||||
EDataBits;
|
||||
|
||||
// Parity scheme
|
||||
typedef enum
|
||||
{
|
||||
EParUnknown = -1, // Unknown
|
||||
EParNone = NOPARITY, // No parity (default)
|
||||
EParOdd = ODDPARITY, // Odd parity
|
||||
EParEven = EVENPARITY, // Even parity
|
||||
EParMark = MARKPARITY, // Mark parity
|
||||
EParSpace = SPACEPARITY // Space parity
|
||||
}
|
||||
EParity;
|
||||
|
||||
// Stop bits
|
||||
typedef enum
|
||||
{
|
||||
EStopUnknown = -1, // Unknown
|
||||
EStop1 = ONESTOPBIT, // 1 stopbit (default)
|
||||
EStop1_5 = ONE5STOPBITS,// 1.5 stopbit
|
||||
EStop2 = TWOSTOPBITS // 2 stopbits
|
||||
}
|
||||
EStopBits;
|
||||
|
||||
// Handshaking
|
||||
typedef enum
|
||||
{
|
||||
EHandshakeUnknown = -1, // Unknown
|
||||
EHandshakeOff = 0, // No handshaking
|
||||
EHandshakeHardware = 1, // Hardware handshaking (RTS/CTS)
|
||||
EHandshakeSoftware = 2 // Software handshaking (XON/XOFF)
|
||||
}
|
||||
EHandshake;
|
||||
|
||||
// Timeout settings
|
||||
typedef enum
|
||||
{
|
||||
EReadTimeoutUnknown = -1, // Unknown
|
||||
EReadTimeoutNonblocking = 0, // Always return immediately
|
||||
EReadTimeoutBlocking = 1 // Block until everything is retrieved
|
||||
}
|
||||
EReadTimeout;
|
||||
|
||||
// Communication errors
|
||||
typedef enum
|
||||
{
|
||||
EErrorUnknown = 0, // Unknown
|
||||
EErrorBreak = CE_BREAK, // Break condition detected
|
||||
EErrorFrame = CE_FRAME, // Framing error
|
||||
EErrorIOE = CE_IOE, // I/O device error
|
||||
EErrorMode = CE_MODE, // Unsupported mode
|
||||
EErrorOverrun = CE_OVERRUN, // Character buffer overrun, next byte is lost
|
||||
EErrorRxOver = CE_RXOVER, // Input buffer overflow, byte lost
|
||||
EErrorParity = CE_RXPARITY,// Input parity error
|
||||
EErrorTxFull = CE_TXFULL // Output buffer full
|
||||
}
|
||||
EError;
|
||||
|
||||
// Port availability
|
||||
typedef enum
|
||||
{
|
||||
EPortUnknownError = -1, // Unknown error occurred
|
||||
EPortAvailable = 0, // Port is available
|
||||
EPortNotAvailable = 1, // Port is not present
|
||||
EPortInUse = 2 // Port is in use
|
||||
|
||||
}
|
||||
EPort;
|
||||
|
||||
// Construction
|
||||
public:
|
||||
CSerial();
|
||||
virtual ~CSerial();
|
||||
|
||||
// Operations
|
||||
public:
|
||||
// Check if particular COM-port is available (static method).
|
||||
static EPort CheckPort (LPCTSTR lpszDevice);
|
||||
|
||||
// Open the serial communications for a particular COM port. You
|
||||
// need to use the full devicename (i.e. "COM1") to open the port.
|
||||
// It's possible to specify the size of the input/output queues.
|
||||
virtual LONG Open (LPCTSTR lpszDevice, DWORD dwInQueue = 0, DWORD dwOutQueue = 0, bool fOverlapped = SERIAL_DEFAULT_OVERLAPPED);
|
||||
|
||||
// Close the serial port.
|
||||
virtual LONG Close (void);
|
||||
|
||||
// Setup the communication settings such as baudrate, databits,
|
||||
// parity and stopbits. The default settings are applied when the
|
||||
// device has been opened. Call this function if these settings do
|
||||
// not apply for your application. If you prefer to use integers
|
||||
// instead of the enumerated types then just cast the integer to
|
||||
// the required type. So the following two initializations are
|
||||
// equivalent:
|
||||
//
|
||||
// Setup(EBaud9600,EData8,EParNone,EStop1)
|
||||
//
|
||||
// or
|
||||
//
|
||||
// Setup(EBaudrate(9600),EDataBits(8),EParity(NOPARITY),EStopBits(ONESTOPBIT))
|
||||
//
|
||||
// In the latter case, the types are not validated. So make sure
|
||||
// that you specify the appropriate values.
|
||||
virtual LONG Setup (EBaudrate eBaudrate = EBaud9600,
|
||||
EDataBits eDataBits = EData8,
|
||||
EParity eParity = EParNone,
|
||||
EStopBits eStopBits = EStop1);
|
||||
|
||||
// Set/clear the event character. When this byte is being received
|
||||
// on the serial port then the EEventRcvEv event is signalled,
|
||||
// when the mask has been set appropriately. If the fAdjustMask flag
|
||||
// has been set, then the event mask is automatically adjusted.
|
||||
virtual LONG SetEventChar (BYTE bEventChar, bool fAdjustMask = true);
|
||||
|
||||
// Set the event mask, which indicates what events should be
|
||||
// monitored. The WaitEvent method can only monitor events that
|
||||
// have been enabled. The default setting only monitors the
|
||||
// error events and data events. An application may choose to
|
||||
// monitor CTS. DSR, RLSD, etc as well.
|
||||
virtual LONG SetMask (DWORD dwMask = EEventBreak|EEventError|EEventRecv);
|
||||
|
||||
// The WaitEvent method waits for one of the events that are
|
||||
// enabled (see SetMask).
|
||||
virtual LONG WaitEvent (LPOVERLAPPED lpOverlapped = 0, DWORD dwTimeout = INFINITE);
|
||||
|
||||
// Setup the handshaking protocol. There are three forms of
|
||||
// handshaking:
|
||||
//
|
||||
// 1) No handshaking, so data is always send even if the receiver
|
||||
// cannot handle the data anymore. This can lead to data loss,
|
||||
// when the sender is able to transmit data faster then the
|
||||
// receiver can handle.
|
||||
// 2) Hardware handshaking, where the RTS/CTS lines are used to
|
||||
// indicate if data can be sent. This mode requires that both
|
||||
// ports and the cable support hardware handshaking. Hardware
|
||||
// handshaking is the most reliable and efficient form of
|
||||
// handshaking available, but is hardware dependant.
|
||||
// 3) Software handshaking, where the XON/XOFF characters are used
|
||||
// to throttle the data. A major drawback of this method is that
|
||||
// these characters cannot be used for data anymore.
|
||||
virtual LONG SetupHandshaking (EHandshake eHandshake);
|
||||
|
||||
// Read operations can be blocking or non-blocking. You can use
|
||||
// this method to setup wether to use blocking or non-blocking
|
||||
// reads. Non-blocking reads is the default, which is required
|
||||
// for most applications.
|
||||
//
|
||||
// 1) Blocking reads, which will cause the 'Read' method to block
|
||||
// until the requested number of bytes have been read. This is
|
||||
// useful if you know how many data you will receive.
|
||||
// 2) Non-blocking reads, which will read as many bytes into your
|
||||
// buffer and returns almost immediately. This is often the
|
||||
// preferred setting.
|
||||
virtual LONG SetupReadTimeouts (EReadTimeout eReadTimeout);
|
||||
|
||||
// Obtain communication settings
|
||||
virtual EBaudrate GetBaudrate (void);
|
||||
virtual EDataBits GetDataBits (void);
|
||||
virtual EParity GetParity (void);
|
||||
virtual EStopBits GetStopBits (void);
|
||||
virtual EHandshake GetHandshaking (void);
|
||||
virtual DWORD GetEventMask (void);
|
||||
virtual BYTE GetEventChar (void);
|
||||
|
||||
// Write data to the serial port. Note that we are only able to
|
||||
// send ANSI strings, because it probably doesn't make sense to
|
||||
// transmit Unicode strings to an application.
|
||||
virtual LONG Write (const void* pData, size_t iLen, DWORD* pdwWritten = 0, LPOVERLAPPED lpOverlapped = 0, DWORD dwTimeout = INFINITE);
|
||||
virtual LONG Write (LPCSTR pString, DWORD* pdwWritten = 0, LPOVERLAPPED lpOverlapped = 0, DWORD dwTimeout = INFINITE);
|
||||
|
||||
// Read data from the serial port. Refer to the description of
|
||||
// the 'SetupReadTimeouts' for an explanation about (non) blocking
|
||||
// reads and how to use this.
|
||||
virtual LONG Read (void* pData, size_t iLen, DWORD* pdwRead = 0, LPOVERLAPPED lpOverlapped = 0, DWORD dwTimeout = INFINITE);
|
||||
|
||||
// Send a break
|
||||
LONG Break (void);
|
||||
|
||||
// Determine what caused the event to trigger
|
||||
EEvent GetEventType (void);
|
||||
|
||||
// Obtain the error
|
||||
EError GetError (void);
|
||||
|
||||
// Obtain the COMM and event handle
|
||||
HANDLE GetCommHandle (void) { return m_hFile; }
|
||||
|
||||
// Check if com-port is opened
|
||||
bool IsOpen (void) const { return (m_hFile != 0); }
|
||||
|
||||
// Obtain last error status
|
||||
LONG GetLastError (void) const { return m_lLastError; }
|
||||
|
||||
// Obtain CTS/DSR/RING/RLSD settings
|
||||
bool GetCTS (void);
|
||||
bool GetDSR (void);
|
||||
bool GetRing (void);
|
||||
bool GetRLSD (void);
|
||||
|
||||
// Purge all buffers
|
||||
LONG Purge (void);
|
||||
|
||||
protected:
|
||||
// Internal helper class which wraps DCB structure
|
||||
class CDCB : public DCB
|
||||
{
|
||||
public:
|
||||
CDCB() { DCBlength = sizeof(DCB); }
|
||||
};
|
||||
|
||||
// Attributes
|
||||
protected:
|
||||
LONG m_lLastError; // Last serial error
|
||||
HANDLE m_hFile; // File handle
|
||||
EEvent m_eEvent; // Event type
|
||||
DWORD m_dwEventMask; // Event mask
|
||||
|
||||
#ifndef SERIAL_NO_OVERLAPPED
|
||||
HANDLE m_hevtOverlapped; // Event handle for internal overlapped operations
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// Check the requirements
|
||||
void CheckRequirements (LPOVERLAPPED lpOverlapped, DWORD dwTimeout) const;
|
||||
|
||||
// CancelIo wrapper (for Win95 compatibility)
|
||||
BOOL CancelCommIo (void);
|
||||
};
|
||||
|
||||
#endif // __SERIAL_H
|
@ -0,0 +1,277 @@
|
||||
// SerialEx.cpp - Implementation of the CSerialEx 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
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Include the standard header files
|
||||
|
||||
|
||||
#include <crtdbg.h>
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Include module headerfile
|
||||
#include "pch.h"
|
||||
#include "SerialEx.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Disable warning C4127: conditional expression is constant, which
|
||||
// is generated when using the _RPTF and _ASSERTE macros.
|
||||
|
||||
#pragma warning(disable: 4127)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Enable debug memory manager
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#ifdef THIS_FILE
|
||||
#undef THIS_FILE
|
||||
#endif
|
||||
|
||||
static const char THIS_FILE[] = __FILE__;
|
||||
#define new DEBUG_NEW
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Code
|
||||
|
||||
CSerialEx::CSerialEx()
|
||||
: m_fStopping(false)
|
||||
, m_hThread(0)
|
||||
#ifndef SERIAL_NO_OVERLAPPED
|
||||
, m_hevtOverlappedWorkerThread(0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
CSerialEx::~CSerialEx()
|
||||
{
|
||||
// Check if the thread handle is still there. If so, then we
|
||||
// didn't close the serial port. We cannot depend on the
|
||||
// CSerial destructor, because if it calls Close then it
|
||||
// won't call our overridden Close.
|
||||
if (m_hThread)
|
||||
{
|
||||
// Display a warning
|
||||
_RPTF0(_CRT_WARN, "CSerialEx::~CSerialEx - Serial port not closed\n");
|
||||
|
||||
// Close implicitly
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
LONG CSerialEx::Open (LPCTSTR lpszDevice, DWORD dwInQueue, DWORD dwOutQueue, bool fStartListener)
|
||||
{
|
||||
// Call the base class first
|
||||
long lLastError = CSerial::Open(lpszDevice,dwInQueue,dwOutQueue,SERIAL_DEFAULT_OVERLAPPED);
|
||||
if (lLastError != ERROR_SUCCESS)
|
||||
return lLastError;
|
||||
|
||||
#ifndef SERIAL_NO_OVERLAPPED
|
||||
// Create an event that is used for the workerthread. The globally
|
||||
// used event is used by the main-thread and cannot be reused
|
||||
// for this thread.
|
||||
m_hevtOverlappedWorkerThread = ::CreateEvent(0,true,false,0);
|
||||
if (m_hevtOverlappedWorkerThread == 0)
|
||||
{
|
||||
// Obtain the error information
|
||||
m_lLastError = ::GetLastError();
|
||||
_RPTF0(_CRT_WARN,"CSerialEx::Open - Unable to create event\n");
|
||||
|
||||
// Close the serial port again
|
||||
CSerial::Close();
|
||||
|
||||
// Return the error
|
||||
return m_lLastError;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Start the listener thread (only on request)
|
||||
if (fStartListener)
|
||||
{
|
||||
lLastError = StartListener();
|
||||
if (lLastError != ERROR_SUCCESS)
|
||||
return lLastError;
|
||||
}
|
||||
|
||||
// Return the error
|
||||
return m_lLastError;
|
||||
}
|
||||
|
||||
LONG CSerialEx::Close (void)
|
||||
{
|
||||
// Stop listener thread (wait until it ends)
|
||||
//StopListener(INFINITE);
|
||||
StopListener(100);
|
||||
|
||||
#ifndef SERIAL_NO_OVERLAPPED
|
||||
// Free event handle
|
||||
if (m_hevtOverlappedWorkerThread)
|
||||
{
|
||||
::CloseHandle(m_hevtOverlappedWorkerThread);
|
||||
m_hevtOverlappedWorkerThread = 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// Call the base class
|
||||
return CSerial::Close();
|
||||
}
|
||||
|
||||
LONG CSerialEx::StartListener (void)
|
||||
{
|
||||
// Check if the watcher thread was already running
|
||||
if (m_hThread == 0)
|
||||
{
|
||||
// Make sure the thread has stopped
|
||||
_ASSERTE(!m_fStopping);
|
||||
|
||||
// Start the watcher thread
|
||||
DWORD dwThreadId = 0;
|
||||
m_hThread = ::CreateThread(0,0,ThreadProc,LPVOID(this),0,&dwThreadId);
|
||||
if (m_hThread == 0)
|
||||
{
|
||||
// Display a warning
|
||||
_RPTF0(_CRT_WARN, "CSerialEx::StartListener - Unable to start COMM watcher thread\n");
|
||||
|
||||
// Set the error code and exit
|
||||
m_lLastError = ::GetLastError();
|
||||
return m_lLastError;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the error
|
||||
m_lLastError = ERROR_SUCCESS;
|
||||
return m_lLastError;
|
||||
}
|
||||
|
||||
LONG CSerialEx::StopListener (DWORD dwTimeout)
|
||||
{
|
||||
// Check if the thread is running
|
||||
if (m_hThread)
|
||||
{
|
||||
// Set the flag that the thread must be stopped
|
||||
m_fStopping = true;
|
||||
|
||||
// Cancel the pending WaitEvent, but we won't do this using
|
||||
// CancelIo. This would break Win95 compatibility and some
|
||||
// USB serial dongles cannot handle CancelIo correctly. By
|
||||
// setting the event mask again, the call will also be
|
||||
// completed before the thread exits.
|
||||
SetMask(GetEventMask());
|
||||
|
||||
// Wait until the watcher thread has stopped
|
||||
::WaitForSingleObject(m_hThread,dwTimeout);
|
||||
|
||||
// The thread has stopped
|
||||
m_fStopping = false;
|
||||
|
||||
// Close handle to the thread
|
||||
::CloseHandle(m_hThread);
|
||||
m_hThread = 0;
|
||||
}
|
||||
|
||||
// Return the error
|
||||
m_lLastError = ERROR_SUCCESS;
|
||||
return m_lLastError;
|
||||
}
|
||||
|
||||
DWORD WINAPI CSerialEx::ThreadProc (LPVOID lpArg)
|
||||
{
|
||||
// Route the method to the actual object
|
||||
CSerialEx* pThis = reinterpret_cast<CSerialEx*>(lpArg);
|
||||
return pThis->ThreadProc();
|
||||
}
|
||||
|
||||
DWORD CSerialEx::ThreadProc (void)
|
||||
{
|
||||
// Use overlapped structure
|
||||
LPOVERLAPPED lpOverlapped = 0;
|
||||
|
||||
// Keep looping
|
||||
do
|
||||
{
|
||||
#ifndef SERIAL_NO_OVERLAPPED
|
||||
// Reset the event handle
|
||||
::ResetEvent(m_hevtOverlappedWorkerThread);
|
||||
|
||||
// Initialize the overlapped structure
|
||||
OVERLAPPED ovInternal = {0};
|
||||
ovInternal.hEvent = m_hevtOverlappedWorkerThread;
|
||||
|
||||
// Start the WaitEvent (use our own overlapped structure)
|
||||
if (WaitEvent(&ovInternal) != ERROR_SUCCESS)
|
||||
return m_lLastError;
|
||||
|
||||
// Wait for the overlapped operation to complete
|
||||
if (::WaitForSingleObject(m_hevtOverlappedWorkerThread,INFINITE) != WAIT_OBJECT_0)
|
||||
{
|
||||
// Set the internal error code
|
||||
m_lLastError = ::GetLastError();
|
||||
|
||||
// Issue an error and quit
|
||||
_RPTF0(_CRT_WARN,"CSerialEx::ThreadProc - Unable to wait until COM event has arrived\n");
|
||||
return m_lLastError;
|
||||
}
|
||||
#else
|
||||
// Start the WaitEvent (don't need to specify an overlapped structure)
|
||||
if (WaitEvent() != ERROR_SUCCESS)
|
||||
return m_lLastError;
|
||||
#endif
|
||||
|
||||
// Wait until one of the events happens
|
||||
if (!m_fStopping)
|
||||
{
|
||||
// Determine the event
|
||||
EEvent eEvent = GetEventType();
|
||||
|
||||
// Obtain the error status during this event
|
||||
DWORD dwErrors = 0;
|
||||
if (!::ClearCommError(m_hFile,&dwErrors,0))
|
||||
{
|
||||
// Set the internal error code
|
||||
m_lLastError = ::GetLastError();
|
||||
|
||||
// Issue an error and quit
|
||||
_RPTF0(_CRT_WARN, "CSerialEx::ThreadProc - Unable to obtain COM status\n");
|
||||
}
|
||||
|
||||
// Convert the error
|
||||
EError eError = EError(dwErrors);
|
||||
|
||||
// There was a COMM event, which needs handling. We'll call the
|
||||
// event handler. We can receive a "zero" event, when the
|
||||
// mask or event character has been set. We won't pass this
|
||||
// down to the window.
|
||||
if (eEvent)
|
||||
OnEvent(eEvent,eError);
|
||||
}
|
||||
}
|
||||
while (!m_fStopping);
|
||||
|
||||
// Bye bye
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
// SerialEx.h - Definition of the CSerialEx 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_EX_H
|
||||
#define __SERIAL_EX_H
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Include CSerial base class
|
||||
|
||||
#include "Serial.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CSerialEx - Win32 message-based wrapper for serial communications
|
||||
//
|
||||
// A lot of MS-Windows GUI based programs use a central message
|
||||
// loop, so the application cannot block to wait for objects. This
|
||||
// make serial communication difficult, because it isn't event
|
||||
// driven using a message queue. This class makes the CSerial based
|
||||
// classes suitable for use with such a messagequeue. Whenever
|
||||
// an event occurs on the serial port, a user-defined message will
|
||||
// be sent to a user-defined window. It can then use the standard
|
||||
// message dispatching to handle the event.
|
||||
//
|
||||
// Pros:
|
||||
// -----
|
||||
// - Easy to use
|
||||
// - Fully ANSI and Unicode aware
|
||||
// - Integrates easily in GUI applications and is intuitive to
|
||||
// use for GUI application programmers
|
||||
//
|
||||
// Cons:
|
||||
// -----
|
||||
// - Uses a thread for each COM-port, which has been opened.
|
||||
// - More overhead, due to thread switching and message queues.
|
||||
// - Requires a window, but that's probably why you're using
|
||||
// this class.
|
||||
//
|
||||
// Copyright (C) 1999-2003 Ramon de Klein
|
||||
// (Ramon.de.Klein@ict.nl)
|
||||
|
||||
class CSerialEx : public CSerial
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CSerialEx();
|
||||
virtual ~CSerialEx();
|
||||
|
||||
// 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, DWORD dwInQueue = 0, DWORD dwOutQueue = 0, bool fStartListener = false);
|
||||
|
||||
// Close the serial port.
|
||||
virtual LONG Close (void);
|
||||
|
||||
// Start the listener thread
|
||||
virtual LONG StartListener (void);
|
||||
|
||||
// Stop the listener thread. Because the other thread might be
|
||||
// busy processing data it might take a while, so you can specify
|
||||
// a time-out.
|
||||
virtual LONG StopListener (DWORD dwTimeout = INFINITE);
|
||||
|
||||
protected:
|
||||
// Each opened COM-port uses its own specific thread, which will
|
||||
// wait for one of the events to happen. When an event happens,
|
||||
// then the client window is send a message informing about the
|
||||
// event.
|
||||
static DWORD WINAPI ThreadProc (LPVOID lpArg);
|
||||
DWORD ThreadProc (void);
|
||||
|
||||
// Event handler
|
||||
virtual void OnEvent (EEvent eEvent, EError eError) = 0;
|
||||
|
||||
protected:
|
||||
// The WaitEvent method is being used by this class internally
|
||||
// and shouldn't be used by client applications. Client
|
||||
// application should monior the messages.
|
||||
using CSerial::WaitEvent;
|
||||
|
||||
// The event-type is send in the WPARAM of the message and
|
||||
// the GetEventType method returns the wrong data, so we'll
|
||||
// hide this method for client applications to avoid problems.
|
||||
using CSerial::GetEventType;
|
||||
using CSerial::GetError;
|
||||
|
||||
protected:
|
||||
// Internal attributes
|
||||
bool m_fStopping;
|
||||
HANDLE m_hThread;
|
||||
|
||||
#ifndef SERIAL_NO_OVERLAPPED
|
||||
// Handle for overlapped operations in worker-thread
|
||||
HANDLE m_hevtOverlappedWorkerThread;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // __SERIAL_EX_H
|
@ -0,0 +1,135 @@
|
||||
// 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)
|
||||
{
|
||||
|
||||
CString strTemp = _T("\\\\.\\");
|
||||
strTemp += lpszDevice;
|
||||
return CSerialWnd::Open(strTemp.GetBuffer(0), pwndDest->GetSafeHwnd(), nComMsg, lParam, dwInQueue, dwOutQueue);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//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
|
@ -0,0 +1,131 @@
|
||||
// SerialWnd.cpp - Implementation of the CSerialWnd 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
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Include the standard header files
|
||||
|
||||
|
||||
#include "pch.h"
|
||||
#include <crtdbg.h>
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Include module headerfile
|
||||
|
||||
#include "SerialWnd.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Disable warning C4127: conditional expression is constant, which
|
||||
// is generated when using the _RPTF and _ASSERTE macros.
|
||||
|
||||
#pragma warning(disable: 4127)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Enable debug memory manager
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#ifdef THIS_FILE
|
||||
#undef THIS_FILE
|
||||
#endif
|
||||
|
||||
static const char THIS_FILE[] = __FILE__;
|
||||
#define new DEBUG_NEW
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Code
|
||||
|
||||
// Register the standard CSerialWnd COM message
|
||||
const UINT CSerialWnd::mg_nDefaultComMsg = ::RegisterWindowMessage(_T("CSerialWnd_DefaultComMsg"));
|
||||
|
||||
|
||||
CSerialWnd::CSerialWnd()
|
||||
: m_hwndDest(0)
|
||||
, m_nComMsg(WM_NULL)
|
||||
, m_lParam(0)
|
||||
{
|
||||
}
|
||||
|
||||
CSerialWnd::~CSerialWnd()
|
||||
{
|
||||
// Check if the thread handle is still there. If so, then we
|
||||
// didn't close the serial port. We cannot depend on the
|
||||
// CSerial destructor, because if it calls Close then it
|
||||
// won't call our overridden Close.
|
||||
if (m_hThread)
|
||||
{
|
||||
// Display a warning
|
||||
_RPTF0(_CRT_WARN, "CSerialWnd::~CSerialWnd - Serial port not closed\n");
|
||||
|
||||
// Close implicitly
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
LONG CSerialWnd::Open (LPCTSTR lpszDevice, HWND hwndDest, UINT nComMsg, LPARAM lParam, DWORD dwInQueue, DWORD dwOutQueue)
|
||||
{
|
||||
// Call the base class first
|
||||
long lLastError = CSerialEx::Open(lpszDevice,dwInQueue,dwOutQueue);
|
||||
if (lLastError != ERROR_SUCCESS)
|
||||
return lLastError;
|
||||
|
||||
// Save the window handle, notification message and user message
|
||||
m_hwndDest = hwndDest;
|
||||
m_nComMsg = nComMsg?nComMsg:mg_nDefaultComMsg;
|
||||
m_lParam = lParam;
|
||||
|
||||
// Start the listener thread
|
||||
lLastError = StartListener();
|
||||
if (lLastError != ERROR_SUCCESS)
|
||||
{
|
||||
// Close the serial port
|
||||
Close();
|
||||
|
||||
// Return the error-code
|
||||
m_lLastError = lLastError;
|
||||
return m_lLastError;
|
||||
}
|
||||
|
||||
// Return the error
|
||||
m_lLastError = ERROR_SUCCESS;
|
||||
return m_lLastError;
|
||||
}
|
||||
|
||||
LONG CSerialWnd::Close (void)
|
||||
{
|
||||
// Reset all members
|
||||
m_hwndDest = 0;
|
||||
m_nComMsg = WM_NULL;
|
||||
|
||||
// Call the base class
|
||||
return CSerialEx::Close();
|
||||
}
|
||||
|
||||
void CSerialWnd::OnEvent (EEvent eEvent, EError eError)
|
||||
{
|
||||
// Post message to the client window
|
||||
::PostMessage(m_hwndDest,m_nComMsg,MAKEWPARAM(eEvent,eError),LPARAM(m_lParam));
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
// SerialWnd.h - Definition of the CSerialWnd 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_WND_H
|
||||
#define __SERIAL_WND_H
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Include CSerialEx base class
|
||||
|
||||
#include "SerialEx.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CSerialWnd - Win32 message-based wrapper for serial communications
|
||||
//
|
||||
// A lot of MS-Windows GUI based programs use a central message
|
||||
// loop, so the application cannot block to wait for objects. This
|
||||
// make serial communication difficult, because it isn't event
|
||||
// driven using a message queue. This class makes the CSerial based
|
||||
// classes suitable for use with such a messagequeue. Whenever
|
||||
// an event occurs on the serial port, a user-defined message will
|
||||
// be sent to a user-defined window. It can then use the standard
|
||||
// message dispatching to handle the event.
|
||||
//
|
||||
// Pros:
|
||||
// -----
|
||||
// - Easy to use
|
||||
// - Fully ANSI and Unicode aware
|
||||
// - Integrates easily in GUI applications and is intuitive to
|
||||
// use for GUI application programmers
|
||||
//
|
||||
// Cons:
|
||||
// -----
|
||||
// - Uses a thread for each COM-port, which has been opened.
|
||||
// - More overhead, due to thread switching and message queues.
|
||||
// - Requires a window, but that's probably why you're using
|
||||
// this class.
|
||||
//
|
||||
// Copyright (C) 1999-2003 Ramon de Klein
|
||||
// (Ramon.de.Klein@ict.nl)
|
||||
|
||||
class CSerialWnd : public CSerialEx
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CSerialWnd();
|
||||
virtual ~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, HWND hwndDest, UINT nComMsg=WM_NULL, LPARAM lParam=0, DWORD dwInQueue = 0, DWORD dwOutQueue = 0);
|
||||
|
||||
// Close the serial port.
|
||||
virtual LONG Close (void);
|
||||
|
||||
protected:
|
||||
// Event handler that is called when
|
||||
virtual void OnEvent (EEvent eEvent, EError eError);
|
||||
|
||||
public:
|
||||
// Default Serial notification message
|
||||
static const UINT mg_nDefaultComMsg;
|
||||
|
||||
protected:
|
||||
// Internal attributes
|
||||
HWND m_hwndDest;
|
||||
UINT m_nComMsg;
|
||||
LONG m_lParam;
|
||||
};
|
||||
|
||||
#endif // __SERIAL_WND_H
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,226 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{12662F45-5722-45B9-8C02-2863C436C1F6}</ProjectGuid>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
<RootNamespace>TimeSet</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<ValidateAllParameters>true</ValidateAllParameters>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0412</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<ValidateAllParameters>true</ValidateAllParameters>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0412</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<ValidateAllParameters>true</ValidateAllParameters>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0412</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<ValidateAllParameters>true</ValidateAllParameters>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0412</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="Serial.h" />
|
||||
<ClInclude Include="SerialEx.h" />
|
||||
<ClInclude Include="SerialMFC.h" />
|
||||
<ClInclude Include="SerialWnd.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="TimeSet.h" />
|
||||
<ClInclude Include="TimeSetDlg.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Serial.cpp" />
|
||||
<ClCompile Include="SerialEx.cpp" />
|
||||
<ClCompile Include="SerialWnd.cpp" />
|
||||
<ClCompile Include="TimeSet.cpp" />
|
||||
<ClCompile Include="TimeSetDlg.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="TimeSet.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\TimeSet.rc2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\TimeSet.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="소스 파일">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="헤더 파일">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="리소스 파일">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="TimeSet.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TimeSetDlg.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Serial.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SerialEx.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SerialMFC.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SerialWnd.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="TimeSet.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TimeSetDlg.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Serial.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SerialEx.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SerialWnd.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="TimeSet.rc">
|
||||
<Filter>리소스 파일</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\TimeSet.rc2">
|
||||
<Filter>리소스 파일</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\TimeSet.ico">
|
||||
<Filter>리소스 파일</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<RESOURCE_FILE>TimeSet.rc</RESOURCE_FILE>
|
||||
</PropertyGroup>
|
||||
</Project>
|
After Width: | Height: | Size: 66 KiB |
Binary file not shown.
Loading…
Reference in new issue