kopia lustrzana https://github.com/cyoung/stratux
Test program. Parsing some polygons.
rodzic
ecb7648999
commit
0d759e91a0
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./uatparse"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := "+3cc0978aa66ca3a02100002d3f29688210000000ff0dc45e1e00000000efd305071c142d071d0300bef1e3f1900abdf823bc440abe9ee394a80ac088439a980abfefa3e45c0abef1e3f1900a248000353f6a002210000000ff003e51987c4d5060cb9cb1c30833df2c78cf87f2d74c307d77cf7c10893053857f1d70df2e72c70c1fc75c37cb9cb2cf07f3c707f3c707c17d97df7df780260000353f6a002210000000ff004146247c4d5060cb9cb1c30833df2cf3df07f2d35c307d77cf7d7b71e3881420f3417f1d70df2e72c70c1fc75c37cf0c35d797f0c307f2d707c17d97df7df780648000213c66b022102c45170000bec0487c38f50136d1202c4517bb0defcf0da0c77c79cb26a0844517830defcf0da01145e05176605f1b205f3b205f4b205f6b205176605e00943a0497660e52bf2dcc8013848145d9817c6c8145d980a80250e8145d98178013848125d98334afcb132c8145d981680250e8145d981780138480140322014e120497660cb74ac8145d981780250e8145d9810d2004e1205176605f68033131203075048013848020524890c1105120c75c37c77c79cb2b71d71c31df0cf0c054d47800;rs=31;"
|
||||
// s := "+3c2643887cdca4802100002d3f29688210000000ff0dc45e1e00000000efd305071c142d071d0300bef1e3f1900abdf823bc440abe9ee394a80ac088439a980abfefa3e45c0abef1e3f1900a248000353f6a002210000000ff003e51987c4d5060cb9cb1c30833df2c78cf87f2d74c307d77cf7c10893053857f1d70df2e72c70c1fc75c37cb9cb2cf07f3c707f3c707c17d97df7df7806c80002d3f29682210000000ff00ce11787c04948d15480b0c8260cb8cb0d358032094e05c1832e32c34d5e04948d1548132454920605501148348063d280919281604c24481539424c832e70cf0c1e04948d154809192baeb8d3a024180d3e05c980931e1923cd833c138050558143e0cb039780430c8143e0d304d31600841a050f833c0538580948b8143e0d703858044cd7943e0cf04e014155e0c91e008c5e0c31c2f5894e008c5e0cd336040340ebc24ae8033ce11380458c407830c2dc336ae8033ce1138033ce507782644830cda814212560c3969e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;rs=17;"
|
||||
|
||||
// s := "+3bb40f8953d8b1b0360000353f54002210000000ff006185947c4d5060cb9c70c30833df0d78d707f2e72d5f5df49fcf4c3105fc75c37cb9c70c307f1d70df3c30df0c1fc30c1fcb2c1f05f65f7f3d30c417d2cf4c3105f0545054825526604854c549616018f48315381448e1e0052141b2024e78006c80002d3f29682210000000ff00ce11787c04948d15480b0c8260cb8cb0d358032094e05c1832e32c34d5e04948d1548132454920605501148348063d280919281604c24481539424c832e70cf0c1e04948d154809192baeb8d3a024180d3e05c980931e1923cd833c138050558143e0cb039780430c8143e0d304d31600841a050f833c0538580948b8143e0d703858044cd7943e0cf04e014155e0c91e008c5e0c31c2f5894e008c5e0cd336040340ebc24ae8033ce11380458c407830c2dc336ae8033ce1138033ce507782644830cda814212560c3969e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;rs=29;"
|
||||
|
||||
// s := "+3c2643887cdcb780480000213e955822102cc5c1000085bb887c38f50136d1202cc5c1bb0defc30ca0cb6c70d336a084c5c1830defc30ca03170603c24d48143d715280c1d48280534a0c72c34e30ca9834cb2c33c2ec303b0e36c38d38bb1c17828d2ee4e360160317069831c31d6ec46520a33cf1bb01948011cca603d55203c68131525890c5831d70df2db1c34cedc75c38c70c70d3378005700002d3f29688210000000ff28c4631e00000000efd317071c142d071d0300ce1a242695a4ce03a3e63da4cc01039cbda4ca5f633345a4c93ca31db1a4c899034aa1a4c8328379fda4c73fe39e15a4c75fa3d24da4cac703fe89a4ccf3840731a4ce1a242695a4ce1a24269540ce03a3e63d40cc01039cbd40ca5f63334540c93ca31db140c899034aa140c8328379fd40c73fe39e1540c75fa3d24d40cac703fe8940ccf384073140ce1a24269540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;"
|
||||
|
||||
msg, err := uatparse.New(s)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("err: %s\n", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
msg.DecodeUplink()
|
||||
|
||||
|
||||
for _, frame := range msg.Frames {
|
||||
fmt.Printf("Frame_type: %d\n", frame.Frame_type)
|
||||
fmt.Printf("Product_id: %d\n", frame.Product_id)
|
||||
fmt.Printf("FISB_hours: %d\n", frame.FISB_hours)
|
||||
fmt.Printf("FISB_minutes: %d\n", frame.FISB_minutes)
|
||||
}
|
||||
}
|
Plik binarny nie jest wyświetlany.
|
@ -175,9 +175,14 @@ func (f *UATFrame) decodeTextFrame() {
|
|||
func (f *UATFrame) decodeAirmet() {
|
||||
// APDU header: 48 bits (3-3) - assume no segmentation.
|
||||
|
||||
// fmt.Printf("%s\n", hex.Dump(f.FISB_data))
|
||||
|
||||
record_format := (uint8(f.FISB_data[0]) & 0xF0) >> 4
|
||||
//FIXME: temp.
|
||||
if record_format != 8 {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", hex.Dump(f.FISB_data))
|
||||
|
||||
fmt.Printf("record_format=%d\n", record_format)
|
||||
product_version := (uint8(f.FISB_data[0]) & 0x0F)
|
||||
fmt.Printf("product_version=%d\n", product_version)
|
||||
|
@ -215,7 +220,7 @@ func (f *UATFrame) decodeAirmet() {
|
|||
}
|
||||
fmt.Printf("record_length=%d\n", record_length)
|
||||
// Report identifier = report number + report year.
|
||||
report_number := (uint16(f.FISB_data[8]) << 8) | ((uint16(f.FISB_data[9]) & 0xFC) >> 2)
|
||||
report_number := (uint16(f.FISB_data[8]) << 6) | ((uint16(f.FISB_data[9]) & 0xFC) >> 2)
|
||||
fmt.Printf("report_number=%d\n", report_number)
|
||||
report_year := ((uint16(f.FISB_data[9]) & 0x03) << 5) | ((uint16(f.FISB_data[10]) & 0xF8) >> 3)
|
||||
fmt.Printf("report_year=%d\n", report_year)
|
||||
|
@ -226,8 +231,107 @@ func (f *UATFrame) decodeAirmet() {
|
|||
text_data := dlac_decode(f.FISB_data[11:], uint32(text_data_len))
|
||||
fmt.Printf("text_data=%s\n", text_data)
|
||||
case 8:
|
||||
// (6-1).
|
||||
// (6-1). (6.22 - Graphical Overlay Record Format).
|
||||
record_data := f.FISB_data[6:] // Start after the record header.
|
||||
record_length := (uint16(record_data[0]) << 2) | ((uint16(record_data[1]) & 0xC0) >> 6)
|
||||
fmt.Printf("record_length=%d\n", record_length)
|
||||
// Report identifier = report number + report year.
|
||||
report_number := ((uint16(record_data[1]) & 0x3F) << 8) | uint16(record_data[2])
|
||||
fmt.Printf("report_number=%d\n", report_number)
|
||||
report_year := (uint16(record_data[3]) & 0xFE) >> 1
|
||||
fmt.Printf("report_year=%d\n", report_year)
|
||||
overlay_record_identifier := ((uint8(record_data[4]) & 0x1E) >> 1) + 1 // Document instructs to add 1.
|
||||
fmt.Printf("overlay_record_identifier=%d\n", overlay_record_identifier)
|
||||
object_label_flag := uint8(record_data[4] & 0x01)
|
||||
fmt.Printf("object_label_flag=%d\n", object_label_flag)
|
||||
|
||||
if object_label_flag == 0 { // Numeric index.
|
||||
object_label := (uint8(record_data[5]) << 8) | uint8(record_data[6])
|
||||
record_data = record_data[7:]
|
||||
fmt.Printf("object_label=%d\n", object_label)
|
||||
} else {
|
||||
object_label := dlac_decode(record_data[5:], 9)
|
||||
record_data = record_data[14:]
|
||||
fmt.Printf("object_label=%s\n", object_label)
|
||||
}
|
||||
|
||||
element_flag := (uint8(record_data[0]) & 0x80) >> 7
|
||||
fmt.Printf("element_flag=%d\n", element_flag)
|
||||
qualifier_flag := (uint8(record_data[0]) & 0x40) >> 6
|
||||
fmt.Printf("qualifier_flag=%d\n", qualifier_flag)
|
||||
param_flag := (uint8(record_data[0]) & 0x20) >> 5
|
||||
fmt.Printf("param_flag=%d\n", param_flag)
|
||||
object_element := uint8(record_data[0]) & 0x1F
|
||||
fmt.Printf("object_element=%d\n", object_element)
|
||||
|
||||
object_type := (uint8(record_data[1]) & 0xF0) >> 4
|
||||
fmt.Printf("object_type=%d\n", object_type)
|
||||
|
||||
object_status := uint8(record_data[1]) & 0x0F
|
||||
fmt.Printf("object_status=%d\n", object_status)
|
||||
|
||||
//FIXME
|
||||
if qualifier_flag == 0 { //TODO: Check.
|
||||
record_data = record_data[2:]
|
||||
} else {
|
||||
object_qualifier := (uint32(record_data[2]) << 16) | (uint32(record_data[3]) << 8) | uint32(record_data[4])
|
||||
fmt.Printf("object_qualifier=%d\n", object_qualifier)
|
||||
fmt.Printf("%02x%02x%02x\n", record_data[2], record_data[3], record_data[4])
|
||||
record_data = record_data[5:]
|
||||
}
|
||||
//FIXME
|
||||
//if param_flag == 0 { //TODO: Check.
|
||||
// record_data = record_data[2:]
|
||||
//} else {
|
||||
// //TODO.
|
||||
// // record_data = record_data[4:]
|
||||
//}
|
||||
|
||||
record_applicability_options := (uint8(record_data[0]) & 0xC0) >> 6
|
||||
fmt.Printf("record_applicability_options=%d\n", record_applicability_options)
|
||||
date_time_format := (uint8(record_data[0]) & 0x30) >> 4
|
||||
fmt.Printf("date_time_format=%d\n", date_time_format)
|
||||
geometry_overlay_options := uint8(record_data[0]) & 0x0F
|
||||
fmt.Printf("geometry_overlay_options=%d\n", geometry_overlay_options)
|
||||
|
||||
overlay_operator := (uint8(record_data[1]) & 0xC0) >> 6
|
||||
fmt.Printf("overlay_operator=%d\n", overlay_operator)
|
||||
|
||||
overlay_vertices_count := (uint8(record_data[1]) & 0x3F) + 1 // Document instructs to add 1. (6.20).
|
||||
fmt.Printf("overlay_vertices_count=%d\n", overlay_vertices_count)
|
||||
|
||||
//TODO: Parse all applicability options.
|
||||
if record_applicability_options == 3 && date_time_format == 1 {
|
||||
//TODO:. Date formats.
|
||||
// record_data = record_data[???:]
|
||||
record_data = record_data[10:]
|
||||
}
|
||||
|
||||
// Now we have the vertices.
|
||||
if geometry_overlay_options == 3 { // Extended Range 3D Polygon (MSL).
|
||||
//FIXME: Off by one vertex.
|
||||
fmt.Printf("%d\n", len(record_data))
|
||||
for i := 0; i < int(overlay_vertices_count); i++ {
|
||||
lng_raw := (int32(record_data[6*i]) << 11) | (int32(record_data[6*i+1]) << 3) | (int32(record_data[6*i+2]) & 0xE0 << 5)
|
||||
lat_raw := ((int32(record_data[6*i+2]) & 0x1F) << 14) | (int32(record_data[6*i+3]) << 6) | ((int32(record_data[6*i+4]) & 0xFC) >> 2)
|
||||
alt_raw := ((int32(record_data[6*i+4]) & 0x03) << 8) | int32(record_data[6*i+5])
|
||||
|
||||
fmt.Printf("lat_raw=%d, lng_raw=%d, alt_raw=%d\n", lat_raw, lng_raw, alt_raw)
|
||||
lat := float64(0.000687) * float64(lat_raw)
|
||||
lng := float64(0.000687) * float64(lng_raw)
|
||||
if lat > 90.0 {
|
||||
lat = lat - 180.0
|
||||
}
|
||||
if lng > 180.0 {
|
||||
lng = lng - 360.0
|
||||
}
|
||||
alt := alt_raw * 100
|
||||
fmt.Printf("lat=%f,lng=%f,alt=%d\n", lat, lng, alt)
|
||||
fmt.Printf("coord:%f,%f\n", lat, lng)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue