Skip to content

Instantly share code, notes, and snippets.

@tekjar
Created November 2, 2019 14:26
Show Gist options
  • Save tekjar/0ff4eef14d75daf722f9f748e5a3a85e to your computer and use it in GitHub Desktop.
Save tekjar/0ff4eef14d75daf722f9f748e5a3a85e to your computer and use it in GitHub Desktop.
# {
# packet_type”: “can_raw”,
# "can_id" : “0x148”,
# “data”: “0xdeadbeef”,
# “Timestamp: “1572062547300”,
# }
# processor will call enricher.Enrich("packet type", "message type", "version", "data")
# generated code's function signature
#
# func Enrich(packetType string, messageType string, version string, data interface{}) map[string]interface{} {
#data will be casted to array of bytes based on filter type. byte manipulation in this casecp
# }
[components.can.rule1]
filters = {can_id = "0x148", dev = "can0"}
[components.can.rule1.outputs]
bms_voltage = "float32(int(bytes[7]) * 256 * 256 + int(bytes[6]) * 256 + int(bytes[5]))"
bms_mode = "float32((bytes[3] >> 1) & 1)"
[components.can.rule2]
filters = {can_id = "0x148", dev = "can1"}
[components.can.rule2.outputs]
bms_voltage = "float32(int(bytes[5]) * 256 * 256 + int(bytes[4]) * 256 + int(bytes[3]))"
bms_mode = "float32((bytes[3] >> 1) & 1)"
[components.can.rule3]
filters = {can_id = "0x149"}
[components.can.rule3.outputs]
bms_current = "float32(bytes[0])"
# {
# “packet_type”: “gps”,
# “message_type”: “gll”,
# “data”: “$GPGLL,4916.45,N,12311.12,W,225444,A,*1D”,
# “Timestamp: “1572062547300”,
# }
[components.gps.rule1]
filters = {message_type = "gll"}
[components.gps.rule1.outputs]
latitude = "float32((bytes[3] >> 1) & 1)"
longitude = "float32((bytes[3] >> 1) & 1)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment