| 165 | } |
| 166 | |
| 167 | void testBulkWrite() override |
| 168 | { |
| 169 | struct any_frame f = { |
| 170 | .f = {.type = F_FRAME_BULK_WRITE_TEST_CMD, .size = sizeof(f)} |
| 171 | }; |
| 172 | usb_cmd_send(&f, f.f.size); |
| 173 | |
| 174 | /* These must match the device. */ |
| 175 | const int XSIZE = 64; |
| 176 | const int YSIZE = 256; |
| 177 | const int ZSIZE = 64; |
| 178 | |
| 179 | std::cout << "Reading data: " << std::flush; |
| 180 | Bytes bulk_buffer(XSIZE * YSIZE * ZSIZE); |
| 181 | double start_time = getCurrentTime(); |
| 182 | usb_data_recv(bulk_buffer); |
| 183 | double elapsed_time = getCurrentTime() - start_time; |
| 184 | |
| 185 | std::cout << "transferred " << bulk_buffer.size() |
| 186 | << " bytes from device -> PC in " |
| 187 | << int(elapsed_time * 1000.0) << " ms (" |
| 188 | << int((bulk_buffer.size() / 1024.0) / elapsed_time) |
| 189 | << " kB/s)" << std::endl; |
| 190 | |
| 191 | for (int x = 0; x < XSIZE; x++) |
| 192 | for (int y = 0; y < YSIZE; y++) |
| 193 | for (int z = 0; z < ZSIZE; z++) |
| 194 | { |
| 195 | int offset = x * XSIZE * YSIZE + y * ZSIZE + z; |
| 196 | if (bulk_buffer[offset] != uint8_t(x + y + z)) |
| 197 | error("data transfer corrupted at 0x{:x} {}.{}.{}", |
| 198 | offset, |
| 199 | x, |
| 200 | y, |
| 201 | z); |
| 202 | } |
| 203 | |
| 204 | await_reply<struct any_frame>(F_FRAME_BULK_WRITE_TEST_REPLY); |
| 205 | } |
| 206 | |
| 207 | void testBulkRead() override |
| 208 | { |
no test coverage detected