1 #Copyright (C) 2014 Intel Corporation
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License as published by the Free Software Foundation; either
6 #version 2.1 of the License, or (at your option) any later version.
8 #This library is distributed in the hope that it will be useful,
9 #but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 #Lesser General Public License for more details.
13 #You should have received a copy of the GNU Lesser General Public
14 #License along with this library; if not, write to the Free Software
15 #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 DbcOutput: Line(s?) eofile
26 my @electronicControlUnits = ();
27 for my $ecui (0..scalar(@ecuList)-1) {
29 $ecuField{'canId'} = $ecuList[$ecui];
31 if ( exists( $ecuMessages{$ecuList[$ecui]} ) ) {
32 my $messagesRef = $ecuMessages{$ecuList[$ecui]};
33 my @messages = @{$messagesRef};
35 $ecuField{'messages'} = \@messages;
36 for my $msgi (0..scalar(@messages)-1) {
37 my @signals = @{$messages[$msgi]{'signals'}};
39 for my $si (0..scalar(@signals)-1) {
40 my $signal = \%{$signals[$si]};
41 my $msgid = $messages[$msgi]{'canId'};
43 if ( exists( ${ecuValues{$msgid}} ) && defined ${$ecuValues{$msgid}{$signal->{'canId'}}} ) {
44 my $valueListRef=${$ecuValues{$msgid}->{$signal->{'canId'}}};
45 my @valueList = @$valueListRef;
46 $signal->{'values'} = \@valueList;
48 # Add AMBPropertyName prefix if valueName starts with number
49 foreach my $vali (@{$signal->{'values'}}) {
50 if ( $vali->{'name'} =~ m/^[0-9]/ ) {
51 $vali->{'name'} = $signal->{'AMBPropertyName'} . '_' . $vali->{'name'};
55 use Intel::IviPoc::AmbCommon;
56 $signal->{'AMBPropertyType'} = &evaluateType($signal);
60 push (@electronicControlUnits, \%ecuField);
64 $jsonroot{'pluginName'} = "pluginName";
65 $jsonroot{'electronicControlUnits'} = \@electronicControlUnits;
67 # Now return the whole internal json structure
74 Line: CommentPrefix /.*\n/
75 # Not needed to output anything yet
76 | 'VERSION' DoubleQuotedId
77 # Not needed to output anything yet
78 | 'NS_' ':' NSList(s?) ...'BS_'
80 # We just read the list of NSs
81 @networks = @{$item[3]};
84 # Not needed to output anything yet
85 | 'BU_' ':' EcuList(s?) ...'BO_'
87 @ecuList = @{$item[3]};
89 | 'BO_' Number Identifier ':' Identifier Identifier Signal(s?)
92 $msg{'canId'} = $item[2];
93 $msg{'canName'} = $item[3];
94 $msg{'canDlc'} = $item[5];
95 $msg{'canMessageId'} = $item[6];
96 $msg{'signals'} = $item[7];
98 push ( @{$ecuMessages{$item[6]}}, \%msg );
100 | 'VAL_' Number Identifier ValuePair(s?) ';'
102 ${$ecuValues{$item[2]}->{$item[3]}} = $item[4];
104 | <error: Invalid dbc format at $thisline!>
106 Signal: 'SG_' Identifier ':' DataPlacement FactorOffset Range DoubleQuotedId Receiver(s /,/)
109 $signal{'canId'} = $item[2];
111 my %placement = %{$item[4]};
112 $signal{'startbit'} = $placement{'startbit'};
113 $signal{'length'} = $placement{'length'};
114 $signal{'byteOrdering'} = $placement{'byteOrdering'};
115 $signal{'signedness'} = $placement{'signedness'};
118 $signal{'factor'} = $fo{'factor'};
119 $signal{'offset'} = $fo{'offset'};
121 my %range=%{$item[6]};
122 $signal{'minValue'} = $range{'minValue'};
123 $signal{'maxValue'} = $range{'maxValue'};
125 $signal{'unit'} = $item[7];
127 $signal{'receivers'} = $item[8];
129 my $ambPropertyName = $item[2];
130 $ambPropertyName =~ s/\_[HM]S$//;
131 $signal{'AMBPropertyName'} = $ambPropertyName;
136 EcuList: ...!'BO_' Identifier
141 NSList: ...!'BS_' Identifier
149 $rx{'name'} = $item[1];
153 ValuePair: Number DoubleQuotedId
156 $valuepair{'value'} = $item[1];
157 $valuepair{'description'} = $item[2];
160 $s =~ s!(^|\s)(\w)!$1\U$2!g;
162 $s =~ s/[^_a-zA-Z0-9]//g;
163 $s =~ s/_(?=[_]*$)//;
167 $valuepair{'name'} = $s;
172 DataPlacement: Number '|' Number '@' Number Sign
175 $placement{'startbit'} = $item[1];
176 $placement{'length'} = $item[3];
177 $placement{'byteOrdering'} = $item[5];
178 $placement{'signedness'} = $item[6];
182 FactorOffset: '(' RealNumber ',' RealNumber ')'
185 $fo{'factor'} = $item[2];
186 $fo{'offset'} = $item[4];
190 Range: '[' RealNumber '|' RealNumber ']'
193 $range{'minValue'} = $item[2];
194 $range{'maxValue'} = $item[4];
198 DoubleQuotedId: DoubleQuotation /[A-Za-z0-9°\!@#\$%\^&\*()\-_=\+\[\]\{\};:\'|,\.\/<>\?`~\ ]+/ DoubleQuotation
202 | DoubleQuotation DoubleQuotation
207 Identifier: /[A-Za-z0-9_\-]+/
212 Number: /[-+]?[0-9]*/
213 RealNumber: /[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/
216 CommentPrefix: /^\/\//
218 DoubleQuotation: "\""