These tests require a device configured with the following Arduino sketch:
uint32_t seed = 0;
uint32_t bytesToSend = 0;
uint8_t nextByte() {
seed = (1103515245 * seed + 12345) % 0x8000000;
return (seed >> 16) & 0xFF;
}
void setup() {
Serial.begin(115200);
}
void loop() {
if (!Serial) {
return;
}
if (bytesToSend == 0) {
// Read the seed and number of bytes to send from the host as 32-bit
// little-endian values.
if (Serial.available() < 8) {
return;
}
uint8_t buf[8];
Serial.readBytes((char*)buf, sizeof buf);
seed = (uint32_t)buf[0] |
((uint32_t)buf[1] << 8) |
((uint32_t)buf[2] << 16) |
((uint32_t)buf[3] << 24);
bytesToSend = (uint32_t)buf[4] |
((uint32_t)buf[5] << 8) |
((uint32_t)buf[6] << 16) |
((uint32_t)buf[7] << 24);
} else {
uint8_t buf[64];
uint32_t count = min(sizeof buf, bytesToSend);
for (uint32_t i = 0; i < count; ++i) {
buf[i] = nextByte();
}
bytesToSend -= count;
Serial.write((char*)buf, count);
}
}