+
+ public AltosMag() {
+ x = AltosLib.MISSING;
+ z = AltosLib.MISSING;
+ y = AltosLib.MISSING;
+ }
+
+ static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
+ try {
+ AltosMag mag = new AltosMag(link);
+ AltosCalData cal_data = listener.cal_data();
+
+ if (mag != null)
+ listener.set_mag(cal_data.mag_along(mag.y),
+ cal_data.mag_across(mag.x),
+ cal_data.mag_through(mag.z));
+ } catch (TimeoutException te) {
+ }
+ }
+
+ public AltosMag(AltosLink link) throws InterruptedException, TimeoutException {
+ this();
+ link.printf("M\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null) {
+ throw new TimeoutException();
+ }
+ if (parse_string(line))
+ break;
+ }
+ }