Compare commits
2 Commits
57443a5c26
...
b8550dee70
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8550dee70 | ||
|
|
78fc7cb184 |
@@ -47,7 +47,7 @@ Channel::Channel(char const * ptr, size_t len, uint32_t board) {
|
|||||||
}
|
}
|
||||||
void Channel::Print(){
|
void Channel::Print(){
|
||||||
if (valid) {
|
if (valid) {
|
||||||
spdlog::get("zynqDump")->info("board {}, channel {}, spill {}, size {}, blocks {}, crossing {}, integrals {}, {}, {}",
|
spdlog::get("zynqDump")->debug("board {}, channel {}, spill {}, size {}, blocks {}, crossing {}, integrals {}, {}, {}",
|
||||||
board_id, id, spill, size, block_count, crossing, integral[0], integral[1], integral[2]);
|
board_id, id, spill, size, block_count, crossing, integral[0], integral[1], integral[2]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
120
client.cc
120
client.cc
@@ -33,66 +33,11 @@ bool bad_data = true;
|
|||||||
int open_socket();
|
int open_socket();
|
||||||
void signalHandler( int signum );
|
void signalHandler( int signum );
|
||||||
void setup_logger();
|
void setup_logger();
|
||||||
size_t process_channel(char const * ptr, size_t len);
|
size_t process_channel(char const * ptr, size_t len, uint32_t board_id);
|
||||||
size_t process_block(char const * ptr, size_t len);
|
size_t process_block(char const * ptr, size_t len);
|
||||||
size_t process_block(char const * ptr, size_t len){
|
size_t process_block(char const * ptr, size_t len){
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
size_t process_channel(char const * ptr, size_t len){
|
|
||||||
if ((len < MIN_CHANNEL_SIZE) || (len > MAX_CHANNEL_SIZE)) {
|
|
||||||
spdlog::debug("channel length must be between {} and {}.",
|
|
||||||
MIN_CHANNEL_SIZE, MAX_CHANNEL_SIZE);
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t bytes_left = len;
|
|
||||||
bool valid_channel = false;
|
|
||||||
uint32_t * wordData = (uint32_t *)ptr;
|
|
||||||
|
|
||||||
while ((bytes_left > 0) && !valid_channel) {
|
|
||||||
if ((ptr[0] & 0xFF) != CHANNEL_MARKER){
|
|
||||||
spdlog::debug("bad_data, expecting {0:x}, received {0:x}",
|
|
||||||
static_cast<uint32_t>(CHANNEL_MARKER), static_cast<uint32_t>(ptr[0]));
|
|
||||||
bytes_left -= 4;
|
|
||||||
} else {
|
|
||||||
valid_channel = true;
|
|
||||||
|
|
||||||
size_t channel_size = ((wordData[0] & 0xFFFFFF00) >> 8) * sizeof(uint32_t);
|
|
||||||
if ((channel_size > MAX_CHANNEL_SIZE) || (channel_size < MIN_CHANNEL_SIZE)) {
|
|
||||||
spdlog::debug("Invalid channel size: {}", channel_size);
|
|
||||||
}
|
|
||||||
uint32_t version = wordData[0] && 0xFF;
|
|
||||||
spdlog::debug("channel size {}, version {}", channel_size, version);
|
|
||||||
|
|
||||||
int32_t integral[3];
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
integral[i] = (wordData[i + 1] & 0xFFFFFF00)>>8;
|
|
||||||
spdlog::debug("integrals: {}, {}, {}", integral[0], integral[1], integral[2]);
|
|
||||||
|
|
||||||
uint32_t crossing_count = wordData[4] & 0x00FFFFFF;
|
|
||||||
uint32_t block_count = (wordData[5] &0xFF000000) >> 24;
|
|
||||||
uint32_t channel = (wordData[5] & 0x00FF0000) >> 16;
|
|
||||||
uint32_t spill_id = (wordData[5] & 0x0000FFFF);
|
|
||||||
spdlog::debug("crossing_count {}, block_count {}, channel {}, spill_id {}",
|
|
||||||
crossing_count, block_count, channel, spill_id);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < block_count; i++) {
|
|
||||||
process_block(ptr, channel_size); // not correct yet!
|
|
||||||
}
|
|
||||||
|
|
||||||
// the number of bytes consumed by this function, regardless of block
|
|
||||||
// processing
|
|
||||||
bytes_left -= channel_size;
|
|
||||||
|
|
||||||
Channel c(ptr, channel_size);
|
|
||||||
c.Print();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return number of bytes cosumed of the channel
|
|
||||||
spdlog::debug("processed {} bytes out of {}", (len - bytes_left), len);
|
|
||||||
return len - bytes_left;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
@@ -162,8 +107,10 @@ int main(int argc, char * argv[])
|
|||||||
size_t bytes_left = (frameSize - 3 * sizeof(uint32_t));
|
size_t bytes_left = (frameSize - 3 * sizeof(uint32_t));
|
||||||
size_t bytes_processed = 0;
|
size_t bytes_processed = 0;
|
||||||
while ((bytes_left - bytes_processed >= MIN_CHANNEL_SIZE) && (bytes_processed < bytes_left)) {
|
while ((bytes_left - bytes_processed >= MIN_CHANNEL_SIZE) && (bytes_processed < bytes_left)) {
|
||||||
bytes_processed += process_channel(char_buffer + 2 * sizeof(uint32_t) + bytes_processed,
|
bytes_processed += process_channel(
|
||||||
bytes_left - bytes_processed);
|
char_buffer + 2 * sizeof(uint32_t) + bytes_processed,
|
||||||
|
bytes_left - bytes_processed,
|
||||||
|
static_cast<uint32_t>(board_id));
|
||||||
}
|
}
|
||||||
spdlog::get("zynqDump")->debug("Done, {} bytes processed.", bytes_processed);
|
spdlog::get("zynqDump")->debug("Done, {} bytes processed.", bytes_processed);
|
||||||
}
|
}
|
||||||
@@ -217,3 +164,60 @@ void setup_logger(){
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t process_channel(char const * ptr, size_t len, uint32_t board_id){
|
||||||
|
if ((len < MIN_CHANNEL_SIZE) || (len > MAX_CHANNEL_SIZE)) {
|
||||||
|
spdlog::debug("channel length must be between {} and {}.",
|
||||||
|
MIN_CHANNEL_SIZE, MAX_CHANNEL_SIZE);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t bytes_left = len;
|
||||||
|
bool valid_channel = false;
|
||||||
|
uint32_t * wordData = (uint32_t *)ptr;
|
||||||
|
|
||||||
|
while ((bytes_left > 0) && !valid_channel) {
|
||||||
|
if ((ptr[0] & 0xFF) != CHANNEL_MARKER){
|
||||||
|
spdlog::debug("bad_data, expecting {0:x}, received {0:x}",
|
||||||
|
static_cast<uint32_t>(CHANNEL_MARKER), static_cast<uint32_t>(ptr[0]));
|
||||||
|
bytes_left -= 4;
|
||||||
|
} else {
|
||||||
|
valid_channel = true;
|
||||||
|
|
||||||
|
size_t channel_size = ((wordData[0] & 0xFFFFFF00) >> 8) * sizeof(uint32_t);
|
||||||
|
if ((channel_size > MAX_CHANNEL_SIZE) || (channel_size < MIN_CHANNEL_SIZE)) {
|
||||||
|
spdlog::debug("Invalid channel size: {}", channel_size);
|
||||||
|
}
|
||||||
|
uint32_t version = wordData[0] && 0xFF;
|
||||||
|
spdlog::debug("channel size {}, version {}", channel_size, version);
|
||||||
|
|
||||||
|
int32_t integral[3];
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
integral[i] = (wordData[i + 1] & 0xFFFFFF00)>>8;
|
||||||
|
spdlog::debug("integrals: {}, {}, {}", integral[0], integral[1], integral[2]);
|
||||||
|
|
||||||
|
uint32_t crossing_count = wordData[4] & 0x00FFFFFF;
|
||||||
|
uint32_t block_count = (wordData[5] &0xFF000000) >> 24;
|
||||||
|
uint32_t channel = (wordData[5] & 0x00FF0000) >> 16;
|
||||||
|
uint32_t spill_id = (wordData[5] & 0x0000FFFF);
|
||||||
|
spdlog::debug("crossing_count {}, block_count {}, channel {}, spill_id {}",
|
||||||
|
crossing_count, block_count, channel, spill_id);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < block_count; i++) {
|
||||||
|
process_block(ptr, channel_size); // not correct yet!
|
||||||
|
}
|
||||||
|
|
||||||
|
// the number of bytes consumed by this function, regardless of block
|
||||||
|
// processing
|
||||||
|
bytes_left -= channel_size;
|
||||||
|
|
||||||
|
Channel c(ptr, channel_size, board_id);
|
||||||
|
c.Print();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return number of bytes cosumed of the channel
|
||||||
|
spdlog::debug("processed {} bytes out of {}", (len - bytes_left), len);
|
||||||
|
return len - bytes_left;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user