Skip to content

Commit

Permalink
add AERT controls to LTM output
Browse files Browse the repository at this point in the history
  • Loading branch information
stronnag committed May 17, 2022
1 parent 9e6ddc7 commit cd18d8f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('flightlog2kml', version : '1.0.1-rc3')
project('flightlog2kml', version : '1.0.1-rc4')
meson.add_install_script('meson/post_install.py')
version = get_option('version')
commit = get_option('commit')
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/types/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ type LogItem struct {
Hdop uint16
HWfail bool
NavMode byte
Ail int16
Ele int16
Rud int16
Thr int16
}

type LogRec struct {
Expand Down
17 changes: 17 additions & 0 deletions pkg/bbl/bblreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,23 @@ func get_bbl_line(r []string, have_origin bool) types.LogItem {
}
}

if s, ok = get_rec_value(r, "rcData[0]"); ok {
i64, _ := strconv.Atoi(s)
b.Ail = int16(i64)
if s, ok = get_rec_value(r, "rcData[1]"); ok {
i64, _ := strconv.Atoi(s)
b.Ele = int16(i64)
}
if s, ok = get_rec_value(r, "rcData[2]"); ok {
i64, _ := strconv.Atoi(s)
b.Rud = int16(i64)
}
if s, ok = get_rec_value(r, "rcData[3]"); ok {
i64, _ := strconv.Atoi(s)
b.Thr = int16(i64)
}
}

if s, ok = get_rec_value(r, "attitude[0]"); ok {
i64, _ := strconv.Atoi(s)
b.Roll = int16(i64 / 10)
Expand Down
16 changes: 16 additions & 0 deletions pkg/ltmgen/ltmgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func newLTM(mtype byte) *ltmbuf {
paylen = 2
case 'a':
paylen = 2
case 'r':
paylen = 8
default:
log.Fatalf("LTM: No payload defined for type '%c'\n", mtype)
}
Expand Down Expand Up @@ -67,6 +69,14 @@ func (l *ltmbuf) checksum() {
l.msg[l.len+3] = c
}

func (l *ltmbuf) prframe(b types.LogItem) {
binary.LittleEndian.PutUint16(l.msg[3:5], uint16(b.Ail))
binary.LittleEndian.PutUint16(l.msg[5:7], uint16(b.Ele))
binary.LittleEndian.PutUint16(l.msg[7:9], uint16(b.Rud))
binary.LittleEndian.PutUint16(l.msg[9:11], uint16(b.Thr))
l.checksum()
}

func (l *ltmbuf) aframe(b types.LogItem) {
binary.LittleEndian.PutUint16(l.msg[3:5], uint16(b.Pitch))
binary.LittleEndian.PutUint16(l.msg[5:7], uint16(b.Roll))
Expand Down Expand Up @@ -361,6 +371,12 @@ func LTMGen(ch chan interface{}, meta types.FlightMeta) {
g3t = b.Utc.Add(g3diff)
}

if b.Ail > 0 {
l := newLTM('r')
l.prframe(b)
s.Write(l.msg)
}

if !lt.IsZero() {
if options.Config.Fast {
time.Sleep(10 * time.Millisecond)
Expand Down
18 changes: 18 additions & 0 deletions pkg/otx/otxreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,24 @@ func get_otx_line(r []string) types.LogItem {
}
b.Throttle = 100 * (b.Throttle + 1024) / 2048
b.Status = status

if s, _, ok := get_rec_value(r, "Ail"); ok {
i64, _ := strconv.Atoi(s)
b.Ail = int16(i64)
if s, _, ok = get_rec_value(r, "Ele"); ok {
i64, _ := strconv.Atoi(s)
b.Ele = int16(i64)
}
if s, _, ok = get_rec_value(r, "Rud"); ok {
i64, _ := strconv.Atoi(s)
b.Rud = int16(i64)
}
if s, _, ok = get_rec_value(r, "Thr"); ok {
i64, _ := strconv.Atoi(s)
b.Thr = int16(i64)
}
}

return b
}

Expand Down

0 comments on commit cd18d8f

Please sign in to comment.