mirror of https://bitbucket.org/ausocean/av.git
psi/helpers.go: modified UpdateLocation() to make updating of location in pmt cleaner, and also removed redundant conversion of string to byte slice
This commit is contained in:
parent
98d89a4e4e
commit
5c4795786e
|
@ -106,14 +106,11 @@ func UpdateLocation(d []byte, s string) error {
|
|||
if !HasLocation(d) {
|
||||
return errors.New("pmt does not location descriptor, cannot update")
|
||||
}
|
||||
sb := []byte(s)
|
||||
locBytes := d[LocationDataIndx : LocationDataIndx+LocationDataSize]
|
||||
for i, _ := range locBytes {
|
||||
if i < len(sb) {
|
||||
locBytes[i] = sb[i]
|
||||
} else {
|
||||
locBytes[i] = 0x00
|
||||
}
|
||||
loc := d[LocationDataIndx : LocationDataIndx+LocationDataSize]
|
||||
n := copy(loc, s)
|
||||
loc = loc[n:]
|
||||
for i := range loc {
|
||||
loc[i] = 0
|
||||
}
|
||||
updateCrc(d)
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue