| 128 | } |
| 129 | |
| 130 | int mainInspect(int argc, const char* argv[]) |
| 131 | { |
| 132 | globalConfig().overrides()->mutable_flux_source()->set_type(FLUXTYPE_DRIVE); |
| 133 | flags.parseFlagsWithConfigFiles(argc, argv, {}); |
| 134 | |
| 135 | auto fluxSource = FluxSource::create(globalConfig()); |
| 136 | auto tracks = parseCylinderHeadsString(destTracks); |
| 137 | if (tracks.size() != 1) |
| 138 | error("you must specify exactly one track"); |
| 139 | const auto fluxmap = fluxSource->readFlux(tracks[0])->next(); |
| 140 | |
| 141 | std::cout << fmt::format("0x{:x} bytes of data in {:.3f}ms\n", |
| 142 | fluxmap->bytes(), |
| 143 | fluxmap->duration() / 1e6); |
| 144 | std::cout << fmt::format("Required USB bandwidth: {}kB/s\n", |
| 145 | (int)(fluxmap->bytes() / 1024.0 / (fluxmap->duration() / 1e9))); |
| 146 | |
| 147 | nanoseconds_t clockPeriod = guessClock(*fluxmap); |
| 148 | std::cout << fmt::format( |
| 149 | "{:.2f} us clock detected.", (double)clockPeriod / 1000.0) |
| 150 | << std::flush; |
| 151 | |
| 152 | FluxmapReader fmr(*fluxmap); |
| 153 | fmr.seek(seekFlag * 1000000.0); |
| 154 | |
| 155 | if (dumpFluxFlag) |
| 156 | { |
| 157 | std::cout << "\n\nMagnetic flux follows (times in us):" << std::endl; |
| 158 | |
| 159 | int resolution = fluxmapResolutionFlag; |
| 160 | if (resolution == 0) |
| 161 | resolution = clockPeriod / 4; |
| 162 | |
| 163 | nanoseconds_t nextclock = clockPeriod; |
| 164 | |
| 165 | nanoseconds_t now = fmr.tell().ns(); |
| 166 | int ticks = now / NS_PER_TICK; |
| 167 | |
| 168 | std::cout << fmt::format("{: 10.3f}:-", ticks * US_PER_TICK); |
| 169 | nanoseconds_t lasttransition = 0; |
| 170 | while (!fmr.eof()) |
| 171 | { |
| 172 | unsigned thisTicks; |
| 173 | fmr.findEvent(F_BIT_PULSE, thisTicks); |
| 174 | ticks += thisTicks; |
| 175 | |
| 176 | nanoseconds_t transition = ticks * NS_PER_TICK; |
| 177 | nanoseconds_t next; |
| 178 | |
| 179 | bool clocked = false; |
| 180 | |
| 181 | bool bannered = false; |
| 182 | auto banner = [&]() |
| 183 | { |
| 184 | std::cout << fmt::format("\n{: 10.3f}:{}", |
| 185 | (double)next / 1000.0, |
| 186 | clocked ? '-' : ' '); |
| 187 | bannered = true; |
nothing calls this directly
no test coverage detected