$treeview $search $mathjax $extrastylesheet
otsdaq_components
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_OtsUDPFirmwareCore_h_ 00002 #define _ots_OtsUDPFirmwareCore_h_ 00003 00004 //#include "otsdaq-components/DAQHardware/FirmwareSequence.h" 00005 #include "otsdaq-components/DAQHardware/FrontEndFirmwareBase.h" 00006 00007 #include <string> 00008 #include <vector> 00009 00010 namespace ots 00011 { 00012 class OtsUDPFirmwareCore : public FrontEndFirmwareBase 00013 { 00014 //=============================================== 00015 // OtsUDPFirmwareCore 00016 // 00017 // The intent of this class is to be the core UDP firmware functionality. 00018 // This should handle everything except the user block 0x0 of the address space. 00019 // 00020 // 00021 // Note: Currently there are these other blocks of the address space: 00022 // block 0x1 -- UDP core 00023 // block 0x2 -- Programming over Ethernet core 00024 00025 public: 00026 OtsUDPFirmwareCore(unsigned int version); 00027 virtual ~OtsUDPFirmwareCore(void); 00028 virtual void init(void); 00029 00031 // implementation of base class virtual functionality 00032 00033 // std::string read (char* address); 00034 virtual std::string write(char* address, char* data); 00035 virtual void write(std::string& buffer, 00036 char* address, 00037 char* data, 00038 bool clearBuffer = true); 00039 virtual void write(std::string& buffer, 00040 uint32_t address, 00041 uint32_t data, 00042 bool clearBuffer = true); 00043 virtual void write(std::string& buffer, 00044 uint64_t address, 00045 uint64_t data, 00046 bool clearBuffer = true); 00047 virtual void waitClear(std::string& buffer, 00048 uint32_t address, 00049 uint32_t data, 00050 uint32_t timeout = 255, 00051 bool clearBuffer = true) 00052 { 00053 } 00054 00055 virtual std::string read(char* address); 00056 virtual void read(std::string& buffer, char* address, bool clearBuffer = true); 00057 virtual void read(std::string& buffer, uint64_t address, bool clearBuffer = true); 00058 virtual void read(std::string& buffer, uint32_t address, bool clearBuffer = true); 00059 00060 virtual void setDataDestination(std::string& buffer, 00061 const std::string& ip, 00062 const uint16_t port, 00063 bool clearBuffer = true); 00064 00065 virtual uint32_t createRegisterFromValue(std::string& readBuffer, 00066 std::string& receivedValue); 00068 // low level functionality 00069 void writeAdvanced(std::string& buffer, 00070 const char* address, 00071 const char* data, 00072 uint8_t size = 1, 00073 uint8_t commandTypeOptions = 0, 00074 bool clearBuffer = true); 00075 void writeAdvanced(std::string& buffer, 00076 const uint64_t& address, 00077 const char* data, 00078 uint8_t size, 00079 uint8_t commandTypeOptions = 0, 00080 bool clearBuffer = true); // size is required, to remove ambiguity 00081 // when calling write with data=0 00082 void writeAdvanced(std::string& buffer, 00083 const uint64_t& address, 00084 const uint64_t& data, 00085 uint8_t commandTypeOptions = 0, 00086 bool clearBuffer = true); 00087 void writeAdvanced(std::string& buffer, 00088 const uint64_t& address, 00089 const std::vector<uint64_t>& data, 00090 uint8_t commandTypeOptions = 0, 00091 bool clearBuffer = true); 00092 void readAdvanced(std::string& buffer, 00093 char* address, 00094 uint8_t size = 1, 00095 uint8_t commandTypeOptions = 0, 00096 bool clearBuffer = true); 00097 void readAdvanced(std::string& buffer, 00098 const uint64_t& address, 00099 uint8_t size = 1, 00100 uint8_t commandTypeOptions = 0, 00101 bool clearBuffer = true); 00102 00104 // next level functionality 00105 00106 // data destination read/write 00107 void writeDataDestinationIP(std::string& buffer, 00108 const uint64_t value, 00109 bool clearBuffer = true); 00110 void writeDataDestinationMAC(std::string& buffer, 00111 const uint64_t value, 00112 bool clearBuffer = true); 00113 void writeDataDestinationPort(std::string& buffer, 00114 const uint64_t value, 00115 bool clearBuffer = true); 00116 00117 void readDataDestinationIP(std::string& buffer); 00118 void readDataDestinationMAC(std::string& buffer); 00119 void readDataDestinationPort(std::string& buffer); 00120 00121 void setDataDestinationAsSelf(std::string& buffer) 00122 { 00123 buffer.resize(0); 00124 buffer += (char)2; /* special one-byte packet, sets data destination as sender */ 00125 } 00126 00127 // control destination read/write 00128 virtual void setControlDestination(std::string& buffer, 00129 const std::string& ip, 00130 const uint16_t port); 00131 00132 void writeControlDestinationIP(std::string& buffer, const uint64_t value); 00133 void writeControlDestinationMAC(std::string& buffer, const uint64_t value); 00134 void writeControlDestinationPort(std::string& buffer, const uint64_t value); 00135 00136 void readControlDestinationIP(std::string& buffer); 00137 void readControlDestinationMAC(std::string& buffer); 00138 void readControlDestinationPort(std::string& buffer); 00139 00140 void setControlDestinationAsSelf(std::string& buffer) 00141 { 00142 buffer.resize(0); 00143 buffer += 00144 (char)1; /* special one-byte packet, sets control destination as sender */ 00145 } 00146 00147 // other 00148 void UDPFirmwareSpecialPing(std::string& buffer) 00149 { 00150 buffer.resize(0); 00151 buffer += (char)0; /* special one-byte packet, returns OEI version (16-bits) */ 00152 } 00153 void UDPFirmwareSpecialNoOp(std::string& buffer) 00154 { 00155 buffer.resize(0); 00156 buffer += (char)3; /* special one-byte packet, is ignored at OIE - could be used 00157 to keep connection alive */ 00158 } 00159 00160 void readUDPFirmwareVersion(std::string& buffer); 00161 void softEthernetReset(std::string& buffer); 00162 void hardEthernetReset(std::string& buffer); 00163 void clearEthernetReset(std::string& buffer); 00164 00165 void startBurst(std::string& buffer); 00166 void stopBurst(std::string& buffer); 00167 00168 // command type options that can be OR'd 00169 static const uint8_t FIFO_ADDRESS_CMD_TYPE; 00170 }; 00171 } 00172 00173 #endif