-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathno_rescale_x.go
29 lines (26 loc) · 968 Bytes
/
no_rescale_x.go
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
package calibrationReader
import (
"errors"
"github.com/asap2Go/calibrationReader/a2l"
"github.com/rs/zerolog/log"
)
// getNoRescaleX retrieves the number of Rescale X-axis pairs according to its layout specified within the record layout and their values as calibrated in the hex file
func (cd *CalibrationData) getNoRescaleX(rl *a2l.RecordLayout, curPos *uint32) (int64, error) {
if !rl.NoRescaleX.DatatypeSet {
err := errors.New("noRescaleX datatype not set")
log.Err(err).Msg("could not retrieve noRescaleX value")
return 0, err
}
bufBytes, err := cd.getValue(curPos, rl.NoRescaleX.Datatype, rl)
if err != nil {
log.Err(err).Msg("could not retrieve noRescaleX value")
return 0, err
}
val, err := cd.convertByteSliceToDatatype(bufBytes, rl.NoRescaleX.Datatype)
if err != nil {
log.Err(err).Msg("could not retrieve noRescaleX value")
return 0, err
}
*curPos += uint32(rl.NoRescaleX.Datatype.GetDatatypeLength())
return int64(val), err
}