mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Got our first track read!
This commit is contained in:
1
build.py
1
build.py
@@ -90,6 +90,7 @@ cxxlibrary(
|
||||
"./lib/proto.cc",
|
||||
"./lib/readerwriter.cc",
|
||||
"./lib/sector.cc",
|
||||
"./lib/usb/applesauce.cc",
|
||||
"./lib/usb/applesauceusb.cc",
|
||||
"./lib/usb/fluxengineusb.cc",
|
||||
"./lib/usb/greaseweazle.cc",
|
||||
|
||||
34
lib/usb/applesauce.cc
Normal file
34
lib/usb/applesauce.cc
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "lib/globals.h"
|
||||
#include "usb.h"
|
||||
#include "protocol.h"
|
||||
#include "lib/bytes.h"
|
||||
#include "greaseweazle.h"
|
||||
#include "lib/fluxmap.h"
|
||||
#include "lib/a2r.h"
|
||||
|
||||
static uint32_t a2r_to_ticks(uint32_t a2rticks)
|
||||
{
|
||||
return a2rticks * A2R_NS_PER_TICK / NS_PER_TICK;
|
||||
}
|
||||
|
||||
Bytes applesauceToFluxEngine(const Bytes& asdata)
|
||||
{
|
||||
ByteReader br(asdata);
|
||||
Fluxmap fluxmap;
|
||||
|
||||
unsigned a2rTicksSinceLastPulse = 0;
|
||||
while (!br.eof())
|
||||
{
|
||||
uint8_t b = br.read_8();
|
||||
a2rTicksSinceLastPulse += b;
|
||||
if (b != 255)
|
||||
{
|
||||
fluxmap.appendInterval(a2r_to_ticks(a2rTicksSinceLastPulse));
|
||||
fluxmap.appendPulse();
|
||||
a2rTicksSinceLastPulse = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return fluxmap.rawBytes();
|
||||
}
|
||||
|
||||
@@ -4,3 +4,5 @@
|
||||
#define APPLESAUCE_PID 0x0483
|
||||
|
||||
#define APPLESAUCE_ID ((APPLESAUCE_VID << 16) | APPLESAUCE_PID)
|
||||
|
||||
extern Bytes applesauceToFluxEngine(const Bytes& asdata);
|
||||
|
||||
@@ -188,8 +188,7 @@ public:
|
||||
doCommand(fmt::format("data:<{}", bufferSize));
|
||||
|
||||
Bytes rawData = _serial->readBytes(bufferSize);
|
||||
|
||||
return Bytes();
|
||||
return applesauceToFluxEngine(rawData);
|
||||
}
|
||||
|
||||
void write(int side,
|
||||
|
||||
Reference in New Issue
Block a user