Skip to content

Commit

Permalink
Container PDU support.
Browse files Browse the repository at this point in the history
Co-authored-by: Kiran Gowda Kempanna <[email protected]>
Signed-off-by: Rule Timothy (VM/EMT3) <[email protected]>
  • Loading branch information
timrulebosch and Kiran Gowda Kempanna committed Apr 29, 2024
1 parent 45ebdc5 commit d1e4946
Show file tree
Hide file tree
Showing 38 changed files with 1,975 additions and 340 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export DSE_CLIB_VERSION ?= 1.0.12

###############
## DSE Model C Library
export DSE_MODELC_VERSION ?= 2.0.12
export DSE_MODELC_VERSION ?= 2.0.13


###############
Expand Down
109 changes: 107 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,92 @@ vars:
GCC_TAG: main

tasks:

generate:
run: always
dir: '{{.USER_WORKING_DIR}}'
label: dse:network:generate-{{.DBCFILE}}
vars:
SIGNAL: '{{.SIGNAL | default "SIGNAL_NOT_SPECIFIED"}}'
MIMETYPE: '{{.MIMETYPE | default "MIMETYPE_NOT_SPECIFIED"}}'
DBCFILE: '{{.DBCFILE | default "DBCFILE_NOT_SPECIFIED"}}'
ARXML: '{{.ARXML | default ""}}'
DBCDIR:
sh: dirname {{.DBCFILE}}
OUTDIR: '{{default .DBCDIR .OUTDIR}}'
FUNCTION_LIB: '{{.FUNCTION_PATCH | default ""}}'
FUNCTION_PATCH: '{{.FUNCTION_PATCH | default ""}}'
SIGNAL_PATCH: '{{.SIGNAL_PATCH | default ""}}'
REMOVE_UNKNOWN: '{{.REMOVE_UNKNOWN | default ""}}'
PACKAGE_ARCH: '{{.PACKAGE_ARCH | default ""}}'
cmds:
- task: "{{if .ARXML}}convert-arxml{{else}}generate-dbc{{end}}"
requires:
vars: [DBCFILE, SIGNAL, MIMETYPE]
sources:
- '{{.PWD}}/{{.DBCFILE}}'
- '{{.PWD}}/{{.ARXML}}'
generates:
- '{{.PWD}}/{{.OUTDIR}}/**'

convert-arxml:
run: always
dir: '{{.USER_WORKING_DIR}}'
label: dse:network:generate-{{.ARXML}}
vars:
ARXML: '{{.ARXML | default "ARXML_NOT_SPECIFIED"}}'
DBCDIR:
sh: dirname {{.ARXML}}
OUTDIR: '{{default .DBCDIR .OUTDIR}}'
SIGNAL: '{{.SIGNAL | default "SIGNAL_NOT_SPECIFIED"}}'
MIMETYPE: '{{.MIMETYPE | default "MIMETYPE_NOT_SPECIFIED"}}'
FUNCTION_LIB: '{{.FUNCTION_PATCH | default ""}}'
FUNCTION_PATCH: '{{.FUNCTION_PATCH | default ""}}'
SIGNAL_PATCH: '{{.SIGNAL_PATCH | default ""}}'
REMOVE_UNKNOWN: '{{.REMOVE_UNKNOWN | default ""}}'
IMAGE: '{{.IMAGE | default .NETWORK_IMAGE}}'
TAG: '{{.TAG | default .NETWORK_TAG}}'
cmds:
- docker run --rm -v $(pwd):/sim {{.IMAGE}}:{{.TAG}} convert-arxml {{.ARXML}} {{.OUTDIR}}
- task: find-dbc
requires:
vars: [ARXML, SIGNAL, MIMETYPE]
sources:
- '{{.PWD}}/{{.ARXML}}'
generates:
- '{{.PWD}}/{{.OUTDIR}}/**'

find-dbc:
run: always
dir: '{{.USER_WORKING_DIR}}'
label: dse:network:generate-{{.ARXML}}
vars:
SIGNAL: '{{.SIGNAL | default "SIGNAL_NOT_SPECIFIED"}}'
MIMETYPE: '{{.MIMETYPE | default "MIMETYPE_NOT_SPECIFIED"}}'
ARXML: '{{.ARXML | default "ARXML_NOT_SPECIFIED"}}'
DBCDIR:
sh: dirname {{.ARXML}}
OUTDIR: '{{default .DBCDIR .OUTDIR}}'
FUNCTION_LIB: '{{.FUNCTION_PATCH | default ""}}'
FUNCTION_PATCH: '{{.FUNCTION_PATCH | default ""}}'
SIGNAL_PATCH: '{{.SIGNAL_PATCH | default ""}}'
REMOVE_UNKNOWN: '{{.REMOVE_UNKNOWN | default ""}}'
IMAGE: '{{.IMAGE | default .NETWORK_IMAGE}}'
TAG: '{{.TAG | default .NETWORK_TAG}}'
DBC:
sh: find {{.OUTDIR}} -type f \( -name '*.dbc' -o -name '*.DBC' \)
cmds:
- for: { var: DBC }
task: generate-dbc
vars: { DBCFILE: '{{.ITEM}}' }
requires:
vars: [ARXML, SIGNAL, MIMETYPE]
sources:
- '{{.PWD}}/{{.ARXML}}'
generates:
- '{{.PWD}}/{{.OUTDIR}}/**'

