Skip to content

Conversation

@michaelbeutler
Copy link
Contributor

Status bytes can now be enabled or disabled for each port separately. Additionally, you can set the position of the status byte, since the tag S / L has the status byte on different indexes.

// example config
decoder.PayloadConfig{
	Fields: []decoder.FieldConfig{
		{Name: "Moving", Start: 0, Length: 1},
		{Name: "Latitude", Start: 1, Length: 4, Transform: func(v interface{}) interface{} {
			return float64(v.(int)) / 1000000
		}},
		{Name: "Longitude", Start: 5, Length: 4, Transform: func(v interface{}) interface{} {
			return float64(v.(int)) / 1000000
		}},
		{Name: "Altitude", Start: 9, Length: 2, Transform: func(v interface{}) interface{} {
			return float64(v.(int)) / 10
		}},
		{Name: "Timestamp", Start: 11, Length: 4},
		{Name: "Battery", Start: 15, Length: 2, Transform: func(v interface{}) interface{} {
			return float64(v.(int)) / 1000
		}},
		{Name: "TTF", Start: 17, Length: 1, Optional: true},
		{Name: "PDOP", Start: 18, Length: 1, Optional: true},
		{Name: "Satellites", Start: 19, Length: 1, Optional: true},
	},
	TargetType:      reflect.TypeOf(Port10Payload{}),
	StatusByteIndex: helpers.ToIntPointer(0),
}, nil

+ added new tests

Co-Authored-By: havar-miromico <105286030+havar-miromico@users.noreply.github.com>
@michaelbeutler michaelbeutler added bug Something isn't working tagsl/v1 Affects decoder for tag S / tag L v1 labels Nov 8, 2024
@michaelbeutler michaelbeutler self-assigned this Nov 8, 2024
@codecov
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
pkg/decoder/helpers/helpers.go 92.30% <100.00%> (+0.15%) ⬆️
pkg/decoder/tagsl/v1/decoder.go 98.90% <100.00%> (-0.02%) ⬇️

@michaelbeutler michaelbeutler merged commit ce1a72f into main Nov 8, 2024
@michaelbeutler michaelbeutler deleted the bugfix/status-byte branch November 8, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working tagsl/v1 Affects decoder for tag S / tag L v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants