Nebula
Loading...
Searching...
No Matches
debugpacket.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
36#include "core/refcounted.h"
37#include "io/stream.h"
38
39//------------------------------------------------------------------------------
40namespace Net
41{
43{
44public:
47 {
48 PC2WiiCmd, // message from PC to Wii has been sent
49 Wii2PCCmd, // message from Wii to PC has been sent
50 PC2WiiAck, // Wii-2-PC message has arrived on PC
51 Wii2PCAck, // PC-2-Wii message has arrived on Wii
52 };
53
55 static const SizeT PacketSize = 512;
57 static const SizeT HeaderSize = 12;
60
64 virtual ~DebugPacket();
65
67 static Util::Array<DebugPacket> EncodeStream(ushort portNum, uint firstPacketCounter, const Ptr<IO::Stream>& stream);
69 static void DecodePackets(const Util::Array<DebugPacket>& packets, const Ptr<IO::Stream>& stream, ushort& outPortNum);
70
72 SizeT Write(ushort portNum, uint packetCounter, const ubyte* buf, SizeT numBytes);
74 void WriteRaw(const void* buf, SizeT bufSize);
75
77 void SetDataValid(bool b);
79 bool HasData() const;
81 Util::FourCC GetMagic() const;
83 uint GetCount() const;
85 ushort GetPort() const;
87 bool IsFinalPacket() const;
89 SizeT GetPayloadSize() const;
91 const ubyte* GetPayload() const;
93 const ubyte* GetRawBuffer() const;
94
95private:
97 bool hasData;
98};
99
100//------------------------------------------------------------------------------
103inline void
105{
106 this->hasData = b;
107}
108
109//------------------------------------------------------------------------------
112inline bool
114{
115 return this->hasData;
116}
117
118} // namespace Net
119//------------------------------------------------------------------------------
120
Encapsulates a data packet for debug communication.
Definition debugpacket.h:43
SizeT GetPayloadSize() const
get actual payload size
Definition debugpacket.cc:167
virtual ~DebugPacket()
destructor
Definition debugpacket.cc:29
ushort GetPort() const
get the port number of the packet
Definition debugpacket.cc:135
const ubyte * GetRawBuffer() const
get pointer to raw packet buffer (contains header + payload)
Definition debugpacket.cc:197
Command
packet commands
Definition debugpacket.h:47
@ Wii2PCCmd
Definition debugpacket.h:49
@ PC2WiiCmd
Definition debugpacket.h:48
@ PC2WiiAck
Definition debugpacket.h:50
@ Wii2PCAck
Definition debugpacket.h:51
static const SizeT HeaderSize
header size
Definition debugpacket.h:57
bool hasData
Definition debugpacket.h:97
static const SizeT PacketSize
packet size
Definition debugpacket.h:55
Util::FourCC GetMagic() const
get magic code at start of header
Definition debugpacket.cc:105
void WriteRaw(const void *buf, SizeT bufSize)
write raw data to packet (must have valid packet header, size of src buffer must be PacketSize!
Definition debugpacket.cc:92
static const SizeT MaxPayloadSize
max payload size
Definition debugpacket.h:59
static Util::Array< DebugPacket > EncodeStream(ushort portNum, uint firstPacketCounter, const Ptr< IO::Stream > &stream)
encode stream into a series of packets
Definition debugpacket.cc:206
const ubyte * GetPayload() const
get pointer to payload
Definition debugpacket.cc:186
DebugPacket()
constructor
Definition debugpacket.cc:20
bool IsFinalPacket() const
return true if this is the last packet of a message
Definition debugpacket.cc:150
uint GetCount() const
get message counter
Definition debugpacket.cc:120
static void DecodePackets(const Util::Array< DebugPacket > &packets, const Ptr< IO::Stream > &stream, ushort &outPortNum)
decode a series of packets into a stream
Definition debugpacket.cc:239
ubyte buffer[PacketSize]
Definition debugpacket.h:96
bool HasData() const
return true if the packet contains data
Definition debugpacket.h:113
void SetDataValid(bool b)
set the "has data" flag on the packet
Definition debugpacket.h:104
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Nebula's dynamic array class.
Definition array.h:60
A four-character-code is a quasi-human-readable 32-bit-id.
Definition fourcc.h:19
@ Write
Definition filewatcher.h:47
Definition debugmessage.h:20
unsigned char ubyte
Definition types.h:34
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
unsigned short ushort
Definition types.h:32