generate-dbc:
run: always
dir: '{{.USER_WORKING_DIR}}'
label: dse:network:generate-{{.DBCFILE}}
Expand Down Expand Up @@ -80,11 +165,12 @@ tasks:
MESSAGE_LIB_FILE: '{{.OUTDIR}}/{{.MESSAGE_LIB}}'
IMAGE: '{{.IMAGE | default .GCC_IMAGE}}'
TAG: '{{.TAG | default .GCC_TAG}}'
PACKAGE_ARCH: '{{if eq .PACKAGE_ARCH "linux-x86"}}-mx32{{else}}{{end}}'
cmds:
- docker run --rm -v $(pwd):/sim -w /sim {{.IMAGE}}:{{.TAG}}
gcc -c -Wall -Werror -fpic -o {{.OBJECT_FILE}} {{.SOURCE_FILE}}
gcc {{.PACKAGE_ARCH}} -c -Wall -Werror -fpic -o {{.OBJECT_FILE}} {{.SOURCE_FILE}}
- docker run --rm -v $(pwd):/sim -w /sim {{.IMAGE}}:{{.TAG}}
gcc -shared -o {{.MESSAGE_LIB_FILE}} {{.OBJECT_FILE}}
gcc {{.PACKAGE_ARCH}} -shared -o {{.MESSAGE_LIB_FILE}} {{.OBJECT_FILE}}
requires:
vars: [DBCFILE, OUTDIR]
sources:
Expand Down Expand Up @@ -118,6 +204,7 @@ tasks:
--network {{.NETWORK_FILE}}
--metadata {{.METADATA_FILE}}
--message_lib {{.OUTDIR}}/{{.MESSAGE_LIB}}
--style snake_case
{{.FUNCTION_LIB}}
{{.LABELS}}
{{.ANNOTATIONS}}
Expand Down Expand Up @@ -191,3 +278,21 @@ tasks:
- '{{.PWD}}/{{.NETWORK_FILE}}'
generates:
- '{{.PWD}}/{{.SIGGROUP_FILE}}'

set-mimetype:
run: when_changed
dir: '{{.USER_WORKING_DIR}}'
label: dse:network:gen-signalgroup-{{.DBCFILE}}
vars:
SIGNAL: '{{.SIGNAL | default "SIGNAL_NOT_SPECIFIED"}}'
MIMETYPE: '{{.MIMETYPE | default "MIMETYPE_NOT_SPECIFIED"}}'
OUTDIR: '{{.OUTDIR | default "OUTDIR_NOT_SPECIFIED"}}'
IMAGE: '{{.IMAGE | default .NETWORK_IMAGE}}'
TAG: '{{.TAG | default .NETWORK_TAG}}'
cmds:
- docker run --rm -v $(pwd):/sim {{.IMAGE}}:{{.TAG}} set-mimetype
--output_directory {{.OUTDIR}}
--signal {{.SIGNAL}}
--mimetype "{{.MIMETYPE}}"
requires:
vars: [OUTDIR, SIGNAL, MIMETYPE]
59 changes: 43 additions & 16 deletions dse/network/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,32 @@ uint32_t simbus_generate_uid_hash(const uint8_t* key, size_t len)
}


static void _process_can_frame(Network* network, NCodecCanMessage* msg)
static void _process_message(
Network* network, NetworkMessage* message, NCodecCanMessage* msg)
{
/* Find the matching message. */
NetworkMessage* message = NULL;
NetworkMessage* nm_p = network->messages;
while (nm_p->frame_id) {
if (nm_p->frame_id == msg->frame_id) {
message = nm_p;
break;
message->unpack_func(message->buffer, msg->buffer, msg->len);
if (message->mux_signal && message->mux_signal->mux_mi) {
/* This is a container message, also process the contained message. */
MarshalItem* mi = message->mux_signal->mux_mi;
network_marshal_messages_to_signals(network, mi, true);
uint32_t mux_id = network->signal_vector[mi->signal_vector_index];
/* Locate the mux message. */
NetworkMessage* mux_message = NULL;
NetworkMessage* nm_p = network->messages;
while (mux_id && nm_p->frame_id) {
if (nm_p->frame_id == msg->frame_id) {
if (nm_p->mux_id == mux_id) {
mux_message = nm_p;
break;
}
}
/* Next message. */
nm_p++;
}
if (mux_message) {
_process_message(network, mux_message, msg);
}
/* Next message. */
nm_p++;
}
if (message == NULL) {
log_debug("Network does not have frame_id : %d", msg->frame_id);
return;
};

message->unpack_func(message->buffer, msg->buffer, msg->len);

/* Calculate the checksum for the payload. */
uint32_t payload_checksum =
Expand All @@ -63,6 +70,26 @@ static void _process_can_frame(Network* network, NCodecCanMessage* msg)
log_debug("decode path checksum %d", payload_checksum);
}

static void _process_can_frame(Network* network, NCodecCanMessage* msg)
{
/* Find the matching message. */
NetworkMessage* message = NULL;
NetworkMessage* nm_p = network->messages;
while (nm_p->frame_id) {
if (nm_p->frame_id == msg->frame_id) {
message = nm_p;
break;
}
/* Next message. */
nm_p++;
}
if (message) {
_process_message(network, message, msg);
} else {
log_debug("Network does not have frame_id : %d", msg->frame_id);
}
}

void network_decode_from_bus(Network* network, void* nc)
{
assert(network);
Expand Down
Loading

0 comments on commit d1e4946

Please sign in to comment.