diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/PayloadParser.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/PayloadParser.java index 9b618e2d5..67186f3ae 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/PayloadParser.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/PayloadParser.java @@ -31,7 +31,7 @@ public class PayloadParser extends LogFileParser { private static Logger logger = LoggerFactory.getLogger(PayloadParser.class); - private static final String BSM_START_FLAG = "0014"; // these bytes indicate + private static final String BSM_START_FLAG = "001f"; // these bytes indicate // start of BSM payload private static final int HEADER_MINIMUM_SIZE = 20; // WSMP headers are at // least 20 bytes long @@ -108,7 +108,6 @@ public void writeTo(OutputStream os) throws IOException { public byte[] removeHeader(byte[] packet) { String hexPacket = HexUtils.toHexString(packet); - logger.debug("RemoveHeader recordType: " + recordType); int startIndex = hexPacket.indexOf(BSM_START_FLAG); if (startIndex == 0) { logger.debug("Message is raw BSM with no headers."); @@ -121,6 +120,8 @@ public byte[] removeHeader(byte[] packet) { } else { // We likely found a message with a header, look past the first 20 // bytes for the start of the BSM + logger.debug("Found payload start at: " + startIndex); + logger.debug("Payload hex: " + hexPacket); int trueStartIndex = HEADER_MINIMUM_SIZE + hexPacket.substring(HEADER_MINIMUM_SIZE, hexPacket.length()).indexOf(BSM_START_FLAG); hexPacket = hexPacket.substring(trueStartIndex, hexPacket.length()); diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/RxMsgFileParser.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/RxMsgFileParser.java index 5eeaf41c3..0623c90b3 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/RxMsgFileParser.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/RxMsgFileParser.java @@ -22,6 +22,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import us.dot.its.jpo.ode.model.OdeBsmMetadata.BsmSource; import us.dot.its.jpo.ode.model.RxSource; public class RxMsgFileParser extends LogFileParser { @@ -46,40 +47,47 @@ public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws F ParserStatus status; try { status = super.parseFile(bis, fileName); + logger.debug("RxMsgFileParser start"); if (status != ParserStatus.COMPLETE) return status; // parse rxSource if (getStep() == 1) { + logger.debug("RxMsgFileParser step 1"); status = parseStep(bis, RX_SOURCE_LENGTH); if (status != ParserStatus.COMPLETE) return status; try { - setRxSource(RxSource.values()[readBuffer[0]]); + setRxSource(readBuffer[0]); } catch (Exception e) { + logger.debug("exception"); setRxSource(RxSource.UNKNOWN); } } if (getStep() == 2) { + logger.debug("RxMsgFileParser step 2"); status = nextStep(bis, fileName, locationParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 3) { + logger.debug("RxMsgFileParser step 3"); status = nextStep(bis, fileName, timeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 4) { + logger.debug("RxMsgFileParser step 4"); status = nextStep(bis, fileName, secResCodeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 5) { + logger.debug("RxMsgFileParser step 5"); status = nextStep(bis, fileName, payloadParser); if (status != ParserStatus.COMPLETE) return status; @@ -101,12 +109,19 @@ public RxSource getRxSource() { } public void setRxSource(RxSource rxSource) { + logger.debug("rxSourceOrdinal value: " + rxSource); this.rxSource = rxSource; } public void setRxSource(int rxSourceOrdinal) { try { - setRxSource(RxSource.values()[rxSourceOrdinal]); + if (rxSourceOrdinal != 10){ + logger.debug("rxSourceOrdinal value: " + rxSourceOrdinal); + setRxSource(RxSource.values()[rxSourceOrdinal]); + } else { + logger.debug("Removing newline character"); + setStep(1); + } } catch (Exception e) { logger.error("Invalid RxSource: {}. Valid values are {}: ", rxSourceOrdinal, RxSource.values());