source: thomson/elec/CrO2/software/device.cpp@ e017851

main
Last change on this file since e017851 was e017851, checked in by Adrien Destugues <pulkomandy@…>, 11 years ago

Port to Haiku. Untested.

git-svn-id: svn://localhost/thomson@28 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/* CrO2 datassette emulator
2 * Copyright 2013, Adrien Destugues <pulkomandy@pulkomandy.tk>
3 *
4 * Distributed under the terms of the MIT licence.
5 *
6 * High-level device management functions shared by all implementations.
7 */
8
9#include "device.h"
10#include "k5.h"
11#include "Tape.h"
12
13#include <typeinfo>
14#include <unistd.h>
15
16
17bool Device::initOnce = false;
18Device* Device::instance = NULL;
19
20const uint32_t Device::vid = 0x16C0;
21const uint32_t Device::pid = 0x05DC;
22const char* Device::vendor = "pulkomandy.ath.cx"; // FIXME update
23const char* Device::product = "CrO2";
24
25
26void Device::write(const Tape& file) throw (const char*)
27{
28 for (int k = 0; k < file.getBlockCount(); k++)
29 {
30 // wait for motor on
31 while (getStatus() & 8)
32 usleep(1000 * 1000);
33
34 const Tape::Block& block = file.getBlock(k);
35 try {
36 const K5::Block& moblock = dynamic_cast<const K5::Block&>(block);
37 write(moblock.data, moblock.length - 1, moblock.type);
38 // TODO error handling on write
39 } catch (std::bad_cast x) {
40 throw "Only MO5 files supported so far. Sorry!";
41 };
42
43 // TODO wait for correct time (read status from usb OR compute from size+type)
44 usleep(1400 * 1000);
45 }
46}
47
Note: See TracBrowser for help on using the repository browser.