我在win10下面进行测试,使用官方的 xdma_driver_win_src_2018_2驱动版本测试发现小于8MB的数据发送到板上内存后, 回传,验证的md5值相同
但是大于8M的数据测试发送回传数据不正常, MD5值不一样
size_t device_file::write(char* buffer, size_t size, long offset) {
seek(BASE_OFFSET+offset); //修改起始位置
DWORD wr_size = 0;
//单次传输大小不能超过8M
unsigned int transfers;
unsigned int i;
transfers = (size / MAX_BYTES_PER_TRANSFER);
for (i = 0; i < transfers; i++) {
if (!WriteFile(h, (void *)(buffer + i * MAX_BYTES_PER_TRANSFER), MAX_BYTES_PER_TRANSFER, &wr_size, NULL)) {
return -1;
}
if (wr_size != MAX_BYTES_PER_TRANSFER) {
return -2;
}
}
if (!WriteFile(h, (void *)(buffer + i * MAX_BYTES_PER_TRANSFER), (DWORD)(size - i * MAX_BYTES_PER_TRANSFER), &wr_size, NULL)) {
return -1;
}
if (wr_size != (size - i * MAX_BYTES_PER_TRANSFER)) {
return -2;
}
return size;
}
size_t device_file::read(char* buffer, size_t size, long offset) {
seek(BASE_OFFSET+offset); //修改起始位置
DWORD rd_size = 0;
unsigned int transfers;
unsigned int i;
transfers = (size / MAX_BYTES_PER_TRANSFER);
for (i = 0; i < transfers; i++){
if (!ReadFile(h, (void *)(buffer + i * MAX_BYTES_PER_TRANSFER), (DWORD)MAX_BYTES_PER_TRANSFER, &rd_size, NULL)){
return -1;
}
if (rd_size != MAX_BYTES_PER_TRANSFER){
return -2;
}
}
if (!ReadFile(h, (void *)(buffer + i * MAX_BYTES_PER_TRANSFER), (DWORD)(size - i * MAX_BYTES_PER_TRANSFER), &rd_size, NULL)){
return -1;
}
if (rd_size != (size - i * MAX_BYTES_PER_TRANSFER)){
return -2;
}
return size;
}
上位机的发送和接收程序是按照图传的代码写的.不知道哪个地方出问题了,
我单独测试图传程序也会出现图片错位和数据乱的问题
|
|