OROCHI
 
Loading...
Searching...
No Matches
GxDebugCommunication.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13GX_CORE_NAMESPACE_BEGIN()
14
15#if GX_DEVELOP
16
17//===========================================================================
19//===========================================================================
20class GxDebugCommunicationBase : public GxClassBase
21{
22 //-----------------------------------------------------------
24 //-----------------------------------------------------------
26public:
27 // RTTI定義
28 GX_RTTI_ABSTRACT_CLASS(GxDebugCommunicationBase, GxClassBase)
29 // new, delete定義
30 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
31 // GxClassBase継承クラス用禁止宣言
32 GX_PROHIBIT_CLASS_BASE(GxDebugCommunicationBase)
33
34public:
35#if defined(_PS4) || defined(_PS5) || defined(_XBOX_XS)
37 static constexpr u32 PACKET_MAX_SIZE = GxMath::VALUE_1K * 64;
39 static constexpr u32 RECEIVE_MAX_SIZE = PACKET_MAX_SIZE;
40#elif defined(_WINDOWS)
42 static constexpr u32 PACKET_MAX_SIZE = GxMath::VALUE_1K;
44 static constexpr u32 RECEIVE_MAX_SIZE = PACKET_MAX_SIZE;
45#elif defined(_NX64)
47 static constexpr u32 PACKET_MAX_SIZE = GxMath::VALUE_1K * 54; // NX htcs 制限値
49 static constexpr u32 RECEIVE_MAX_SIZE = PACKET_MAX_SIZE;
50#endif // _NX64
51
53 struct GxPacketHeader
54 {
55 u32 _command;
56 u16 _bodySize;
57 u8 _isReply;
58 u8 _padding;
59 };
60
62 typedef void (*PACKET_ANALYSE_CALLBACK)(const GxPacketHeader& header, const void* pBody);
63
65 //-----------------------------------------------------------
67 //-----------------------------------------------------------
69
70public:
72 GxDebugCommunicationBase(void);
74 ~GxDebugCommunicationBase(void);
75
77 virtual b32 initialize(u32 receiveBufferSize = GxDebugCommunicationBase::RECEIVE_MAX_SIZE);
79 virtual void terminate(void);
80
82 //-----------------------------------------------------------
84 //-----------------------------------------------------------
86public:
88 virtual void update(void){}
89
91 virtual b32 send(const void* /*pData*/ = nullptr, u32 /*size*/ = 0, b32 /*isOutputTrace*/ = true){ return false; }
92
94 static u16 getNetworkToPlatform(u16 value);
96 static s16 getNetworkToPlatform(s16 value);
98 static u32 getNetworkToPlatform(u32 value);
100 static s32 getNetworkToPlatform(s32 value);
102 static u64 getNetworkToPlatform(u64 value);
104 static s64 getNetworkToPlatform(s64 value);
106 static f32 getNetworkToPlatform(f32 value);
108 static f64 getNetworkToPlatform(f64 value);
109
111 static u16 getPlatformToNetwork(u16 value);
113 static s16 getPlatformToNetwork(s16 value);
115 static u32 getPlatformToNetwork(u32 value);
117 static s32 getPlatformToNetwork(s32 value);
119 static u64 getPlatformToNetwork(u64 value);
121 static s64 getPlatformToNetwork(s64 value);
123 static f32 getPlatformToNetwork(f32 value);
125 static f64 getPlatformToNetwork(f64 value);
126
128 //-----------------------------------------------------------
130 //-----------------------------------------------------------
132public:
134 b32 isConnected(void) const { return _isConnected; }
136 constexpr void setAnalyseCallback(PACKET_ANALYSE_CALLBACK callback) { _pAnalyseCallback = callback; }
137
139 //-----------------------------------------------------------
141 //-----------------------------------------------------------
143protected:
144 static GxCriticalSection _criticalSection;
145 GX_STR _receiveBuffer;
146 b32 _isConnected;
147 PACKET_ANALYSE_CALLBACK _pAnalyseCallback;
148 u32 _receiveBufferSize;
149
151};
152
153#if defined(_WINDOWS) || defined(_XBOX_XS)
154//===========================================================================
156//===========================================================================
157class GxDebugCommunicationPC : public GxDebugCommunicationBase
158{
159 //-----------------------------------------------------------
161 //-----------------------------------------------------------
163public:
164 // RTTI定義
165 GX_RTTI_CLASS(GxDebugCommunicationPC, GxDebugCommunicationBase)
166 // GxClassBase継承クラス用禁止宣言
167 GX_PROHIBIT_CLASS_BASE(GxDebugCommunicationPC);
168
169private:
171 static constexpr u16 COMMUNICATION_PORT = 5631;
172
174 class GxReceiveThread : public GxThread
175 {
176 //-----------------------------------------------------------
178 //-----------------------------------------------------------
180 public:
182 void threadMain(void* pArgument) override;
183 private:
185 static s32 receive(SOCKET& socket, void* pData, s32 size);
186
188 };
189
191 //-----------------------------------------------------------
193 //-----------------------------------------------------------
195public:
197 GxDebugCommunicationPC(void);
198
200 b32 initialize(u32 receiveBufferSize = GxDebugCommunicationBase::RECEIVE_MAX_SIZE) override;
202 void terminate(void) override;
203
205 //-----------------------------------------------------------
207 //-----------------------------------------------------------
209public:
211 b32 send(const void* pData, u32 size, b32 isOutputTrace = true) override;
212
214 //-----------------------------------------------------------
216 //-----------------------------------------------------------
218private:
219 GxReceiveThread* _pReceiveThread;
220 b32 _isStopRequestThread;
221 SOCKET _server;
222 SOCKET _socket;
223
225};
226
227#elif defined(_PS4) || defined(_PS5)
228//===========================================================================
230//===========================================================================
231class GxDebugCommunicationPS : public GxDebugCommunicationBase
232{
233 //-----------------------------------------------------------
235 //-----------------------------------------------------------
237public:
238 // RTTI定義
239 GX_RTTI_CLASS(GxDebugCommunicationPS, GxDebugCommunicationBase)
240 // GxClassBase継承クラス用禁止宣言
241 GX_PROHIBIT_CLASS_BASE(GxDebugCommunicationPS);
242
243private:
245 static constexpr u16 COMMUNICATION_PORT = 5631;
246
248 class GxReceiveThread : public GxThread
249 {
250 //-----------------------------------------------------------
252 //-----------------------------------------------------------
254 public:
256 void threadMain(void* pArgument) override;
257 private:
259 static s32 receive(GxNativeNetworkId& socket, void* pData, s32 size);
260
262 };
263
265 //-----------------------------------------------------------
267 //-----------------------------------------------------------
269public:
271 GxDebugCommunicationPS(void);
272
274 b32 initialize(u32 receiveBufferSize = GxDebugCommunicationBase::RECEIVE_MAX_SIZE) override;
276 void terminate(void) override;
277
279 //-----------------------------------------------------------
281 //-----------------------------------------------------------
283public:
285 b32 send(const void* pData, u32 size, b32 isOutputTrace = true) override;
286private:
288 static void closeConnection(GxNativeNetworkId sid );
289
291 static s32 controlAddSocket(GxNativeNetworkId eid, GxNativeNetworkId sid, GxNativeNetworkEvent* pEvent );
292
294 static s32 controlDeleteSocket(GxNativeNetworkId eid, GxNativeNetworkId sid );
295
297 static s32 doAccept(GxNativeNetworkId eid, GxNativeNetworkEvent* pEvent );
298
300 static s32 doReceive(GxNativeNetworkId eid, GxNativeNetworkEvent* pEvent, void* pData, s32 dataSize, s32 receiveFlags = 0 );
301
303 //-----------------------------------------------------------
305 //-----------------------------------------------------------
307private:
308 GxReceiveThread* _pReceiveThread;
309 b32 _isStopRequestThread;
310 GxNativeNetworkId _server;
311 GxNativeNetworkId _socket;
312 GxNativeNetworkId _epollId;
313
315};
316
317#elif defined(_NX64)
318//===========================================================================
320//===========================================================================
321class GxDebugCommunicationNX : public GxDebugCommunicationBase
322{
323 //-----------------------------------------------------------
325 //-----------------------------------------------------------
327public:
328 // RTTI定義
329 GX_RTTI_CLASS(GxDebugCommunicationNX, GxDebugCommunicationBase)
330 // GxClassBase継承クラス用禁止宣言
331 GX_PROHIBIT_CLASS_BASE(GxDebugCommunicationNX);
332
333private:
335 static GX_CSTR COMMUNICATION_NAME;
337 static constexpr s32 INVALID_ID = (-1);
338
340 class GxReceiveThread : public GxThread
341 {
342 //-----------------------------------------------------------
344 //-----------------------------------------------------------
346 public:
348 void threadMain(void* pArgument) override;
349
351 };
352
354 //-----------------------------------------------------------
356 //-----------------------------------------------------------
358
359public:
361 GxDebugCommunicationNX(void);
362
364 b32 initialize(u32 receiveBufferSize = GxDebugCommunicationBase::RECEIVE_MAX_SIZE) override;
366 void terminate(void) override;
367
369 //-----------------------------------------------------------
371 //-----------------------------------------------------------
373public:
375 b32 send(const void* pData, u32 size, b32 isOutputTrace = true) override;
376private:
378 void HtcsSocketErrorOutput(s32 id);
379
381 //-----------------------------------------------------------
383 //-----------------------------------------------------------
385
386private:
387 GxReceiveThread* _pReceiveThread;
388 b32 _isStopRequestThread;
389 s32 _server;
390 s32 _socket;
391
393};
394
395#endif // _NX64
396
397#endif // GX_DEVELOP
398
399GX_CORE_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
pThis threadMain(pThis->_pIn)
オブジェクト基底クラス
Definition GxBase.h:88
クリティカルセクションクラス
Definition GxThread.h:20
static constexpr u32 VALUE_1K
1K
Definition GxMath.h:129
スレッドクラス
Definition GxThread.h:177
32bitブーリアン
Definition GxDefine.h:173