}
}
-string[*] settings(file f) {
- string[...] x = {};
-
- flush_input(f);
- fprintf (f, "c s\nv\n");
- flush(f);
- for (;;) {
- string l = File::fgets(f);
- x[dim(x)] = l;
- if (String::index(l, "software-version") == 0)
- break;
- }
- return x;
-}
-
-string[*] find_setting(string[*] s, string match) {
- for (int i = 0; i < dim(s); i++)
- if (String::index(s[i], match) == 0)
- return String::wordsplit(s[i], " ");
- return (string[*]) {};
-}
-
string[*] baro(file f) {
string[...] x = {};
fprintf (f, "B\n");
flush(f);
for (;;) {
- string l = File::fgets(f);
+ string l = timed_read(f, 1000);
+ if (l == "") {
+ File::fprintf(stderr, "read timedout\n");
+ exit(1);
+ }
x[dim(x)] = l;
if (String::index(l, "Altitude:") == 0)
break;
real temperature = string_to_integer(temp[2]) / 100.0;
real altitude = string_to_integer(alt[1]);
- if (altitude < 0 || 3000 < altitude) {
+ if (altitude < -50 || 3000 < altitude) {
printf ("weird altitude %f\n", altitude);
return false;
}