raw обмен на плате Tau-PCI/32-Lite

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <cstdio>
#define DEFAULT_PACKET_LEN 1504
int main() {
FILE* fp = fopen("/dev/cronyx/tau32_0.0", "wb");
if (NULL == fp) {
std::cout << "error opening pipe" << std::endl;
return 1;
}
setvbuf(fp, NULL, _IONBF, 0);
FILE* data = fopen("/home/steplg/a-law.mono.wav", "rb");
if (NULL == data) {
std::cout << "error opening data file" << std::endl;
return 1;
}
while (!feof(data)) {
char buffer[DEFAULT_PACKET_LEN];
size_t real_length = fread(buffer, 1, DEFAULT_PACKET_LEN, data);
size_t real_wrote = fwrite(buffer, 1, real_length, fp);
// fflush(fp);
if (real_wrote != real_length) {
std::cout << "!(" << real_length << ":" << real_wrote << ")" << std::endl;
} else {
std::cout << ".";
}
std::cout << std::endl;
}
return 0;
}