Skip to content

Commit

Permalink
fix(geneactive): trim whitespace when parsing header
Browse files Browse the repository at this point in the history
Integer.paserInt(...) fails if there are whitespaces, so .trim() before that.
  • Loading branch information
chanshing committed Jul 4, 2024
1 parent e255fb3 commit 10579ed
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/accelerometer/java/GENEActivReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ private static int parseBinFileHeader(BufferedReader reader, int fileHeaderSize,
}
// read axes calibration lines for gain and offset values
// data like -> x gain:25548 \n x offset:574 ... Volts:300 \n Lux:800
gainVals[0] = Double.parseDouble(readLine(reader).split(":")[1]); // xGain
offsetVals[0] = Integer.parseInt(readLine(reader).split(":")[1]); // xOffset
gainVals[1] = Double.parseDouble(readLine(reader).split(":")[1]); // y
offsetVals[1] = Integer.parseInt(readLine(reader).split(":")[1]); // y
gainVals[2] = Double.parseDouble(readLine(reader).split(":")[1]); // z
offsetVals[2] = Integer.parseInt(readLine(reader).split(":")[1]); // z
int volts = Integer.parseInt(readLine(reader).split(":")[1]); // volts
int lux = Integer.parseInt(readLine(reader).split(":")[1]); // lux
gainVals[0] = Double.parseDouble(readLine(reader).split(":")[1].trim()); // xGain
offsetVals[0] = Integer.parseInt(readLine(reader).split(":")[1].trim()); // xOffset
gainVals[1] = Double.parseDouble(readLine(reader).split(":")[1].trim()); // y
offsetVals[1] = Integer.parseInt(readLine(reader).split(":")[1].trim()); // y
gainVals[2] = Double.parseDouble(readLine(reader).split(":")[1].trim()); // z
offsetVals[2] = Integer.parseInt(readLine(reader).split(":")[1].trim()); // z
int volts = Integer.parseInt(readLine(reader).split(":")[1].trim()); // volts
int lux = Integer.parseInt(readLine(reader).split(":")[1].trim()); // lux
readLine(reader); // 9 blank
readLine(reader); // 10 memory status header
int memorySizePages = Integer.parseInt(readLine(reader).split(":")[1]); // 11
int memorySizePages = Integer.parseInt(readLine(reader).split(":")[1].trim()); // 11

// ignore remaining header lines in bin file
for (int i = 0; i < fileHeaderSize - linesToAxesCalibration - 11; i++) {
Expand Down

0 comments on commit 10579ed

Please sign in to comment.