Skip to content

Commit

Permalink
updates to processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael7371 committed Nov 3, 2023
1 parent 7181f9f commit dc765c2
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 20 deletions.
Binary file added data/rxMsg_commsginia_map.gz
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
package us.dot.its.jpo.ode.coder.stream;

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -207,7 +204,7 @@ public String checkHeader(OdeMsgPayload payload) {
for (String key : msgStartFlags.keySet()) {
String startFlag = msgStartFlags.get(key);
int startIndex = hexPacket.indexOf(startFlag);
if (startIndex < 10 && startIndex != 0 && startIndex != -1) {
if (startIndex <= 20 && startIndex != 0 && startIndex != -1) {
header = "Ieee1609Dot2Data";
}
}
Expand All @@ -220,8 +217,8 @@ public String checkHeader(OdeMsgPayload payload) {

public BufferedInputStream removeNewLine(BufferedInputStream bis) {
try {
bis.mark(1); // Mark the current position in the stream
int nextByte = bis.read(); // Read the next byte
bis.mark(1);
int nextByte = bis.read();
if (nextByte != 10) { // If the next byte is not a newline
bis.reset(); // Reset the stream back to the most recent mark
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DriverAlertFileParser extends LogFileParser {
private static final Logger logger = LoggerFactory.getLogger(DriverAlertFileParser.class);

private String alert;

Expand All @@ -36,6 +31,7 @@ public DriverAlertFileParser() {

@Override
public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws FileParserException {

ParserStatus status;
try {
status = super.parseFile(bis, fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public byte[] removeHeader(byte[] packet) {
logger.debug("Start index for: " + key + " is: " + startIndex);
if (startIndex == -1) {
logger.debug("Message does not have header for: " + key);
} else if (startIndex < 10) {
} else if (startIndex <= HEADER_SIZE) {
logger.debug("Message has supported header. startIndex: " + startIndex + " msgFlag: " + startFlag);
hexPacketParsed = hexPacket;
} else if (startIndex > 20 && startIndex < 35) {
} else if (startIndex > HEADER_SIZE && startIndex < 35) {
int trueStartIndex = HEADER_SIZE
+ hexPacket.substring(HEADER_SIZE, hexPacket.length()).indexOf(startFlag);
logger.debug("Found payload start at: " + trueStartIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,47 +46,40 @@ 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(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;
Expand Down

0 comments on commit dc765c2

Please sign in to comment.