package commands import ( "fmt" "git.cheetah.cat/cheetah/moto-flash-data/flashpart" "git.cheetah.cat/cheetah/moto-flash-data/s19" "github.com/rs/zerolog/log" ) type S19TreeCommand struct { FileName string `long:"file" short:"f" required:"true" description:"filename"` } func (command *S19TreeCommand) Execute(args []string) error { log.Info().Str("fileName", command.FileName).Msg("S19-Tree") s19File, err := s19.NewS19Reader(command.FileName) if err != nil { return err } defer s19File.Close() log.Info().Int64("fileSize", s19File.OsSize).Msg("Reading file...") // records, err := s19File.ReadAllRecords() if err != nil { return err } records = records[1:] // skip first ?? ranges := s19File.DetectAddressRanges(records) // for index, segment := range ranges { log.Info().Msg( fmt.Sprintf("Index: %d, Start: 0x%08X, End: 0x%08X, Size: %d bytes, Slice: %d-%d", index, segment.StartAddress, segment.EndAddress, segment.Size, segment.SliceStart, segment.SliceEnd, ), ) // fpHeader := flashpart.ParseFlashPartHeader(records[segment.SliceStart].Data) log.Info().Msg( fmt.Sprintf("Index: %d, Media-ID: 0x%02X, Partition Size: 0x%08X / %d bytes, Partition Tag: '%s'", index, fpHeader.MediaID, fpHeader.TotalSize, fpHeader.TotalSize, fpHeader.VersionText, ), ) //log.Debug().Msg(fmt.Sprint(fpHeader)) } return nil }