Skip to content

Commit

Permalink
ODE-755 Implemented Lear PR11.03 log file format
Browse files Browse the repository at this point in the history
  • Loading branch information
hmusavi committed Apr 30, 2018
1 parent 01a8a5e commit 8440bfd
Show file tree
Hide file tree
Showing 36 changed files with 608 additions and 1,313 deletions.
91 changes: 35 additions & 56 deletions data/wydotLogRecords.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
#ifndef _LOG_CONFIGURATIONS_H_
#define _LOG_CONFIGURATIONS_H_

#define MAX_ISO_TIME_LEN 23
#define MAX_STRING_LEN 255
#define MAX_PAYLOAD_SIZE 2302 //as per 1609.3 std
typedef enum _rxSource {
RSU = 0,
SAT, //XM satelite
RV, /* for BSM rx */
SNMP /* for SRM payload from backend/ODE*/
} rxSource;

/* securityResultCode contains below result codes */
typedef enum _securityResultCode { /* from dot3 */
Expand Down Expand Up @@ -49,82 +52,58 @@ typedef enum _securityResultCode { /* from dot3 */
spduCertificateExpired = 35
} securityResultCode;

typedef enum _rxSource {
RSU = 0,
SAT, //XM satelite
RV, /* for BSM rx */
SNMP /* for SRM payload from backend/ODE*/
} rxSource;

/* below elements units are as per SAE-2735 */
typedef struct _location {
uint32_t latitude;
uint32_t longitude;
uint32_t elevation;
int32_t latitude;
int32_t longitude;
int32_t elevation;
uint16_t speed;
uint16_t heading;
} __attribute__((__packed__)) location;
/*
* LEAR:
* Respective log files will have dump of below mentioned respective records.
* "DriverAlert_msec_ipv6.csv.gzip" file will have dump of continues "driverAlertRecord" records.
*
* Reading records from file:
* fd = open("BSM30Sec_msec_ipv6.csv", O_RDONLY, 0666);
* read(fd, &bsmTxRecord.timeInISO, MAX_ISO_TIME_LEN);
* read(fd, &bsmTxRecord.length, 2(size of length:uint16_t));
* read(fd, &bsmTxRecord.payload, bsmTxRecord.length);
*/

typedef struct _driverAlertRecord {
location curLocation;
uint32_t utctimeInSec;
uint16_t mSec;
uint32_t utcTimeInSec;
uint16_t msec;
uint16_t length;
char alert[MAX_STRING_LEN]; //LEAR: Alert will be a string.
/* payload of length size*/
} __attribute__((__packed__)) driverAlertRecord;

typedef struct _bsmTxRecord {
uint8_t direction; //0 for EV(Tx), 1 for RV(Rx)
uint32_t utctimeInSec;
uint16_t mSec;
typedef struct _bsmLogRecHeader {
uint8_t direction; //EV_BSM=0, RV_BSM=1
location curLocation;
uint32_t utcTimeInSec;
uint16_t msec;
int8_t signStatus;
uint16_t length;
uint8_t payload[MAX_PAYLOAD_SIZE]; //LEAR: RAW 1609.2 format of Transmitted BSM
} __attribute__((__packed__)) bsmTxRecord;
/* payload of length size*/
} __attribute__((__packed__)) bsmLogRecHeader;

typedef struct _receivedMsgRecord {
uint8_t rxFrom; /* refer rxSource for values */
location curLocation;
uint32_t utctimeInSec;
uint16_t mSec;
rxSource rxFrom;
int8_t verificationStatus;
uint32_t utcTimeInSec;
uint16_t msec;
int8_t verificationStatus;
uint16_t length;
uint8_t payload[MAX_PAYLOAD_SIZE]; //LEAR: RAW 1609.2 format of TIM
/* payload of length size*/
} __attribute__((__packed__)) receivedMsgRecord;

typedef struct _bsmRxRecord {
uint8_t direction; //0 for EV(Tx), 1 for RV(Rx)
uint32_t utctimeInSec;
uint16_t mSec;
int8_t verificationStatus;
uint16_t length;
uint8_t payload[MAX_PAYLOAD_SIZE]; //LEAR: RAW 1609.2 format of Rx BSM
} __attribute__((__packed__)) bsmRxRecord;

typedef struct _dnmMsgRecord {
location curLocation;
uint32_t utctimeInSec;
uint16_t mSec;
uint32_t utcTimeInSec;
uint16_t msec;
int8_t verificationStatus;
uint16_t length;
uint8_t payload[MAX_PAYLOAD_SIZE]; //LEAR: RAW 1609.2 format of Tx & Rx DN TIM
/* payload of length size*/
} __attribute__((__packed__)) dnmMsgRecord;

/*
* LEAR:
* FW upgrade, System Logs will be logged to
* FW upgrade, SCMS, System Logs will be logged to
* respective log files in "syslog" format as mentioned
* in below eaxmple:
* May 2 21:30:36 wsarx: Consistency check failed [WS_ERR_NO_CA_CERTIFICATE].
* Do you prefer ISO time format here also??
*/
typedef struct _scmsRecord {
/* TODO */
Expand All @@ -135,11 +114,11 @@ typedef struct _scmsRecord {
*
*/
typedef struct _updatesSystemLogRecord {
//LEAR: Location & time are added in this record to know where & when exactly updates, boot, shutdown and any system events(application re-starts/crashes/errors) are happend. Since frequency of these messages are less not much over air over head by adding these.
location curLocation;
uint32_t utctimeInSec;
uint16_t mSec;
uint32_t utcTimeInSec;
uint16_t msec;
uint16_t length;
char logString[MAX_STRING_LEN]; //LEAR: will be a string
/* payload of length size*/
} __attribute__((__packed__)) updatesSystemLogRecord;

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class AppContext {
public static final String PAYLOAD_STRING = "payload";
public static final String METADATA_STRING = "metadata";
public static final String DATA_STRING = "data";
public static final String METADATA_VIOLATIONS_STRING = "violations";
public static final String ENCODINGS_STRING = "encodings";
public static final String PAYLOAD_TYPE_STRING = "payloadType";
public static final String DATA_TYPE_STRING = "dataType";
public static final String SERIAL_ID_STRING = "serialId";
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package us.dot.its.jpo.ode.model;

import java.util.ArrayList;
import java.util.List;

public class OdeLogMetadata extends OdeMsgMetadata {

private static final long serialVersionUID = -8601265839394150140L;
Expand Down Expand Up @@ -47,10 +50,11 @@ public enum SecurityResultCode {
spduCertificateExpired
}


private String logFileName;
private RecordType recordType;
private SecurityResultCode securityResultCode;
private ReceivedMessageDetails receivedMessageDetails;
private List<Asn1Encoding> encodings = new ArrayList<Asn1Encoding>();

public OdeLogMetadata(OdeMsgPayload payload) {
super(payload);
Expand Down Expand Up @@ -88,4 +92,25 @@ public void setSecurityResultCode(SecurityResultCode securityResultCode) {
this.securityResultCode = securityResultCode;
}

public ReceivedMessageDetails getReceivedMessageDetails() {
return receivedMessageDetails;
}

public void setReceivedMessageDetails(ReceivedMessageDetails receivedMessageDetails) {
this.receivedMessageDetails = receivedMessageDetails;
}

public List<Asn1Encoding> getEncodings() {
return encodings;
}

public void setEncodings(List<Asn1Encoding> encodings) {
this.encodings = encodings;
}

public OdeLogMetadata addEncoding(Asn1Encoding encoding) {
encodings.add(encoding);
return this;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package us.dot.its.jpo.ode.model;

public enum RxSource {
RSU, SAT, RV, SNMP, NA
RSU, SAT, RV, SNMP, NA, unknown
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public BsmDecoderHelper() {
public OdeData decode(BsmLogFileParser bsmFileParser, SerialId serialId) throws Exception {

Ieee1609Dot2Data ieee1609dot2Data =
ieee1609dotCoder.decodeIeee1609Dot2DataBytes(bsmFileParser.getPayload());
ieee1609dotCoder.decodeIeee1609Dot2DataBytes(bsmFileParser.getPayloadParser().getPayload());
OdeObject bsm = null;
OdeData odeBsmData = null;
IEEE1609p2Message message = null;
Expand All @@ -55,7 +55,7 @@ public OdeData decode(BsmLogFileParser bsmFileParser, SerialId serialId) throws
}
} else {
// probably raw BSM or MessageFrame
bsm = rawBsmMFSorterIn.decodeBsm(bsmFileParser.getPayload());
bsm = rawBsmMFSorterIn.decodeBsm(bsmFileParser.getPayloadParser().getPayload());
}
if (bsm != null) {
logger.debug("Decoded BSM successfully, creating OdeBsmData object.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,19 @@
import org.springframework.beans.factory.annotation.Autowired;

import us.dot.its.jpo.ode.OdeProperties;
import us.dot.its.jpo.ode.coder.stream.BinaryDecoderPublisher;
import us.dot.its.jpo.ode.coder.stream.HexDecoderPublisher;
import us.dot.its.jpo.ode.coder.stream.JsonDecoderPublisher;
import us.dot.its.jpo.ode.importer.ImporterDirectoryWatcher.ImporterFileType;
import us.dot.its.jpo.ode.wrapper.serdes.OdeBsmSerializer;
import us.dot.its.jpo.ode.wrapper.serdes.OdeTimSerializer;

public class FileDecoderPublisher {

private static final Logger logger = LoggerFactory.getLogger(FileDecoderPublisher.class);

private JsonDecoderPublisher jsonDecPub;
private HexDecoderPublisher hexDecPub;
private BinaryDecoderPublisher binDecPub;

@Autowired
public FileDecoderPublisher(OdeProperties odeProperties) {

OdeStringPublisher bsmStringMsgPub = new OdeStringPublisher(odeProperties);
OdeDataPublisher bsmByteMsgPub = new OdeDataPublisher(odeProperties, OdeBsmSerializer.class.getName());
OdeDataPublisher timByteMsgPub = new OdeDataPublisher(odeProperties, OdeTimSerializer.class.getName());

this.jsonDecPub = new JsonDecoderPublisher(bsmStringMsgPub);
this.hexDecPub = new HexDecoderPublisher(bsmByteMsgPub);
this.binDecPub = new BinaryDecoderPublisher(bsmByteMsgPub, timByteMsgPub);
}

public void decodeAndPublishFile(
Expand All @@ -44,16 +32,8 @@ public void decodeAndPublishFile(
logger.info("Decoding and publishing file {}", fileName);

try {
if (filePath.toString().endsWith(".hex") || filePath.toString().endsWith(".txt")) {
logger.info("Decoding {} as hex file.", filePath);
hexDecPub.decodeAndPublish(fileInputStream, fileName, fileType);
} else if (filePath.toString().endsWith(".json")) {
logger.info("Decoding {} as json file.", filePath);
jsonDecPub.decodeAndPublish(fileInputStream, fileName, fileType);
} else {
logger.info("Decoding {} as binary/signed file.", filePath);
binDecPub.decodeAndPublish(fileInputStream, fileName, fileType);
}
logger.info("Decoding {} as json file.", filePath);
jsonDecPub.decodeAndPublish(fileInputStream, fileName, fileType);
} catch (Exception e) {
logger.error("Failed to decode and publish file.", e);
}
Expand Down
Loading

0 comments on commit 8440bfd

Please sign in to comment.