This commit is contained in:
2026-06-19 07:46:17 -05:00
parent ffd3eab72d
commit dd811684dc
10 changed files with 803 additions and 43 deletions

View File

@@ -59,15 +59,15 @@ DataRecorder::DataRecorder() {
allocate_memory();
// Prep access to PL registers
plfd = open("/dev/wsrpl0", O_RDWR);
plfd = open("/dev/drexpl0", O_RDWR);
if (plfd < 0){
printf("Failed to open %s\n", "/dev/wsrpl0");
printf("Failed to open %s\n", "/dev/drexpl0");
}
plmmap = (uint32_t *)mmap(NULL, 0x1000000, PROT_WRITE | PROT_READ, MAP_SHARED, plfd, 0);
if (plmmap < (uint32_t *)0){
printf("Failed to mmap %s\n", "/dev/wsrpl0");
printf("Failed to mmap %s\n", "/dev/drexpl0");
close(plfd);
}
@@ -266,7 +266,7 @@ void DataRecorder::set_validate_cnt_data(bool enable, uint32_t pri, uint32_t int
void DataRecorder::get_data(int ch_ind, int save_to_disk) {
char* file;
asprintf(&file, "/dev/wsrdma%d", ch_ind);
asprintf(&file, "/dev/drexdma%d", ch_ind);
// Start write to disk thread
if (save_to_disk) {
@@ -279,27 +279,27 @@ void DataRecorder::get_data(int ch_ind, int save_to_disk) {
return;
}
wsrpcie_ioctl_t wsrpcie_ioctl;
drexpcie_ioctl_t drexpcie_ioctl;
wsrpcie_ioctl.cmd = WSRDMA_SET_NUM_BYTES;
wsrpcie_ioctl.offset = 0;
wsrpcie_ioctl.value = BUFFER_SIZE;
ioctl(fd, 0, &wsrpcie_ioctl);
drexpcie_ioctl.cmd = DREXDMA_SET_NUM_BYTES;
drexpcie_ioctl.offset = 0;
drexpcie_ioctl.value = BUFFER_SIZE;
ioctl(fd, 0, &drexpcie_ioctl);
wsrpcie_ioctl.cmd = WSRDMA_SET_NUM_BUFS;
wsrpcie_ioctl.offset = 0;
wsrpcie_ioctl.value = NUM_BUFFERS;
ioctl(fd, 0, &wsrpcie_ioctl);
drexpcie_ioctl.cmd = DREXDMA_SET_NUM_BUFS;
drexpcie_ioctl.offset = 0;
drexpcie_ioctl.value = NUM_BUFFERS;
ioctl(fd, 0, &drexpcie_ioctl);
wsrpcie_ioctl.cmd = WSRDMA_DMA_INIT;
wsrpcie_ioctl.offset = 0;
wsrpcie_ioctl.value = 0;
ioctl(fd, 0, &wsrpcie_ioctl);
drexpcie_ioctl.cmd = DREXDMA_DMA_INIT;
drexpcie_ioctl.offset = 0;
drexpcie_ioctl.value = 0;
ioctl(fd, 0, &drexpcie_ioctl);
wsrpcie_ioctl.cmd = WSRDMA_DMA_START;
wsrpcie_ioctl.offset = 0;
wsrpcie_ioctl.value = 0;
ioctl(fd, 0, &wsrpcie_ioctl);
drexpcie_ioctl.cmd = DREXDMA_DMA_START;
drexpcie_ioctl.offset = 0;
drexpcie_ioctl.value = 0;
ioctl(fd, 0, &drexpcie_ioctl);
struct timespec ts_now;
@@ -394,17 +394,17 @@ void DataRecorder::get_data(int ch_ind, int save_to_disk) {
}
wsrpcie_ioctl.cmd = WSRDMA_DMA_STOP;
wsrpcie_ioctl.offset = 0;
wsrpcie_ioctl.value = 0;
drexpcie_ioctl.cmd = DREXDMA_DMA_STOP;
drexpcie_ioctl.offset = 0;
drexpcie_ioctl.value = 0;
ioctl(fd, 0, &wsrpcie_ioctl);
ioctl(fd, 0, &drexpcie_ioctl);
wsrpcie_ioctl.cmd = WSRDMA_DMA_CLEAR;
wsrpcie_ioctl.offset = 0;
wsrpcie_ioctl.value = 0;
drexpcie_ioctl.cmd = DREXDMA_DMA_CLEAR;
drexpcie_ioctl.offset = 0;
drexpcie_ioctl.value = 0;
ioctl(fd, 0, &wsrpcie_ioctl);
ioctl(fd, 0, &drexpcie_ioctl);
// Make sure write thread is done before closing file handle
if (writer[ch_ind].joinable()) {

View File

@@ -16,21 +16,21 @@
#define TIMING_REG_BASE 0x20000
#define DATA_GEN_REG_BASE 0x30000
#define WSRDMA_DMA_INIT 0
#define WSRDMA_DMA_CLEAR 1
#define WSRDMA_DMA_START 2
#define WSRDMA_DMA_STOP 3
#define WSRDMA_SET_NUM_BUFS 4
#define WSRDMA_SET_NUM_BYTES 5
#define WSRDMA_GET_NUM_BUFS 6
#define WSRDMA_GET_NUM_BYTES 7
#define WSRDMA_GET_FREE_BUFS 8
#define DREXDMA_DMA_INIT 0
#define DREXDMA_DMA_CLEAR 1
#define DREXDMA_DMA_START 2
#define DREXDMA_DMA_STOP 3
#define DREXDMA_SET_NUM_BUFS 4
#define DREXDMA_SET_NUM_BYTES 5
#define DREXDMA_GET_NUM_BUFS 6
#define DREXDMA_GET_NUM_BYTES 7
#define DREXDMA_GET_FREE_BUFS 8
typedef struct {
unsigned int cmd;
unsigned int offset;
unsigned int value;
} wsrpcie_ioctl_t;
} drexpcie_ioctl_t;
#define NUM_DMA_CH 4
#define BUFFER_SIZE (4 * 1024 * 1024)

View File

@@ -11,8 +11,13 @@ int main() {
uint32_t n_pulses = 128;
float inter_cpi = 100e-6;
// float pri = 75e-6;
float pri = 200e-6;
float pri = 100e-6;
uint32_t n_samples = 16384;
int test_time_ms = 10000;
// Set false to just pull data across the pcie and run the data validator.
// Set true to save data to disk
bool save_to_disk = false;
float cpi_time = n_pulses * pri + inter_cpi;
float cpi_num_bytes = n_pulses * n_samples * 16;
@@ -40,13 +45,12 @@ int main() {
dr.set_validate_cnt_data(true, dr.read_reg(TIMING_REG_BASE + 0x4) + 1, dr.read_reg(TIMING_REG_BASE + 0x10) + 1, n_pulses);
// Start listening for data
// dr.start_recording("test.bin", 1);
dr.start_recording("/media/hptnvme/test.bin", 1);
dr.start_recording("/media/hptnvme/test.bin", save_to_disk);
sleep(1);
// Start the timing engine so data starts flowing
dr.write_reg(TIMING_REG_BASE + 0x0, 0);
// Wait a while
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
std::this_thread::sleep_for(std::chrono::milliseconds(test_time_ms));
dr.write_reg(TIMING_REG_BASE + 0x0, 1);
sleep(2);
dr.stop_recording();