66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#ifndef PMAC_ETHERNET_CMD_H
|
|
#define PMAC_ETHERNET_CMD_H
|
|
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
class EthernetCommand {
|
|
public:
|
|
enum class RequestType { VR_UPLOAD = 0xC0, VR_DOWNLOAD = 0x40 };
|
|
enum class Request {
|
|
VR_PMAC_SENDLINE = 0xB0,
|
|
VR_PMAC_GETLINE = 0xB1,
|
|
VR_PMAC_FLUSH = 0xB3,
|
|
VR_PMAC_GETMEM = 0xB4,
|
|
VR_PMAC_SETMEN = 0xB5,
|
|
VR_PMAC_SETBIT = 0xBA,
|
|
VR_PMAC_SETBITS = 0xBB,
|
|
VR_PMAC_PORT = 0xBE,
|
|
VR_PMAC_GETRESPONSE = 0xBF,
|
|
VR_PMAC_READREADY = 0xC2,
|
|
VR_CTRL_RESPONSE = 0xC4,
|
|
VR_PMAC_GETBUFFER = 0xC5,
|
|
VR_PMAC_WRITEBUFFER = 0xC6,
|
|
VR_PMAC_WRITEERROR = 0xC7,
|
|
VR_FWDOWNLOAD = 0xCB,
|
|
VR_IPADDRESS = 0xE0
|
|
};
|
|
|
|
std::vector<char> serialize();
|
|
|
|
void write(std::vector<char> command);
|
|
|
|
private:
|
|
const char CTRLB = '\2';
|
|
const char CTRLC = '\3';
|
|
const char CTRLF = '\6';
|
|
const char CTRLG = '\7';
|
|
const char CTRLP = '\16';
|
|
const char CTRLV = '\22';
|
|
|
|
bool isCharControlCommand(char &c);
|
|
|
|
const unsigned ETHERNET_DATA_SIZE = 1492;
|
|
|
|
/*
|
|
1 for Request Type
|
|
1 for Request
|
|
2 for wValue
|
|
2 for wIndex
|
|
2 for wLength
|
|
*/
|
|
constexpr ETHERNET_HEADER_SIZE = 8;
|
|
|
|
/*
|
|
Command Data
|
|
*/
|
|
std::optional<RequestType> requestType;
|
|
std::optional<Request> request;
|
|
unsigned short wValue;
|
|
unsigned short wIndex;
|
|
unsigned short wLength; // lenght of data, will not be necessary since
|
|
// vector know is lenght
|
|
std::vector<char> bData;
|
|
};
|
|
|
|
#endif |