mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Wire up writebrother to the real USB device. Maybe it works now?
This commit is contained in:
18
lib/usb.cc
18
lib/usb.cc
@@ -195,31 +195,29 @@ std::unique_ptr<Fluxmap> usbRead(int side, int revolutions)
|
||||
return fluxmap;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Returns number of bytes actually written */
|
||||
void usb_write(int side, struct fluxmap* fluxmap)
|
||||
void usbWrite(int side, const Fluxmap& fluxmap)
|
||||
{
|
||||
int safelen = fluxmap->bytes & ~(FRAME_SIZE-1);
|
||||
int safelen = fluxmap.bytes() & ~(FRAME_SIZE-1);
|
||||
|
||||
/* Convert from intervals to absolute timestamps. */
|
||||
|
||||
uint8_t buffer[1024*1024];
|
||||
std::vector<uint8_t> buffer(safelen);
|
||||
uint8_t clock = 0;
|
||||
for (int i=0; i<safelen; i++)
|
||||
{
|
||||
clock += fluxmap->intervals[i];
|
||||
clock += fluxmap[i];
|
||||
buffer[i] = clock;
|
||||
}
|
||||
|
||||
struct write_frame f = {
|
||||
.f = { .type = F_FRAME_WRITE_CMD, .size = sizeof(f) },
|
||||
.side = side,
|
||||
.side = (uint8_t) side,
|
||||
.bytes_to_write = htole32(safelen),
|
||||
};
|
||||
usb_cmd_send(&f, f.f.size);
|
||||
|
||||
large_bulk_transfer(FLUXENGINE_DATA_OUT_EP, buffer, safelen);
|
||||
large_bulk_transfer(FLUXENGINE_DATA_OUT_EP, buffer);
|
||||
|
||||
await_reply(F_FRAME_WRITE_REPLY);
|
||||
await_reply<struct any_frame>(F_FRAME_WRITE_REPLY);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,5 +8,6 @@ extern void usbSeek(int track);
|
||||
extern nanoseconds_t usbGetRotationalPeriod();
|
||||
extern void usbTestBulkTransport();
|
||||
extern std::unique_ptr<Fluxmap> usbRead(int side, int revolutions);
|
||||
extern void usbWrite(int side, const Fluxmap& fluxmap);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "writer.h"
|
||||
#include "sql.h"
|
||||
#include "protocol.h"
|
||||
#include "usb.h"
|
||||
#include "fmt/format.h"
|
||||
#include <regex>
|
||||
|
||||
@@ -78,7 +79,10 @@ void writeTracks(const std::function<Fluxmap(int track, int side)> producer)
|
||||
if (outdb)
|
||||
sqlWriteFlux(outdb, track, side, fluxmap);
|
||||
else
|
||||
Error() << "can't write to real hardware yet";
|
||||
{
|
||||
usbSeek(track);
|
||||
usbWrite(side, fluxmap);
|
||||
}
|
||||
std::cout << fmt::format("{0} ms in {1} bytes", int(fluxmap.duration()/1e6), fluxmap.bytes()) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ static DoubleFlag clockRateUs(
|
||||
"Encoded data clock rate (microseconds).",
|
||||
3.850);
|
||||
|
||||
static IntFlag postIndexGapMs(
|
||||
static DoubleFlag postIndexGapMs(
|
||||
{ "--post-index-gap" },
|
||||
"Post-index gap before first sector header (milliseconds).",
|
||||
2.0);
|
||||
@@ -32,6 +32,11 @@ static DoubleFlag sectorSpacingMs(
|
||||
"Time between successive sector headers (milliseconds).",
|
||||
16.684);
|
||||
|
||||
static IntFlag trackOffset(
|
||||
{ "--track-offset" },
|
||||
"Number of tracks to offset when writing the image.",
|
||||
1);
|
||||
|
||||
static DoubleFlag postHeaderSpacingMs(
|
||||
{ "--post-header-spacing" },
|
||||
"Time between a sector's header and data records (milliseconds).",
|
||||
@@ -52,7 +57,7 @@ static int charToInt(char c)
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
setWriterDefaults(0, 77, 0, 0);
|
||||
setWriterDefaults(trackOffset, trackOffset+77, 0, 0);
|
||||
Flag::parseFlags(argc, argv);
|
||||
|
||||
SectorSet allSectors;
|
||||
@@ -68,11 +73,12 @@ int main(int argc, const char* argv[])
|
||||
writeTracks(
|
||||
[&](int physicalTrack, int physicalSide) -> Fluxmap
|
||||
{
|
||||
int logicalTrack = physicalTrack;
|
||||
int logicalTrack = physicalTrack - trackOffset;
|
||||
std::vector<bool> bits(bitsPerRevolution);
|
||||
unsigned cursor = 0;
|
||||
|
||||
std::cerr << "logical track " << logicalTrack << std::endl;
|
||||
std::cerr << "logical track " << logicalTrack << std::endl
|
||||
<< " ";
|
||||
|
||||
for (int sectorCount=0; sectorCount<geometry.sectors; sectorCount++)
|
||||
{
|
||||
@@ -88,11 +94,14 @@ int main(int argc, const char* argv[])
|
||||
writeBrotherSectorHeader(bits, cursor, logicalTrack, sectorId);
|
||||
fillBitmapTo(bits, cursor, dataCursor, { true, false });
|
||||
writeBrotherSectorData(bits, cursor, sectorData->data);
|
||||
|
||||
if (cursor > bits.size())
|
||||
Error() << "track data overrun";
|
||||
}
|
||||
|
||||
if (cursor > bits.size())
|
||||
Error() << "track data overrun";
|
||||
|
||||
// The pre-index gap is not normally reported.
|
||||
// std::cerr << "pre-index gap " << 200.0 - (double)cursor*clockRateUs/1e3 << std::endl;
|
||||
|
||||
Fluxmap fluxmap;
|
||||
fluxmap.appendBits(bits, clockRateUs*1e3);
|
||||
return fluxmap;
|
||||
|
||||
Reference in New Issue
Block a user