Skip to content

Commit f91a9b3

Browse files
committed
Added annotations
These annotations are needed for understanding on how to extract the correct values for a characteristic from the hex file. More annotations will follow.
1 parent e6c645e commit f91a9b3

File tree

4 files changed

+137
-74
lines changed

4 files changed

+137
-74
lines changed

a2l/characteristic.go

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,29 @@ import (
88
)
99

1010
type Characteristic struct {
11-
Name string
12-
nameSet bool
13-
LongIdentifier string
14-
longIdentifierSet bool
15-
Type typeEnum
16-
TypeSet bool
17-
Address string
18-
addressSet bool
19-
deposit string
20-
depositSet bool
21-
maxDiff float64
22-
maxDiffSet bool
23-
conversion string
24-
conversionSet bool
25-
lowerLimit float64
26-
lowerLimitSet bool
27-
upperLimit float64
28-
upperLimitSet bool
29-
annotation []annotation
30-
axisDescr []axisDescr
31-
bitMask bitMask
11+
Name string
12+
nameSet bool
13+
LongIdentifier string
14+
longIdentifierSet bool
15+
Type typeEnum
16+
TypeSet bool
17+
Address string
18+
addressSet bool
19+
//Deposit is the identifier of the corresponding record layout
20+
Deposit string
21+
DepositSet bool
22+
maxDiff float64
23+
maxDiffSet bool
24+
conversion string
25+
conversionSet bool
26+
lowerLimit float64
27+
lowerLimitSet bool
28+
upperLimit float64
29+
upperLimitSet bool
30+
annotation []annotation
31+
axisDescr []axisDescr
32+
bitMask bitMask
33+
//byteOrder can be used to overwrite the standard byte order defined in mod par
3234
byteOrder byteOrder
3335
calibrationAccess calibrationAccessEnum
3436
comparisonQuantity comparisonQuantity
@@ -287,9 +289,9 @@ forLoop:
287289
c.Address = tok.current()
288290
c.addressSet = true
289291
log.Info().Msg("characteristic Address successfully parsed")
290-
} else if !c.depositSet {
291-
c.deposit = tok.current()
292-
c.depositSet = true
292+
} else if !c.DepositSet {
293+
c.Deposit = tok.current()
294+
c.DepositSet = true
293295
log.Info().Msg("characteristic deposit successfully parsed")
294296
} else if !c.maxDiffSet {
295297
var buf float64

a2l/enums.go

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -275,24 +275,32 @@ type typeEnum string
275275

276276
const (
277277
undefinedType typeEnum = emptyToken
278-
Ascii typeEnum = asciiToken
279-
Curve typeEnum = curveToken
280-
Map typeEnum = mapToken
281-
Cuboid typeEnum = cuboidToken
282-
cube4 typeEnum = cube4Token
283-
cube5 typeEnum = cube5Token
284-
ValBlk typeEnum = valBlkToken
285-
Value typeEnum = valueToken
286-
derived typeEnum = derivedToken
287-
extendedSi typeEnum = extendedSiToken
278+
//String value in ASCII format.
279+
ASCII typeEnum = asciiToken
280+
//Curve Datatype of a characteristic is like an array for the y axis plus an axis description on the x axis
281+
Curve typeEnum = curveToken
282+
//Map defines a two dimensional array
283+
Map typeEnum = mapToken
284+
//Cuboid defines a three dimensional array mostly represented as an array of Maps
285+
Cuboid typeEnum = cuboidToken
286+
//The cuboid is stored as an array of maps with incremented or decremented Z coordinates. Rarely used
287+
cube4 typeEnum = cube4Token
288+
//The CUBE_5 is stored as an array of CUBE_4 with incremented or decremented Z5 coordinates. Rarely used
289+
cube5 typeEnum = cube5Token
290+
//Value Block is a a array with one, two or up to three dimensions.
291+
ValBlk typeEnum = valBlkToken
292+
//Value is used in characteristics that only have one value like e.g. "1.0"
293+
Value typeEnum = valueToken
294+
derived typeEnum = derivedToken
295+
extendedSi typeEnum = extendedSiToken
288296
)
289297

290298
func parseTypeEnum(tok *tokenGenerator) (typeEnum, error) {
291299
t := undefinedType
292300
var err error
293301
switch tok.current() {
294302
case asciiToken:
295-
t = Ascii
303+
t = ASCII
296304
case curveToken:
297305
t = Curve
298306
case mapToken:
@@ -321,13 +329,15 @@ type conversionTypeEnum string
321329

322330
const (
323331
undefinedConversionType conversionTypeEnum = emptyToken
324-
Identical conversionTypeEnum = identicalToken
325-
Form conversionTypeEnum = formToken
326-
Linear conversionTypeEnum = linearToken
327-
RatFunc conversionTypeEnum = ratFuncToken
328-
TabIntp conversionTypeEnum = tabIntpToken
329-
TabNointp conversionTypeEnum = tabNointpToken
330-
TabVerb conversionTypeEnum = tabVerbToken
332+
//Identical defines a OneToOne conversion from hex to decimal
333+
Identical conversionTypeEnum = identicalToken
334+
Form conversionTypeEnum = formToken
335+
Linear conversionTypeEnum = linearToken
336+
RatFunc conversionTypeEnum = ratFuncToken
337+
TabIntp conversionTypeEnum = tabIntpToken
338+
TabNointp conversionTypeEnum = tabNointpToken
339+
//Tab Verb is a table to convert numeric values into strings. e.g.: 1 -> "True"
340+
TabVerb conversionTypeEnum = tabVerbToken
331341
)
332342

333343
func parseConversionTypeEnum(tok *tokenGenerator) (conversionTypeEnum, error) {
@@ -358,23 +368,63 @@ type indexModeEnum string
358368

359369
const (
360370
undefinedIndexMode indexModeEnum = emptyToken
361-
alternateCurves indexModeEnum = alternateCurvesToken
362-
alternateWithX indexModeEnum = alternateWithXToken
363-
alternateWithY indexModeEnum = alternateWithYToken
364-
ColumnDir indexModeEnum = columnDirToken
365-
RowDir indexModeEnum = rowDirToken
371+
/* curves which share a common axis are deposited in columns;
372+
each row of memory contains values for all the shared axis curves
373+
at a given axis breakpoint.
374+
Required in order to represent characteristics which correspond to
375+
arrays of structures in ECU program code.*/
376+
AlternateCurves indexModeEnum = alternateCurvesToken
377+
/*AlternateWithX defines that values of a map are
378+
stored in columns and the columns of table values alternate with the
379+
respective X-coordinates. A map of format
380+
9 8 7
381+
[0 1 2
382+
3 4 5
383+
6 7 8]
384+
could be stored within the hex file as an array of format
385+
[9,0,3,6,8,1,4,7,7,2,5,8]
386+
The order of axis points and table values can be defined differently
387+
by the position statement in the FNC_VALUE
388+
In case of a curve the values of x-Axis and values alternate.*/
389+
AlternateWithX indexModeEnum = alternateWithXToken
390+
/*AlternateWithY defines that values of a map are
391+
deposited in rows, the rows of table values alternate with the
392+
respective Y-coordinates. A map of format
393+
9 [0 1 2
394+
8 3 4 5
395+
7 6 7 8]
396+
could be within the hex file as an array of format
397+
[9,0,1,2,8,3,4,5,7,6,7,8]
398+
The order of axis points and table values can be defined differently
399+
by the position statement in the FNC_VALUE
400+
Only applicable to maps*/
401+
AlternateWithY indexModeEnum = alternateWithYToken
402+
/*Column Direction defines that values of a map
403+
[0 1 2
404+
3 4 5
405+
6 7 8]
406+
are stored within the hex file as an array of format
407+
[0,3,6,1,4,7,2,5,8] */
408+
ColumnDir indexModeEnum = columnDirToken
409+
/*Row Direction defines that values of a map
410+
[0 1 2
411+
3 4 5
412+
6 7 8]
413+
are stored within the hex file as an array of format
414+
[0,1,2,3,4,5,6,7,8] */
415+
RowDir indexModeEnum = rowDirToken
366416
)
367417

368418
func parseIndexModeEnum(tok *tokenGenerator) (indexModeEnum, error) {
369419
im := undefinedIndexMode
370420
var err error
371421
switch tok.current() {
372422
case alternateCurvesToken:
373-
im = alternateCurves
423+
im = AlternateCurves
374424
case alternateWithXToken:
375-
im = alternateWithX
425+
im = AlternateWithX
376426
case alternateWithYToken:
377-
im = alternateWithY
427+
im = AlternateWithY
378428
case columnDirToken:
379429
im = ColumnDir
380430
case rowDirToken:

a2l/fnc_values.go

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,28 @@ import (
88
)
99

1010
type fncValues struct {
11-
//position of table values (function values) in the deposit structure (description of sequence of elements in the data record).
12-
position uint16
13-
positionSet bool
11+
//Position of table values (function values) in the deposit structure (description of sequence of elements in the data record).
12+
Position uint16
13+
PositionSet bool
1414
//data type of the table values
15-
datatype dataTypeEnum
16-
datatypeSet bool
17-
//for characteristic maps, this attribute is used to describe how the 2-dimensional table values are mapped onto the 1-dimensional address space
18-
indexMode indexModeEnum
19-
indexModeSet bool
20-
addresstype addrTypeEnum
21-
addresstypeSet bool
15+
Datatype dataTypeEnum
16+
DatatypeSet bool
17+
//for characteristic maps, curves and value blocks, this field is used to describe how the 2-dimensional table values are mapped onto the 1-dimensional address space
18+
IndexMode indexModeEnum
19+
IndexModeSet bool
20+
/*addressing of the table values:
21+
Enumeration for description of the addressing of table
22+
values or axis point values:
23+
PBYTE: The relevant memory location has a 1 byte pointer
24+
to this table value or axis point value.
25+
PWORD: The relevant memory location has a 2 byte pointer
26+
to this table value or axis point value.
27+
PLONG: The relevant memory location has a 4 byte pointer
28+
to this table value or axis point value.
29+
DIRECT: The relevant memory location has the first table value
30+
or axis point value, all others follow with incrementing address. */
31+
Addresstype addrTypeEnum
32+
AddresstypeSet bool
2233
}
2334

2435
func parseFncValues(tok *tokenGenerator) (fncValues, error) {
@@ -35,39 +46,39 @@ forLoop:
3546
err = errors.New("unexpected token " + tok.current())
3647
log.Err(err).Msg("fncValues could not be parsed")
3748
break forLoop
38-
} else if !fv.positionSet {
49+
} else if !fv.PositionSet {
3950
var buf uint64
4051
buf, err = strconv.ParseUint(tok.current(), 10, 16)
4152
if err != nil {
4253
log.Err(err).Msg("fncValues position could not be parsed")
4354
break forLoop
4455
}
45-
fv.position = uint16(buf)
46-
fv.positionSet = true
56+
fv.Position = uint16(buf)
57+
fv.PositionSet = true
4758
log.Info().Msg("fncValues position successfully parsed")
48-
} else if !fv.datatypeSet {
49-
fv.datatype, err = parseDataTypeEnum(tok)
59+
} else if !fv.DatatypeSet {
60+
fv.Datatype, err = parseDataTypeEnum(tok)
5061
if err != nil {
5162
log.Err(err).Msg("fncValues datatype could not be parsed")
5263
break forLoop
5364
}
54-
fv.datatypeSet = true
65+
fv.DatatypeSet = true
5566
log.Info().Msg("fncValues datatype successfully parsed")
56-
} else if !fv.indexModeSet {
57-
fv.indexMode, err = parseIndexModeEnum(tok)
67+
} else if !fv.IndexModeSet {
68+
fv.IndexMode, err = parseIndexModeEnum(tok)
5869
if err != nil {
5970
log.Err(err).Msg("fncValues indexMode could not be parsed")
6071
break forLoop
6172
}
62-
fv.indexModeSet = true
73+
fv.IndexModeSet = true
6374
log.Info().Msg("fncValues indexMode successfully parsed")
64-
} else if !fv.addresstypeSet {
65-
fv.addresstype, err = parseAddrTypeEnum(tok)
75+
} else if !fv.AddresstypeSet {
76+
fv.Addresstype, err = parseAddrTypeEnum(tok)
6677
if err != nil {
6778
log.Err(err).Msg("fncValues addresstype could not be parsed")
6879
break forLoop
6980
}
70-
fv.addresstypeSet = true
81+
fv.AddresstypeSet = true
7182
log.Info().Msg("fncValues addresstype successfully parsed")
7283
break forLoop
7384
}

a2l/record_layout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type recordLayout struct {
3232
fixNoAxisPtsZ fixNoAxisPtsZ
3333
fixNoAxisPts4 fixNoAxisPts4
3434
fixNoAxisPts5 fixNoAxisPts5
35-
fncValues fncValues
35+
FncValues fncValues
3636
identification identification
3737
noAxisPtsX noAxisPtsX
3838
noAxisPtsY noAxisPtsY
@@ -234,7 +234,7 @@ forLoop:
234234
}
235235
log.Info().Msg("recordLayout fixNoAxisPts5 successfully parsed")
236236
case fncValuesToken:
237-
rl.fncValues, err = parseFncValues(tok)
237+
rl.FncValues, err = parseFncValues(tok)
238238
if err != nil {
239239
log.Err(err).Msg("recordLayout fncValues could not be parsed")
240240
break forLoop

0 commit comments

Comments
 (0)