Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated SCMS Files #20

Merged
merged 15 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ jobs:
path: /home/runner/work/asn1-codec/asn1-codec/bw-output
# Archive build-wrapper output

- name: Setup SonarScanner
uses: warchant/setup-sonar-scanner@v4
- uses: actions/setup-java@v3
with:
version: 4.8.0.2856
# Set up SonarScanner for code analysis
distribution: 'temurin'
java-version: '17'

- name: Setup SonarScanner
uses: warchant/setup-sonar-scanner@v7

- name: Generate sonar properties file
run: |
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "pugixml"]
path = pugixml
url = https://github.com/zeux/pugixml.git
[submodule "scms-asn1"]
path = scms-asn1
url = https://github.com/usdot-jpo-ode/scms-asn1.git
[submodule "asn1c"]
path = asn1c
url = https://github.com/mouse07410/asn1c
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@ RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make &&
ADD ./asn1c /asn1_codec/asn1c
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Generate ASN.1 API.
# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
ADD ./asn1c_combined /asn1_codec/asn1c_combined
ADD ./scms-asn1 /asn1_codec/scms-asn1
RUN cd /asn1_codec/asn1c_combined && bash doIt.sh

# Remove any lingering .asn files
RUN rm -rf /asn1c_codec/asn1c_combined/j2735-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/semi-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/scms-asn-files

# Remove duplicate files
RUN rm -rf /asn1c_codec/asn1c_combined/generated-files

# add the source and build files
ADD CMakeLists.txt /asn1_codec
ADD ./config /asn1_codec/config
Expand Down
10 changes: 8 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make &&
ADD ./asn1c /asn1_codec/asn1c
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Generate ASN.1 API.
# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
ADD ./asn1c_combined /asn1_codec/asn1c_combined
ADD ./scms-asn1 /asn1_codec/scms-asn1
RUN cd /asn1_codec/asn1c_combined && bash doIt.sh

# Remove any lingering .asn files
RUN rm -rf /asn1c_codec/asn1c_combined/j2735-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/semi-asn-files

# Remove duplicate files
RUN rm -rf /asn1c_codec/asn1c_combined/generated-files

# add the source and build files
ADD CMakeLists.txt /asn1_codec
ADD ./config /asn1_codec/config
Expand Down
10 changes: 8 additions & 2 deletions Dockerfile.standalone
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make &&
ADD ./asn1c /asn1_codec/asn1c
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Generate ASN.1 API.
# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
ADD ./asn1c_combined /asn1_codec/asn1c_combined
ADD ./scms-asn1 /asn1_codec/scms-asn1
RUN cd /asn1_codec/asn1c_combined && bash doIt.sh

# Remove any lingering .asn files
RUN rm -rf /asn1c_codec/asn1c_combined/j2735-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/semi-asn-files

# Remove duplicate files
RUN rm -rf /asn1c_codec/asn1c_combined/generated-files

# add the source and build files
ADD CMakeLists.txt /asn1_codec
ADD ./config /asn1_codec/config
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,8 @@ There is a provided docker-compose file (docker-compose-confluent-cloud.yml) tha

## Note
This has only been tested with Confluent Cloud but technically all SASL authenticated Kafka brokers can be reached using this method.

# Generating C Files from ASN.1 Definitions
Check here for instructions on how to generate C files from ASN.1 definitions: [ASN.1 C File Generation](asn1c_combined/README.md)

