diff options
| author | Bdale Garbee <bdale@gag.com> | 2014-09-09 23:28:39 -0600 | 
|---|---|---|
| committer | Bdale Garbee <bdale@gag.com> | 2014-09-09 23:28:39 -0600 | 
| commit | 16405fd3eb6f82ef3a709e3ed30fc48faef7b547 (patch) | |
| tree | c111819b3ba0c9357af41c81b798326b9df7adad /altoslib/AltosMma655x.java | |
| parent | 5a2f6ed6210844f7284fbf9f7ecba68c8a14fa52 (diff) | |
| parent | 28bd5057252e61bc5b1a35a00bc1f9fdfde097f7 (diff) | |
Merge branch 'branch-1.5' into debian
Conflicts:
	ChangeLog
	Releasing
	altosui/Instdrv/NSIS/Includes/java.nsh
	altosui/altos-windows.nsi.in
	configure.ac
	doc/Makefile
	doc/altusmetrum.xsl
	micropeak/micropeak-windows.nsi.in
	telegps/telegps-windows.nsi.in
Diffstat (limited to 'altoslib/AltosMma655x.java')
| -rw-r--r-- | altoslib/AltosMma655x.java | 24 | 
1 files changed, 13 insertions, 11 deletions
diff --git a/altoslib/AltosMma655x.java b/altoslib/AltosMma655x.java index cb2e63d4..7f0dab98 100644 --- a/altoslib/AltosMma655x.java +++ b/altoslib/AltosMma655x.java @@ -15,7 +15,7 @@   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.   */ -package org.altusmetrum.altoslib_4; +package org.altusmetrum.altoslib_5;  import java.util.concurrent.*; @@ -23,14 +23,15 @@ public class AltosMma655x implements Cloneable {  	int	accel; -	public boolean parse_line(String line) { -		String[] items = line.split("\\s+"); -		if (line.startsWith("MMA655X value:")) { -			if (items.length >= 3) -				accel = Integer.parseInt(items[1]); -		} else -			return false; -		return true; +	public boolean parse_line(String line) throws NumberFormatException { +		if (line.startsWith("MMA655X value")) { +			String[] items = line.split("\\s+"); +			if (items.length >= 3) { +				accel = Integer.parseInt(items[2]); +				return true; +			} +		} +		return false;  	}  	public AltosMma655x() { @@ -51,17 +52,18 @@ public class AltosMma655x implements Cloneable {  			if (mma655x != null)  				state.set_accel(mma655x.accel);  		} catch (TimeoutException te) { +		} catch (NumberFormatException ne) {  		}  	} -	public AltosMma655x(AltosLink link) throws InterruptedException, TimeoutException { +	public AltosMma655x(AltosLink link) throws InterruptedException, TimeoutException, NumberFormatException {  		this();  		link.printf("A\n");  		for (;;) {  			String line = link.get_reply_no_dialog(5000);  			if (line == null)  				throw new TimeoutException(); -			if (!parse_line(line)) +			if (parse_line(line))  				break;  		}  	}  | 
