+ P = (int) (((((long) raw_pres * SENS) >> 21) - OFF) >> 15);
+
+ return new AltosPresTemp(P, TEMP / 100.0);
+ }
+
+ public AltosPresTemp pres_temp(AltosLink link) throws InterruptedException, TimeoutException {
+ int raw_pres = AltosLib.MISSING;
+ int raw_temp = AltosLib.MISSING;
+ boolean done = false;
+
+ link.printf("B\n");
+ while (!done) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null)
+ throw new TimeoutException();
+
+ String[] items = line.split("\\s+");
+ if (line.startsWith("Pressure:")) {
+ if (items.length >= 2) {
+ raw_pres = Integer.parseInt(items[1]);
+ }
+ } else if (line.startsWith("Temperature:")) {
+ if (items.length >= 2)
+ raw_temp = Integer.parseInt(items[1]);
+ } else if (line.startsWith("Altitude:")) {
+ done = true;
+ }
+ }
+ return pres_temp(raw_pres, raw_temp);
+ }
+
+ public AltosMs5607(boolean ms5611) {
+ this.ms5611 = ms5611;
+ }
+
+ public AltosMs5607() {
+ this(false);
+ }
+
+ public AltosMs5607(AltosMs5607 old) {
+ reserved = old.reserved;
+ sens = old.sens;
+ off = old.off;
+ tcs = old.tcs;
+ tco = old.tco;
+ tref = old.tref;
+ tempsens = old.tempsens;
+ crc = old.crc;
+ }
+
+ static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
+ try {
+ AltosCalData cal_data = listener.cal_data();
+ AltosMs5607 ms5607 = cal_data.ms5607;
+
+ if (ms5607 != null) {
+ AltosPresTemp pt = ms5607.pres_temp(link);
+ listener.set_temperature(pt.temp);
+ listener.set_pressure(pt.pres);
+ }
+ } catch (TimeoutException te) {
+ }
+ }
+
+ public AltosMs5607(AltosConfigData config_data) {
+ this(config_data.ms5607());