Compare commits
7 Commits
f24628443f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| a2e8997090 | |||
| e07831fcad | |||
| ec73a87d31 | |||
| e3fb134dbb | |||
| 6c3b0ceed4 | |||
| e5218cd885 | |||
| afc9b1d6fb |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,4 +2,3 @@ r
|
|||||||
build
|
build
|
||||||
old
|
old
|
||||||
dump
|
dump
|
||||||
spdlog
|
|
||||||
|
|||||||
15
CMakeLists.txt
Normal file
15
CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
|
project(zynqDump VERSION 0.1.0)
|
||||||
|
|
||||||
|
set(TARGET zynqDump)
|
||||||
|
add_compile_options("-std=c++14")
|
||||||
|
include_directories("/home/nam/sw/include")
|
||||||
|
|
||||||
|
add_library(channel STATIC channel.cc)
|
||||||
|
find_library(SPDLOG
|
||||||
|
NAMES spdlog
|
||||||
|
HINTS "/home/nam/sw/lib"
|
||||||
|
)
|
||||||
|
add_executable(${TARGET} client.cc)
|
||||||
|
|
||||||
|
target_link_libraries(${TARGET} channel ${SPDLOG})
|
||||||
4
Makefile
4
Makefile
@@ -1,7 +1,7 @@
|
|||||||
target = r
|
target = r
|
||||||
CXX = g++
|
CXX = g++
|
||||||
CXX_FLAGS := -std=c++14 -I/home/daq/sw/include -Wall -DSPDLOG_COMPILED_LIB
|
CXX_FLAGS := -std=c++14 -I./include -Wall
|
||||||
LD_FLAGS := -lpthread -ldl -L/home/daq/sw/lib64 -lspdlog
|
LD_FLAGS := -lpthread -ldl
|
||||||
|
|
||||||
BUILD := ./build
|
BUILD := ./build
|
||||||
OBJS = $(BUILD)/client.o $(BUILD)/channel.o
|
OBJS = $(BUILD)/client.o $(BUILD)/channel.o
|
||||||
|
|||||||
11
client.cc
11
client.cc
@@ -17,7 +17,7 @@
|
|||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
#include "spdlog/sinks/rotating_file_sink.h"
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
|
|
||||||
const char * HOST = "192.168.30.89";
|
const char * HOST = "192.168.19.1";
|
||||||
const uint32_t PORT = 9999;
|
const uint32_t PORT = 9999;
|
||||||
const size_t MAX_EVENT_SIZE = 33484; // in bytes
|
const size_t MAX_EVENT_SIZE = 33484; // in bytes
|
||||||
const size_t MIN_EVENT_SIZE = 204; // in bytes
|
const size_t MIN_EVENT_SIZE = 204; // in bytes
|
||||||
@@ -51,6 +51,9 @@ int main(int argc, char * argv[])
|
|||||||
char char_buffer[MAX_EVENT_SIZE];
|
char char_buffer[MAX_EVENT_SIZE];
|
||||||
uint32_t * wordData = (uint32_t*) char_buffer;
|
uint32_t * wordData = (uint32_t*) char_buffer;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
std::ofstream output;
|
||||||
|
std::string outputName = "dump.bin";
|
||||||
|
output.open (outputName, std::ios::out );
|
||||||
|
|
||||||
fd_set select_fds; // fd's used by select
|
fd_set select_fds; // fd's used by select
|
||||||
struct timeval timeout; // Time value for time out
|
struct timeval timeout; // Time value for time out
|
||||||
@@ -70,6 +73,9 @@ int main(int argc, char * argv[])
|
|||||||
// read in first 4 bytes
|
// read in first 4 bytes
|
||||||
nread = recv(sock, char_buffer, 4, 0);
|
nread = recv(sock, char_buffer, 4, 0);
|
||||||
spdlog::get("zynqDump")->debug("read in {:d} bytes: 0x{:X}", nread, wordData[0]);
|
spdlog::get("zynqDump")->debug("read in {:d} bytes: 0x{:X}", nread, wordData[0]);
|
||||||
|
for (uint32_t j = 0; j < nread; ++j) {
|
||||||
|
output << char_buffer[j];
|
||||||
|
}
|
||||||
// if not A5 marker, go to next iteration (read in 4 more bytes)
|
// if not A5 marker, go to next iteration (read in 4 more bytes)
|
||||||
if ((char_buffer[0] & 0xFF) != 0xA5){
|
if ((char_buffer[0] & 0xFF) != 0xA5){
|
||||||
bad_data = true;
|
bad_data = true;
|
||||||
@@ -89,6 +95,9 @@ int main(int argc, char * argv[])
|
|||||||
spdlog::get("zynqDump")->debug("next {:d} bytes (expecting {:d}): {:X} {:X} {:X} {:X}",
|
spdlog::get("zynqDump")->debug("next {:d} bytes (expecting {:d}): {:X} {:X} {:X} {:X}",
|
||||||
nread, frameSize - 4, wordData[0], wordData[1], wordData[2], wordData[3]);
|
nread, frameSize - 4, wordData[0], wordData[1], wordData[2], wordData[3]);
|
||||||
spdlog::get("zynqDump")->debug("{:X} {:X} {:X} {:X}", wordData[4], wordData[5], wordData[6], wordData[7]);
|
spdlog::get("zynqDump")->debug("{:X} {:X} {:X} {:X}", wordData[4], wordData[5], wordData[6], wordData[7]);
|
||||||
|
for (uint32_t j = 0; j < nread; ++j) {
|
||||||
|
output << char_buffer[j];
|
||||||
|
}
|
||||||
uint8_t board_id = (wordData[0] >> 24) & 0xFF;
|
uint8_t board_id = (wordData[0] >> 24) & 0xFF;
|
||||||
uint8_t version = wordData[0] & 0xFF;
|
uint8_t version = wordData[0] & 0xFF;
|
||||||
uint16_t spill_id = (wordData[1] & 0x00FFFF00) >> 8;
|
uint16_t spill_id = (wordData[1] & 0x00FFFF00) >> 8;
|
||||||
|
|||||||
Reference in New Issue
Block a user