1 | /* $Id: hmcomm.cpp,v 1.4 2000-02-16 14:23:58 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
5 | *
|
---|
6 | * Win32 COM device access class
|
---|
7 | *
|
---|
8 | * 1999 Achim Hasenmueller <achimha@innotek.de>
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 | #include <odin.h>
|
---|
13 | #include <win32type.h>
|
---|
14 | #include <misc.h>
|
---|
15 | #include "handlemanager.h"
|
---|
16 | #include "hmdevice.h"
|
---|
17 | #include "hmcomm.h"
|
---|
18 | #include "oslibdos.h"
|
---|
19 |
|
---|
20 | #define DBG_LOCALLOG DBG_hmcomm
|
---|
21 | #include "dbglocal.h"
|
---|
22 |
|
---|
23 |
|
---|
24 | HMDeviceCommClass::HMDeviceCommClass(LPCSTR lpDeviceName) : HMDeviceHandler(lpDeviceName)
|
---|
25 | {
|
---|
26 | dprintf(("HMDeviceCommClass: Register COM1 to COM4 with Handle Manager\n"));
|
---|
27 | HMDeviceRegister("COM1", this);
|
---|
28 | HMDeviceRegister("COM2", this);
|
---|
29 | HMDeviceRegister("COM3", this);
|
---|
30 | HMDeviceRegister("COM4", this);
|
---|
31 | HMDeviceRegister("COM5", this);
|
---|
32 | HMDeviceRegister("COM6", this);
|
---|
33 | HMDeviceRegister("COM7", this);
|
---|
34 | HMDeviceRegister("COM8", this);
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | DWORD HMDeviceCommClass::CreateFile(LPCSTR lpFileName,
|
---|
40 | PHMHANDLEDATA pHMHandleData,
|
---|
41 | PVOID lpSecurityAttributes,
|
---|
42 | PHMHANDLEDATA pHMHandleDataTemplate)
|
---|
43 | {
|
---|
44 | dprintf(("HMComm: Serial communication port %s open request\n", lpFileName));
|
---|
45 |
|
---|
46 | pHMHandleData->hHMHandle = 0;
|
---|
47 |
|
---|
48 | //AH: TODO parse Win32 security handles
|
---|
49 | OSLibDosDisableHardError(TRUE);
|
---|
50 | pHMHandleData->hHMHandle = OSLibDosOpen((char*)lpFileName,
|
---|
51 | OSLIB_ACCESS_READWRITE |
|
---|
52 | OSLIB_ACCESS_SHAREDENYREAD |
|
---|
53 | OSLIB_ACCESS_SHAREDENYWRITE);
|
---|
54 | OSLibDosDisableHardError(FALSE);
|
---|
55 | if (pHMHandleData->hHMHandle != 0)
|
---|
56 | return 0;
|
---|
57 | else
|
---|
58 | return -1;
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | /* this is a handler method for calls to CloseHandle() */
|
---|
63 | DWORD HMDeviceCommClass::CloseHandle(PHMHANDLEDATA pHMHandleData)
|
---|
64 | {
|
---|
65 | dprintf(("HMComm: Serial communication port close request\n"));
|
---|
66 | return OSLibDosClose(pHMHandleData->hHMHandle);
|
---|
67 | }
|
---|
68 |
|
---|
69 | /*****************************************************************************
|
---|
70 | * Name : DWORD HMDeviceHandler::SetupComm
|
---|
71 | * Purpose : set com port parameters (queue)
|
---|
72 | * Variables :
|
---|
73 | * Result :
|
---|
74 | * Remark :
|
---|
75 | * Status :
|
---|
76 | *
|
---|
77 | * Author : Achim Hasenmueller
|
---|
78 | *****************************************************************************/
|
---|
79 |
|
---|
80 | BOOL HMDeviceCommClass::SetupComm(PHMHANDLEDATA pHMHandleData, DWORD dwInQueue, DWORD dwOutQueue)
|
---|
81 | {
|
---|
82 | dprintf(("HMDeviceCommClass::SetupComm unimplemented stub!"));
|
---|
83 |
|
---|
84 |
|
---|
85 | return(TRUE);
|
---|
86 | }
|
---|