func ParseSiemensHeader(v interface{}) (SiemensHeader, error) {
	sData := SiemensHeader{
		Elements: make(map[string]SiemensChunk),
	}

	// The data is a byte stream that is encoded into 4-byte words.
	// Specifically, they are encoded as little-endian 32-bit words.
	bs := v.([]uint8)
	bread := bytes.NewReader(bs)

	word := make([]byte, 4)
	var offset int64

	// Confirmed the SV10 header
	if _, err := bread.ReadAt(word, offset); err != nil {
		return sData, err
	}
	offset += int64(len(word))

	if string(word) != "SV10" {
		return sData, fmt.Errorf("Siemens data didn't start with SV10")
	}

	// Check for the 04030201 constant
	bread.ReadAt(word, offset)
	offset += int64(len(word))
	if cslc := []byte{04, 03, 02, 01}; !bytes.Equal(cslc, word) {
		return sData, fmt.Errorf("Didn't find constant %v", cslc)
	}

	bread.ReadAt(word, offset)
	offset += int64(len(word))
	nElements := binary.LittleEndian.Uint32(word)
	sData.NElements = int(nElements)

	// Read the delimiter
	bread.ReadAt(word, offset)
	offset += int64(len(word))

	// Read the first named chunk
	var sc SiemensChunk

	i := 0

	// Since each Name field is 64 bytes, if the remaining data wouldn't be
	// enough for a Name field, we know we are done.
	for offset < (int64(len(bs)) - 64) {
		sc, offset = ReadChunk(bread, offset)
		sc.Order = i
		sData.Elements[sc.Name] = sc

		i++
	}

	return sData, nil
}
// ParseSiemensHeader consumes the element corresponding to the Siemens header
// and parses it fully.
ParseSiemensHeader consumes the element corresponding to the Siemens header
and parses it fully.
// ParseSiemensHeader consumes the element corresponding to the Siemens header // and parses it fully .
func ParseSiemensHeader(v interface{}) (SiemensHeader, error) {
	sData := SiemensHeader{
		Elements: make(map[string]SiemensChunk),
	}
	bs := v.([]uint8)
	bread := bytes.NewReader(bs)
	word := make([]byte, 4)
	var offset int64
	if _, err := bread.ReadAt(word, offset); err != nil {
		return sData, err
	}
	offset += int64(len(word))
	if string(word) != "SV10" {
		return sData, fmt.Errorf("Siemens data didn't start with SV10")
	}
	bread.ReadAt(word, offset)
	offset += int64(len(word))
	if cslc := []byte{04, 03, 02, 01}; !bytes.Equal(cslc, word) {
		return sData, fmt.Errorf("Didn't find constant %v", cslc)
	}
	bread.ReadAt(word, offset)
	offset += int64(len(word))
	nElements := binary.LittleEndian.Uint32(word)
	sData.NElements = int(nElements)
	bread.ReadAt(word, offset)
	offset += int64(len(word))
	var sc SiemensChunk
	i := 0
	for offset < (int64(len(bs)) - 64) {
		sc, offset = ReadChunk(bread, offset)
		sc.Order = i
		sData.Elements[sc.Name] = sc
		i++
	}
	return sData, nil
}
func ParseSiemensHeader ( v interface { } ) ( SiemensHeader , error ) { sData := SiemensHeader { Elements : make ( map [ string ] SiemensChunk ) , } bs := v . ( [ ] uint8 ) bread := bytes . NewReader ( bs ) word := make ( [ ] byte , 4 ) var offset int64 if _ , err := bread . ReadAt ( word , offset ) ; err != nil { return sData , err } offset += int64 ( len ( word ) ) if string ( word ) != " " { return sData , fmt . Errorf ( " " ) } bread . ReadAt ( word , offset ) offset += int64 ( len ( word ) ) if cslc := [ ] byte { 04 , 03 , 02 , 01 } ; ! bytes . Equal ( cslc , word ) { return sData , fmt . Errorf ( " " , cslc ) } bread . ReadAt ( word , offset ) offset += int64 ( len ( word ) ) nElements := binary . LittleEndian . Uint32 ( word ) sData . NElements = int ( nElements ) bread . ReadAt ( word , offset ) offset += int64 ( len ( word ) ) var sc SiemensChunk i := 0 for offset < ( int64 ( len ( bs ) ) - 64 ) { sc , offset = ReadChunk ( bread , offset ) sc . Order = i sData . Elements [ sc . Name ] = sc i ++ } return sData , nil }
ParseSiemensHeader consumes the element corresponding to the Siemens header
and parses it fully.
ParseSiemensHeader consumes the element corresponding to the Siemens header and parses it fully .
// The data is a byte stream that is encoded into 4-byte words. // Specifically, they are encoded as little-endian 32-bit words. // Confirmed the SV10 header // Check for the 04030201 constant // Read the delimiter // Read the first named chunk // Since each Name field is 64 bytes, if the remaining data wouldn't be // enough for a Name field, we know we are done.