MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / mainAnalyseDriveResponse

Function mainAnalyseDriveResponse

src/fe-analysedriveresponse.cc:245–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245int mainAnalyseDriveResponse(int argc, const char* argv[])
246{
247 globalConfig().overrides()->mutable_flux_source()->set_type(FLUXTYPE_DRIVE);
248 flags.parseFlagsWithConfigFiles(argc, argv, {});
249
250 if (globalConfig()->flux_sink().type() != FLUXTYPE_DRIVE)
251 error("this only makes sense with a real disk drive");
252 auto tracks = parseCylinderHeadsString(destTracks);
253 if (tracks.size() != 1)
254 error("you must specify exactly one track");
255
256 usbSetDrive(globalConfig()->drive().drive(),
257 globalConfig()->drive().high_density(),
258 globalConfig()->drive().index_mode());
259 usbSeek(tracks[0].cylinder);
260
261 std::cout << "Measuring rotational speed...\n";
262 nanoseconds_t period = usbGetRotationalPeriod(0);
263 if (period == 0)
264 error("Unable to measure rotational speed (try fluxengine rpm).");
265
266 std::ofstream csv;
267 if (writeCsv.get() != "")
268 csv.open(writeCsv);
269
270 int numRows = (maxInterval - minInterval) / intervalStep;
271 const int numColumns = buckets;
272 std::vector<std::vector<double>> frequencies(
273 numRows, std::vector<double>(numColumns, 0.0));
274
275 double interval;
276 for (int row = 0; row < numRows; row++)
277 {
278 interval = minInterval + (double)row * intervalStep;
279
280 unsigned ticks = (unsigned)(interval * TICKS_PER_US);
281 std::cout << fmt::format("Interval {:.2f}: ", ticks * US_PER_TICK);
282 std::cout << std::flush;
283
284 /* Write the test pattern. */
285
286 if (interval >= 2.0)
287 {
288 Fluxmap outFluxmap;
289 while (outFluxmap.duration() < period)
290 {
291 outFluxmap.appendInterval(ticks);
292 outFluxmap.appendPulse();
293 }
294
295 usbWrite(tracks[0].head, outFluxmap.rawBytes(), 0);
296
297 /* Read the test pattern in again. */
298
299 Fluxmap inFluxmap;
300 inFluxmap.appendBytes(usbRead(tracks[0].head, true, period, 0));
301
302 /* Compute histogram. */

Callers

nothing calls this directly

Calls 15

errorFunction · 0.85
parseCylinderHeadsStringFunction · 0.85
usbSetDriveFunction · 0.85
usbSeekFunction · 0.85
usbGetRotationalPeriodFunction · 0.85
usbWriteFunction · 0.85
usbReadFunction · 0.85
paletteFunction · 0.85
draw_y_axisFunction · 0.85
draw_y_graticulesFunction · 0.85
draw_x_axisFunction · 0.85
draw_x_graticulesFunction · 0.85

Tested by

no test coverage detected