Esempio n. 1
0
func decodeFreeform(satellite_id string, frame []byte, timestamp int64) (
	[]pb.TelemetryDatum, [][]byte) {

	stripped := util.StripWhitespace((string)(frame))

	data, _ := DecodeMorse(satellite_id, stripped, timestamp)
	if data != nil {
		return data, nil
	}

	ax25_header := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

	// Text frame.
	data, _ = DecodeFrame(satellite_id, frame, timestamp)
	if data != nil {
		return data, [][]byte{frame}
	}
	ax25_frame := append(ax25_header, frame...)
	data, _ = DecodeFrame(
		satellite_id, ax25_frame, timestamp)
	if data != nil {
		return data, [][]byte{ax25_frame}
	}

	// Hex-encoded frame.
	hex_frame, err := hex.DecodeString(stripped)
	if err == nil {
		data, _ = DecodeFrame(satellite_id, hex_frame, timestamp)
		if data != nil {
			return data, [][]byte{hex_frame}
		}

		ax25_hex_frame := append(ax25_header, hex_frame...)
		data, _ = DecodeFrame(satellite_id, ax25_hex_frame, timestamp)
		if data != nil {
			return data, [][]byte{ax25_hex_frame}
		}

		frames := DecodeKISS(hex_frame)
		for _, frame := range frames {
			d, _ := DecodeFrame(satellite_id, frame, timestamp)
			if d != nil {
				data = append(data, d...)
			}
		}
		if data != nil {
			return data, frames
		}
	}

	return nil, nil
}
Esempio n. 2
0
func TestDecodeFrame_strand1_all(t *testing.T) {
	hexpackets := strings.Split(strand1Packets, "\n")
	for _, p := range hexpackets {
		stripped := util.StripWhitespace(p)
		if stripped == "" {
			continue
		}
		frame, _ := hex.DecodeString(stripped)
		data, err := DecodeFrame_strand1(frame, 123)
		if err != nil {
			t.Errorf("Error for %s: %s", stripped, err)
		}
		if len(data) == 0 {
			t.Errorf("No data decoded for %s", stripped)
		}
	}
}
Esempio n. 3
0
func DecodeAausat3Morse(decoded_morse string, timestamp int64) (
	data []pb.TelemetryDatum, err error) {
	decoded_morse = strings.ToUpper(util.StripWhitespace(decoded_morse)) +
		" "

	for i := 0; i <= len(decoded_morse)-kAausat3MaxLength; i++ {
		d, _ := aausat3Decode(decoded_morse[i:], timestamp)
		data = append(data, d...)
		if len(d) > 0 {
			i += kAausat3MinLength
		}
	}

	if len(data) == 0 {
		return nil, errors.New("No valid messages found")
	}

	return data, nil
}
Esempio n. 4
0
func DecodeFitsat1Morse(decoded_morse string, timestamp int64) (
	data []pb.TelemetryDatum, err error) {

	decoded_morse = util.StripWhitespace(decoded_morse)

	decoded_morse = strings.ToUpper(decoded_morse)
	if decoded_morse == kFitsat1Call {
		return nil, nil
	}

	for i := 0; i < len(decoded_morse)-9; i++ {
		d, _ := fitsat1DecodePart(decoded_morse[i:], timestamp)
		data = append(data, d...)
		if len(d) > 0 {
			i += 9
		}
	}

	if len(data) == 0 {
		return nil, errors.New("No valid messages found")
	}

	return data, nil
}