source: thomson/elec/CrO2/software/cro2.cpp@ 192e299

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

Cleanup.

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

  • Property mode set to 100644
File size: 999 bytes
Line 
1/* CrO2 datassette emulator
2 * Copyright 2012, Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
3 *
4 * Distributed under the terms of the MIT licence.
5 */
6
7#include <iostream>
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <stdint.h>
12#include <unistd.h>
13
14
15#include "device.h"
16#include "k5.h"
17#include "gui.h"
18
19int main(int argc, char **argv)
20{
21 if(argc < 2){
22 Gui gui(&argc, &argv);
23 exit(0);
24 }
25
26 try {
27 Device& dev = Device::getDevice(); // Constructor inits communication.
28
29 if(strcmp(argv[1], "get") == 0){
30 int nBytes = 0;
31 unsigned char buffer[275];
32 memset(buffer, 0, 275);
33 nBytes = dev.read(buffer, sizeof(buffer));
34 if (nBytes < 0) fprintf(stderr, "USB error %s\n", usb_strerror());
35 }else if(strcmp(argv[1], "put") == 0){
36
37 // load file
38 K5 file(argv[2]);
39
40 dev.write(file);
41 }else{
42 // TODO print usage
43 exit(2);
44 }
45
46 return 0;
47 }
48 catch(const char* error)
49 {
50 std::cerr << error << std::endl;
51 }
52
53 exit(0);
54}
55
Note: See TracBrowser for help on using the repository browser.