Added encoding functionalities, still networking to finish
parent
f6537c4cd0
commit
09a7b2528b
|
@ -1,4 +1,6 @@
|
|||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#define START_OF_HEADER_MARKER 0xee1234ee
|
||||
|
||||
|
@ -33,4 +35,20 @@ enum ERROR_CODES {
|
|||
TIMEOUT_ERROR = (1 << 3)
|
||||
};
|
||||
|
||||
void encode_header(uint32_t *buffer, const Header &header) {
|
||||
buffer[0] = header.startOfHeaderMarker;
|
||||
buffer[1] = header.headerSize;
|
||||
buffer[2] = header.fragmentSize;
|
||||
buffer[3] = header.runNumber;
|
||||
buffer[4] = header.detectorEventNumber;
|
||||
buffer[5] = header.numberOfStatusElements;
|
||||
|
||||
std::memcpy(&buffer[6], header.statusElementsArray, header.numberOfStatusElements * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
void encode_fragment(uint32_t *buffer, const Fragment &fragment){
|
||||
encode_header(buffer, fragment.header);
|
||||
std::memcpy(&buffer[fragment.header.headerSize], fragment.payloadElements, (fragment.header.fragmentSize - fragment.header.headerSize) * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
|
||||
|
|
15
provider.cxx
15
provider.cxx
|
@ -67,10 +67,19 @@ int main(int argc, char* argv[]) {
|
|||
uint32_t event_number = 0;
|
||||
|
||||
uint32_t run_number = 0;
|
||||
if (argc > 1) {
|
||||
run_number = atoi(argv[1]);
|
||||
|
||||
if (argc != 4) {
|
||||
printf("Usage %s host portNumber runNumber\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
const char* host = argv[1];
|
||||
int port = atoi(argv[2]);
|
||||
run_number = atoi(argv[3]);
|
||||
|
||||
int socket = makeSocket();
|
||||
connectTo(socket, host, port);
|
||||
|
||||
while (true) {
|
||||
Header header;
|
||||
header.runNumber = run_number;
|
||||
|
@ -109,6 +118,8 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < header.fragmentSize; i++) {
|
||||
|
|
Loading…
Reference in New Issue