+
+ static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
+ try {
+ AltosIMU imu = new AltosIMU(link);
+ AltosCalData cal_data = listener.cal_data();
+
+ if (imu != null) {
+ listener.set_gyro(cal_data.gyro_roll(imu.gyro_y),
+ cal_data.gyro_pitch(imu.gyro_x),
+ cal_data.gyro_yaw(imu.gyro_z));
+ listener.set_accel_ground(imu.accel_y,
+ imu.accel_x,
+ imu.accel_z);
+ }
+ } catch (TimeoutException te) {
+ }
+ }
+
+ public AltosIMU() {
+ accel_x = AltosLib.MISSING;
+ accel_y = AltosLib.MISSING;
+ accel_z = AltosLib.MISSING;
+
+ gyro_x = AltosLib.MISSING;
+ gyro_y = AltosLib.MISSING;
+ gyro_z = AltosLib.MISSING;
+ }
+
+ public AltosIMU(AltosLink link) throws InterruptedException, TimeoutException {
+ this();
+ link.printf("I\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null) {
+ throw new TimeoutException();
+ }
+ if (parse_string(line))
+ break;
+ }
+ }