Skip to content

Commit

Permalink
Merge remote-tracking branch 'EsaRepo/master' into scala-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Schramka committed Dec 13, 2023
2 parents 31feeaf + 1ddce9c commit c7b4fb1
Show file tree
Hide file tree
Showing 16 changed files with 485 additions and 150 deletions.
7 changes: 6 additions & 1 deletion ADA_RTL2/src/adaasn1rtl-encoding-test_cases_aux.adb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ package body adaasn1rtl.encoding.test_cases_aux is

procedure Write_BitStream_To_File (bs : Bitstream; Filename : String) is
Out_File : Seq_IO.File_Type;
nFileLen : constant Integer :=
bs.Current_Bit_Pos / 8 +
(if bs.Current_Bit_Pos mod 8 > 0 then 1 else 0)
;

begin
Seq_IO.Create (Out_File, Seq_IO.Out_File, Filename);
for i in bs.Buffer'Range loop
for i in bs.Buffer'First .. nFileLen loop
Seq_IO.Write (Out_File, bs.Buffer (i));
end loop;

Expand Down
6 changes: 3 additions & 3 deletions BackendAst/GenerateFiles.fs
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,19 @@ let private printUnit (r:DAst.AstRoot) (lm:LanguageMacros) (encodings: CommonTy

tstCasesHdrContent |> Option.iter(fun tstCasesHdrContent -> File.WriteAllText(testcase_SrcFileName, tstCasesHdrContent.Replace("\r","")))


(defintionsContntent, srcBody)



let generateAll (di:DirInfo) (r:DAst.AstRoot) (lm:LanguageMacros) (encodings: CommonTypes.Asn1Encoding list) =
r.programUnits |> Seq.iter (printUnit r lm encodings di.srcDir)
let generatedContent = r.programUnits |> List.map(printUnit r lm encodings di.srcDir) |> List.map snd |> Seq.StrJoin "\n"
match r.args.generateAutomaticTestCases with
| false -> ()
| true ->
lm.lg.CreateMakeFile r di
let arrsSrcTstFiles, arrsHdrTstFiles = DastTestCaseCreation.printAllTestCasesAndTestCaseRunner r lm di.srcDir
lm.lg.CreateAuxFiles r di (arrsSrcTstFiles, arrsHdrTstFiles)

generatedContent


let EmmitDefaultACNGrammar (r:AstRoot) outDir =
Expand Down
1 change: 1 addition & 0 deletions CommonTypes/CommonTypes.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<Compile Include="FsUtils.fs" />
<Compile Include="RemoveUnusedRtlFunction.fs" />
<Compile Include="CommonTypes.fs" />
<Compile Include="AbstractMacros.fs" />
<Compile Include="RangeSets.fs" />
Expand Down
16 changes: 16 additions & 0 deletions CommonTypes/RemoveUnusedRtlFunction.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module RemoveUnusedRtlFunction


let findFunctionNames (headerContents: string) : string list =
let pattern = @"\b[a-zA-Z_][a-zA-Z0-9_]*\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\([^\)]*\)\s*;"
let regex = System.Text.RegularExpressions.Regex(pattern)
let matches = regex.Matches(headerContents)

[ for matchResult in matches do
let declaration = matchResult.Value
// Split the declaration at whitespace and take the second to last element,
// which should be the function name (assuming no return type modifiers like pointers)
let parts = declaration.Split([|' '; '\t'; '\n'; '\r'|], System.StringSplitOptions.RemoveEmptyEntries)
if parts.Length > 1 then yield parts.[parts.Length - 2] ]


12 changes: 12 additions & 0 deletions FrontEndAst/Language.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ type ILangGeneric () =
abstract member SpecExtention : string
abstract member BodyExtention : string

abstract member RtlFuncNames : string list
abstract member detectFunctionCalls : string -> string -> string list
abstract member removeFunctionFromHeader : string -> string -> string
abstract member removeFunctionFromBody : string -> string -> string


abstract member getRtlFiles : Asn1Encoding list -> string list -> string list

abstract member getAsn1ChildBackendName0 : Asn1AcnAst.Asn1Child -> string
Expand Down Expand Up @@ -147,6 +153,12 @@ type ILangGeneric () =
this.getParamTypeSuffix t "" c
default this.requiresHandlingOfEmptySequences = false
default this.requiresHandlingOfZeroArrays = false
default this.RtlFuncNames = []
default this.detectFunctionCalls (sourceCode: string) (functionName: string) = []
default this.removeFunctionFromHeader (sourceCode: string) (functionName: string) : string =
sourceCode
default this.removeFunctionFromBody (sourceCode: string) (functionName: string) : string =
sourceCode


type LanguageMacros = {
Expand Down
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
[![Build and Test Status of ASN1SCC on Circle CI](https://circleci.com/gh/maxime-esa/asn1scc.svg?&style=shield&circle-token=fcc32f415742887faa6ad69826b1cf25426df086)](https://circleci.com/gh/maxime-esa/asn1scc/tree/master)

*For the impatient: if you already know what ASN.1 and ASN1SCC is, and
just want to run the ASN1SCC compiler:*

docker pull maxime-esa/asn1scc
docker run -it maxime-esa/asn1scc

*...and follow the instructions shown.*
[![CircleCI](https://dl.circleci.com/status-badge/img/circleci/NWDXtobZpVSQ5ErUz9CgXB/3deZmhdEfAoLGYUJtiCX4c/tree/master.svg?style=svg&circle-token=69c83a7973425a3ab92fb7e2d7580bcb292a508f)](https://dl.circleci.com/status-badge/redirect/circleci/NWDXtobZpVSQ5ErUz9CgXB/3deZmhdEfAoLGYUJtiCX4c/tree/master)

Executive summary
=================

This is the source code of the ASN1SCC compiler - an ASN.1 compiler that
targets C and Ada, while placing specific emphasis on embedded systems.
You can read a comprehensive paper about it
targets **C**, **Ada** and **Scala** while placing specific emphasis on embedded systems.

ASN1SCC is the ASN.1 compiler of the **European Space Agency** and is used is space missions to support binary encoding needs in satellite systems flight and ground software.

What makes **ASN1SCC** unique is that in addition to supporting the standard ASN.1 uPER compact binary encoding rules, it offers the possibility to describe **custom binary encoding rules** with a simple textual notation, in order to communicate with equipments that come with legacy data formats. Check out [this page](https://taste.tuxfamily.org/wiki/index.php?title=Technical_topic:_ASN.1_-_An_introduction_to_ACN) to get a comprehensive overview of the feature, and [this page](https://taste.tuxfamily.org/wiki/index.php?title=Technical_topic:_Hints_to_model_complex_packet_encodings_with_ASN.1_and_ACN) for concrete examples as used in space systems.

To know more you can also read this paper about ASN1SCC
[here (PDF)](http://web1.see.asso.fr/erts2012/Site/0P2RUC89/7C-4.pdf),
or a blog post with hands-on examples
[here](https://www.thanassis.space/asn1.html).
Expand Down Expand Up @@ -184,4 +181,19 @@ $ ./sample_test

Credits
=======
George Mamais ([email protected]), Thanassis Tsiodras ([email protected])
Project supervisor at the European Space Agency: Maxime Perrotin ([email protected])

Main project developer: George Mamais ([email protected])

Check https://lamdasoft.eu/asn1scc/ if you need commercial support

Major contributor: Thanassis Tsiodras ([email protected])

The Scala backend was developed by:
* Filip Schramka (Ateleris)
* Ivo Nussbaumer (Ateleris)
* Mario Bucev (EPFL)
* Simon Felix (Ateleris)



Loading

0 comments on commit c7b4fb1

Please sign in to comment.