This should only be necessary if the ASN.1 definitions change. The generated files are already included in the repository.
8 changes: 4 additions & 4 deletions asn1c_combined/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.c
*.h
*.o
Makefile*
./*.c
./*.h
./*.o
./Makefile*

15 changes: 10 additions & 5 deletions asn1c_combined/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# doIt.sh Script
The `doIt.sh` script will generate the C code for the J2735 ASN.1 files.
The `doIt.sh` script will copy the generated C code for the specified year into the `asn1c_combined` directory. It will also compile the example converter program.

## J2735 ASN Files
This script expects the necessary files to have already been generated by the `generate-files.sh` script.

## Generating the C Code
The necessary files can be generated using the `generate-files.sh` script. This script will reference the necessary ASN.1 files from the `j2735-asn-files` directory from the specified year and generate the C code in the `generated-files` directory.

### J2735 ASN Files
The 'j2735-asn-files' subdirectory should contain the ASN.1 files for the J2735 standard. These are organized by year.

The `doIt.sh` script will reference the necessary files from the `j2735-asn-files` directory when generating the C code.
The `generate-files.sh` script will reference the necessary files from the `j2735-asn-files` directory when generating the C code.

### Obtaining the J2735 ASN Files
#### Obtaining the J2735 ASN Files
Redistribution of the ASN files is not permitted, so they are not included in this repository. You must obtain them from SAE and place them in the `j2735-asn-files` directory under the appropriate year subdirectory.

A table of the ASN files for each year is provided below.
Expand All @@ -17,7 +22,7 @@ A table of the ASN files for each year is provided below.
| 2020 | https://www.sae.org/standards/content/j2735set_202007/ |

## Environment Variables
The `doIt.sh` script uses the following environment variables:
The `doIt.sh` and `generate-files.sh` scripts uses the following environment variables:
- `J2735_YEAR` - The year of the J2735 standard to use. For example, `2020`.

# Troubleshooting
Expand Down
28 changes: 14 additions & 14 deletions asn1c_combined/doIt.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# This script assumes that the J2735 files have already been generated.
# To generate the J2735 files, run generate-files.sh with asn1c installed.

export LD_LIBRARY_PATH=/usr/local/lib
export CC=gcc

Expand All @@ -10,19 +13,16 @@ else
year=$J2735_YEAR
fi

asn1c -fcompound-names -gen-OER -fincludes-quoted -no-gen-JER -pdu=all \
../scms-asn1/1609dot2-asn/1609dot2-base-types.asn \
../scms-asn1/1609dot2-asn/1609dot2-schema.asn \
./j2735-asn-files/$year/*.asn \
./SEMI_v2.4.0_121223_j2020.asn \
2>&1 | tee compile.out

# if 2020, copy overrides
if [ "$year" == "2020" ]; then
echo "Copying overrides for $year"
cp ./j2735-asn-files/$year/overrides/*.h .
fi
# Copy generated files to for specified year to asn1c_combined & extract
echo "Extracting & copying generated files for $year"
tar -xzf ./generated-files/$year.tar.gz
cp ./generated-files/$year/* .

sed -i 's/\(-DASN_PDU_COLLECTION\)/-DPDU=MessageFrame \1/' converter-example.mk
# Compile example
echo "Compiling example"
sed -i 's/\(-DASN_PDU_COLLECTION\)/-DPDU=MessageFrame \1/' ./converter-example.mk
make -f ./converter-example.mk

make -f converter-example.mk
# Clean up
echo "Cleaning up"
rm -rf ./generated-files/$year
43 changes: 43 additions & 0 deletions asn1c_combined/generate-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# This script generates the J2735 files for a given year.
# The generated files are included in source control, so this script should only
# need to be run when the J2735 files need to be updated.

export LD_LIBRARY_PATH=/usr/local/lib
export CC=gcc

# if J2735_YEAR is not set, default to 2020
if [ -z "$J2735_YEAR" ]; then
year="2020"
else
year=$J2735_YEAR
fi

# if generated-files directory does not exist, create it
if [ ! -d "./generated-files" ]; then
mkdir ./generated-files
fi

# if generated-files/year directory does not exist, create it
if [ ! -d "./generated-files/$year" ]; then
mkdir ./generated-files/$year
fi

asn1c -fcompound-names -gen-OER -fincludes-quoted -no-gen-JER -pdu=all \
./scms-asn-files/*.asn \
./j2735-asn-files/$year/*.asn \
./semi-asn-files/$year/SEMI*.asn \
-D ./generated-files/$year \
2>&1 | tee compile.out

# if 2020, copy overrides
if [ "$year" == "2020" ]; then
echo "Copying overrides for $year"
cp ./j2735-asn-files/$year/overrides/*.h ./generated-files/$year
fi

# tar generated files and delete originals
echo "Tarring generated files for $year"
tar -czf ./generated-files/$year.tar.gz ./generated-files/$year/*
rm -rf ./generated-files/$year
Binary file added asn1c_combined/generated-files/2016.tar.gz
Binary file not shown.
Binary file added asn1c_combined/generated-files/2020.tar.gz
Binary file not shown.
39 changes: 39 additions & 0 deletions asn1c_combined/scms-asn-files/EtsiTs103097ExtensionModule.asn
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
EtsiTs103097ExtensionModule {itu-t(0) identified-organization(4) etsi(0)
itsDomain(5) wg5(5) secHeaders(103097) extension(2) major-version-1(1)
minor-version-0(0)}

DEFINITIONS AUTOMATIC TAGS ::= BEGIN

IMPORTS
EXT-TYPE,
Extension,
ExtId
FROM
Ieee1609Dot2BaseTypes {iso(1) identified-organization(3) ieee(111)
standards-association-numbered-series-standards(2) wave-stds(1609) dot2(2)
base(1) base-types(2) major-version-2(2) minor-version-4(4)}
WITH SUCCESSORS
;

ExtensionModuleVersion ::= INTEGER(1)

EtsiOriginatingHeaderInfoExtension ::=
Extension{{EtsiTs103097HeaderInfoExtensions}}

EtsiTs103097HeaderInfoExtensionId ::= ExtId
etsiTs102941CrlRequestId EtsiTs103097HeaderInfoExtensionId ::= 1
etsiTs102941DeltaCtlRequestId EtsiTs103097HeaderInfoExtensionId ::= 2

EtsiTs103097HeaderInfoExtensions EXT-TYPE ::= {
{ EtsiTs102941CrlRequest IDENTIFIED BY etsiTs102941CrlRequestId } |
{ EtsiTs102941DeltaCtlRequest IDENTIFIED BY etsiTs102941DeltaCtlRequestId },
...
}

EtsiTs102941CrlRequest ::= NULL

EtsiTs102941CtlRequest ::= NULL

EtsiTs102941DeltaCtlRequest ::= EtsiTs102941CtlRequest

END
Loading
Loading