fidl和arxml互转教程

fracon 命令行工具可以使用 maven 从源代码构建。本页介绍如何运行本地构建。 请注意,你的公司需要成为 AUTOSAR 组织的成员。如果不是会员,你将无法访问 artop.org,因此无法使用 FARACON 工具。

环境要求:java8 / mvn3.x

注意:以下所有操作均在ubuntu20.04上进行。

如何从源码构建命令行工具

源码下载

源码地址:https://github.com/COVESA/franca_ara_tools

1
$ git clone https://github.com/GENIVI/franca_ara_tools.git

artop文件下载

为了构建franca_ara_tools项目,需要下载artop提供的artop-Update-4.12.1文件。只有加入autosar会员的公司才能注册和登录artop站点:https://www.artop.org

  1. 登录artop站点后,选择Downloads,然后选择All Downloads

  1. 选择SDK

  1. 下拉找到artop-Update-4.12.1.zip

注意:目前只能使用4.12.1版本,其他版本无效。

  1. artop-Update-4.12.1.zip解压到制定目录:
1
$ unzip -d /home/test/franca/artop-Update-4.12.1 artop-Update-4.12.1.zip

franca_ara_tools源码修改

进入下载的franca_ara_tools项目目录,然后执行以下操作:

  1. 修改releng/org.genivi.faracon.parent/pom.xml文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
+++ b/releng/org.genivi.faracon.parent/pom.xml
@@ -401,6 +401,16 @@
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>${jdt-core-version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.platform</groupId>
+ <artifactId>org.eclipse.core.runtime</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.platform</groupId>
+ <artifactId>org.eclipse.equinox.common</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
@@ -412,10 +422,36 @@
<artifactId>org.eclipse.jdt.compiler.tool</artifactId>
<version>${jdt-compiler-tool-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.platform</groupId>
+ <artifactId>org.eclipse.core.runtime</artifactId>
+ <version>3.12.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.platform</groupId>
+ <artifactId>org.eclipse.equinox.common</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.codegen</artifactId>
<version>${emf-codegen-version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.platform</groupId>
+ <artifactId>org.eclipse.core.runtime</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.platform</groupId>
+ <artifactId>org.eclipse.equinox.common</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.platform</groupId>
+ <artifactId>org.eclipse.equinox.common</artifactId>
+ <version>3.8.0</version>
</dependency>

  1. 修改releng/org.genivi.faracon.target/fara-oxygen-artop.target文件,将location修改为本地artop文件目录:<repository location="file:/home/test/franca/artop-Update-4.12.1"/>

franca_ara_tools源码构建

进入franca_ara_tools项目的releng/org.genivi.faracon.parent目录,执行以下命令:

1
$ mvn clean install -Pwith-artop -Dtycho.disableP2Mirrors=true

等待构建完成,时间较长:

构建成功之后在franca_ara_tools项目下生成products目录,构建成果物在该目录下。

文件转换

构建完成后在products/org.genivi.faracon.cli.product/target/products/org.genivi.faracon.cli.product目录下会生成各个平台的可执行文件,进入目录:

1
$ cd products/org.genivi.faracon.cli.product/target/products/org.genivi.faracon.cli.product

由于我在ubuntu20.04下操作,将对应系统文件copy到指定目录:

1
$ cp -a franca_ara_tools/products/org.genivi.faracon.cli.product/target/products/org.genivi.faracon.cli.product/linux/gtk/x86_64 $HOME/faracon

为了在任意地方使用faranca命令,设置环境变量:vim ~/.zshrc,添加以下内容:

1
export PATH=$PATH:$HOME/faracon

命令行选项

faracon-linux-x86_64 --help 将输出以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Command: Console Help
Command: Franca ARA Converter
usage: faracon [-a <arg>] [-c] [-ca] [-d <arg>] [-e] [-f <arg>] [-i <arg>] [-L
<arg>] [-l <arg>]
-a,--ara-to-franca <arg> Arxml file that will be converted to .fidl or
directory what will be recursively scanned for
.arxml files and each one of them will be
converted to corresponding fidl ones.
-c,--continue-on-errors Do not stop the tool execution when an error
occurs.
-ca,--check-arxml-files-only Checks the provided ARXML files.
-conf,--f2aconfig <arg> Supply configuration file for command line
related to Franca-to-arxml generation.
-d,--dest <arg> Output directory for the generated files.
-e,--warnings-as-errors Treat warnings as errors.
-f,--franca-to-ara <arg> Franca file that will be converted to arxml or
directory what will be recursively scanned for
fidl files and each one of them will be
converted to corresponding arxml ones.
-i,--include <arg> Additions to classpath.
-L,--license <arg> The file path to the license text that will be
added to each generated file.
-l,--log-level <arg> The log level (quiet or verbose).

Command: Console Help
usage: faracon -h
-h,--help Print out options of the tool.

Command: Version Information
usage: faracon -v
-v,--version Show version number of the tool.

转换前注意事项

终于可以使用命令行工具了,激动的去试一试,但是发现在执行转换命令操作的时候遇到以下报错:

经过一番排查之后,找到了问题原因,修改$HOME/faracon/faracon-linux-x86_64.ini文件内容,删除--illegal-access=deny参数。

删除前:

删除后:

之后就可以按照以下步骤进行转换了。👦

fidl转arxml

转换 /path/to/fidls 中的所有 fidl 文件,将输出存储在/path/to/output中,使用详细的日志记录级别,并在发生错误时继续翻译下一个 fidl

转换fidl使用参数-f

1
$ faracon-linux-x86_64 -f /path/to/fidls/ -d /path/to/output/ -l verbose -c

也可指定文件:

1
$ faracon-linux-x86_64 -f /path/to/fidls/helloworld.fidl -d /path/to/output/ -l verbose -c

arxml转fidl

转换/path/to/arxmls 中的所有 arxml 文件,将输出存储在/path/to/output 中,使用详细的日志记录级别,并在发生错误时继续翻译下一个 arxml

转换arxml使用参数-a

1
$ faracon-linux-x86_64 -a /path/to/arxmls/ -d /path/to/output/ -l verbose -c

也可指定文件:

1
$ faracon-linux-x86_64 -a /path/to/arxmls/helloworld.arxml -d /path/to/output/ -l verbose -c