Hello again,
first of all, I would like to mention that for the _write() to work in my previous post, &bufw needs to be the argument in the _write() function.
After finishing writing the software and firmware, I am running into an issue reading data from the fpga with the error:
"_read() failed: invalid argument" and I'm hoping to get some insight as to what the cause is. Below is the snippet of code for the write and following read function:
int numbytew = 1, numbyter = 40;
unsigned char bufw;
unsigned char *bufr;
case 2 :
printf("case 2: set capture\n");
bufw = 0xFF;
rcw = _write(fdw, &bufw, numbytew);
if ((rcw < 0) && (errno == EINTR))
continue;
if (rcw < 0) {
perror("_write() failed");
break;
}
if (rcw == 0) {
fprintf(stderr, "Reached write EOF (?!)\n");
break;
}
if (rcw == 1) {}
}
break;
case 3 :
printf("case 3: transmit 1\n");
rcr = _read(fdr, bufr, numbyter);
if ((rcr < 0) && (errno == EINTR))
continue;
if (rcr < 0) {
perror("_read() failed");
break;
}
if (rcr == 0) {
fprintf(stderr, "Reached write EOF (?!)\n");
break;
}
file_write(bufr, rcr);
if (rcr == 40) {}
}
break;
I removed the logic in the rcr and rcw if statements since they are not relevant to xillybus. I am also inclusing the fifo mapping and enable logic on the fpga side although I do not believe this is the issue:
assign capture_en_rd = capture_open && !capture_full && (|pc_request) && !capture_select;
assign capture_en_wr = !request_empty;
fifo_write_1 en_fifo
(.rst(!user_w_write_32_open),
.wr_clk(bus_clk),
.rd_clk(clk),
.din(user_w_write_32_data),
.wr_en(user_w_write_32_wren),
.rd_en(capture_en_wr),
.dout(pc_request),
.full(user_w_write_32_full),
.empty(request_empty)
);
fifo_read_1 focused_fifo
(
.rst(!user_r_read_128_open),
.wr_clk(clk),
.rd_clk(bus_clk),
.din(capture_data),
.wr_en(capture_en_rd),
.rd_en(user_r_read_128_rden),
.dout(user_r_read_128_data),
.full(capture_full),
.empty(user_r_read_128_empty)
);
I appreciate the assistance