Developer Application Interface (ARC API) v4.5.8
ARC, Inc. GenIV Application Interface
CArcSystem.h
1// +------------------------------------------------------------------------------------------------------------------+
2// | FILE: CArcSystem.h ( GenIV ) |
3// +------------------------------------------------------------------------------------------------------------------+
4// | PURPOSE: This file defines the class that contains system dependent device driver method calls. |
5// | |
6// | AUTHOR: Scott Streit DATE: June 07, 2021 |
7// | |
8// | Copyright 2021 Astronomical Research Cameras, Inc. All rights reserved. |
9// +------------------------------------------------------------------------------------------------------------------+
12#pragma once
13
14#ifdef _WINDOWS
15
16 #include <windows.h>
17
18#elif defined( __APPLE__ )
19
20 #include <IOKit/IOKitLib.h>
21 #include <ApplicationServices/ApplicationServices.h>
22 #include <IOKit/usb/IOUSBLib.h>
23
24#else
25
26 #include <sys/mman.h>
27 #include <sys/ioctl.h>
28
29#endif
30
31#include <memory>
32
33#include <CArcDeviceDllMain.h>
34#include <CArcBase.h>
35
36
37
38namespace arc
39{
40 namespace gen4
41 {
42
43 // +=========================================================================================================+
44 // | WINDOWS DEFINITIONS |
45 // +=========================================================================================================+
46 #ifdef _WINDOWS
47
48 // +-----------------------------------------------------------------------------------------------------+
49 // | Data Types |
50 // +-----------------------------------------------------------------------------------------------------+
51
53 using arcDevHandle_t = HANDLE;
54
55
56 // +-----------------------------------------------------------------------------------------------------+
57 // | Constants |
58 // +-----------------------------------------------------------------------------------------------------+
59
60 constexpr auto ARC_CTRL_ID = 33460;
61 constexpr auto MAP_FAILED = ( uint8_t* )0;
62 constexpr auto ARC_MAX_PATH = _MAX_PATH;
65 // +=========================================================================================================+
66 // | MAC OS X DEFINITIONS |
67 // +=========================================================================================================+
68 #elif defined( __APPLE__ )
69
70 // +-----------------------------------------------------------------------------------------------------+
71 // | Data Types |
72 // +-----------------------------------------------------------------------------------------------------+
73
74 using arcDevHandle_t = io_connect_t;
75
76
77 // +-----------------------------------------------------------------------------------------------------+
78 // | Constants |
79 // +-----------------------------------------------------------------------------------------------------+
80
81 constexpr auto INVALID_HANDLE_VALUE = IO_OBJECT_NULL;
82 constexpr auto MAX_IOCTL_IN_COUNT = 4;
83 constexpr auto MAX_IOCTL_OUT_COUNT = 2;
84 constexpr auto ARC_MAX_PATH = 512;
85
86 constexpr auto kARC460ClassName = "com_arc_gen4_ARC460";
87
89 enum
90 {
91 kArcOpenUserClient,
92 kArcCloseUserClient,
93 kArcIOCtlUserClient,
94 kArcNumberOfMethods // Must be last
95 };
96
97
98 // +-----------------------------------------------------------------------------------------------------+
99 // | Macros |
100 // +-----------------------------------------------------------------------------------------------------+
101
102 #define MKCMD( cmd ) ( 0x41524300 | cmd )
103
104
105 // +=========================================================================================================+
106 // | LINUX DEFINITIONS |
107 // +=========================================================================================================+
108 #else
109
110 // +-----------------------------------------------------------------------------------------------------+
111 // | Data Types |
112 // +-----------------------------------------------------------------------------------------------------+
113
114 using arcDevHandle_t = int;
115
116
117 // +-----------------------------------------------------------------------------------------------------+
118 // | Constants |
119 // +-----------------------------------------------------------------------------------------------------+
120
121 constexpr auto INVALID_HANDLE_VALUE = int( -1 );
122 constexpr auto ARC_MAX_PATH = 512;
124 constexpr auto DEVICE_DIR = "/dev/";
125 constexpr auto DEVICE_NAME = "Arc460";
128 // +-----------------------------------------------------------------------------------------------------+
129 // | Macros |
130 // +-----------------------------------------------------------------------------------------------------+
131
132 #define MKCMD( cmd ) ( 0x41524300 | cmd )
134 #endif
135
136
137 // +----------------------------------------------------------------------------------------------------------+
138 // | Device Entry Type |
139 // +----------------------------------------------------------------------------------------------------------+
145 struct arcDev_t
146 {
147 std::string sName;
148
149 #ifdef __APPLE__
150 io_service_t tService;
151 #endif
152 };
153
154
155 // +-------------------------------------------------------------------------------------------------------+
156 // | CArcSystem Class |
157 // +-------------------------------------------------------------------------------------------------------+
158
162 class GEN4_CARCDEVICE_API CArcSystem : public CArcBase
163 {
164 public:
165
172 static bool open( arc::gen4::arcDevHandle_t& hDevice, const arcDev_t& tDevice, std::uint64_t uiFlags = 0 ) noexcept;
173
178 static bool close( arc::gen4::arcDevHandle_t& hDevice ) noexcept;
179
186 static bool write( arc::gen4::arcDevHandle_t hDevice, const std::uint8_t* pBuffer, const std::uint32_t uiBufferSize, std::uint32_t* pBytesWritten = nullptr ) noexcept;
187
194 static bool read( arc::gen4::arcDevHandle_t hDevice, std::uint8_t* pBuffer, const std::uint32_t uiBufferSize, std::uint32_t* pBytesRead = nullptr ) noexcept;
195
205 static bool ioctl( arc::gen4::arcDevHandle_t hDevice, const std::uint32_t uiCommand, void* pIn, std::uint32_t uiInSize, void* pOut = nullptr, std::uint32_t uiOutSize = 0 ) noexcept;
206
213 static void* mmap( arc::gen4::arcDevHandle_t hDevice, const std::int32_t iMapCommand, const std::size_t uiSize ) noexcept;
214
221 static bool munmap( arc::gen4::arcDevHandle_t hDevice, const std::int32_t iMapCommand, void* pAddress, const std::size_t uiSize ) noexcept;
222
223 protected:
224
227 CArcSystem( void ) = default;
228
231 ~CArcSystem( void ) = default;
232 };
233
234
235 } // end gen4
236} // end arc
static bool open(arc::gen4::arcDevHandle_t &hDevice, const arcDev_t &tDevice, std::uint64_t uiFlags=0) noexcept
constexpr auto ARC_MAX_PATH
Definition: CArcSystem.h:62
constexpr auto MAP_FAILED
Definition: CArcSystem.h:61
constexpr auto ARC_CTRL_ID
Definition: CArcSystem.h:60
HANDLE arcDevHandle_t
Definition: CArcSystem.h:53
Definition: CArcBase.h:50
std::string sName
Definition: CArcSystem.h:147