Changeset c7b4218 in thomson
- Timestamp:
- Jan 29, 2012, 6:20:30 PM (12 years ago)
- Branches:
- main
- Children:
- f9263dd
- Parents:
- 32c7682
- Location:
- elec/CrO2/software
- Files:
-
- 4 added
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
elec/CrO2/software/Makefile
r32c7682 rc7b4218 14 14 15 15 CC = g++ 16 CPPFLAGS = $(USBFLAGS) -O -Wall -I/usr/include/IUP/ 16 CPPFLAGS = $(USBFLAGS) -O -Wall -I/usr/include/IUP/ -g 17 17 LIBS = $(USBLIBS) -L/usr/lib/ -mwindows -liup -lcomctl32 -lole32 18 18 … … 23 23 all: $(PROGRAM) 24 24 25 $(PROGRAM): $(PROJECT).o device.o poller.o25 $(PROGRAM): $(PROJECT).o device.o gui.o k5.o 26 26 $(CC) -o $(PROGRAM) $^ $(LIBS) 27 27 -
elec/CrO2/software/cro2.cpp
r32c7682 rc7b4218 12 12 #include <unistd.h> 13 13 14 #include <iup.h>15 #include <iupcontrols.h>16 14 17 15 #include "device.h" 18 #include "poller.h" 19 20 /* UI */ 21 int menu_open(Ihandle* that) 22 { 23 IupPopup(IupFileDlg(), IUP_CENTER, IUP_CENTER); 24 return IUP_DEFAULT; 25 } 26 27 int menu_exit(Ihandle* that) 28 { 29 return IUP_CLOSE; 30 } 31 32 33 Ihandle* motoron; 34 void GUI_open(int* argc, char*** argv) 35 { 36 IupOpen(argc, argv); 37 // IupControlsOpen(); 38 39 IupSetFunction("OPEN", menu_open); 40 IupSetFunction("EXIT", menu_exit); 41 42 Ihandle* menu = IupMenu( 43 IupSubmenu("File", 44 IupMenu( 45 IupItem("Open", "OPEN"), 46 IupItem("Exit", "EXIT"), 47 NULL 48 ) 49 ), 50 NULL 51 ); 52 53 // CONTROL 54 motoron = IupProgressBar(); 55 IupSetAttribute(motoron, "RASTERSIZE", "16x16"); 56 57 // EXPLORE 58 Ihandle* platformlist = IupList(NULL); 59 IupSetAttribute(platformlist, "EXPAND", "HORIZONTAL"); 60 IupSetAttribute(platformlist, "DROPDOWN", "YES"); 61 IupSetAttribute(platformlist, "1", "MO5"); 62 IupSetAttribute(platformlist, "VALUE", "1"); 63 64 Ihandle* blocklist = IupTree(); 65 IupSetAttribute(blocklist, "EXPAND", "VERTICAL"); 66 67 Ihandle* tabs = IupTabs( 68 IupVbox( 69 IupHbox( 70 IupLabel("Motor"), 71 motoron, 72 NULL 73 ), 74 IupHbox( 75 IupToggle("play",NULL), 76 IupToggle("REC",NULL), 77 NULL 78 ), 79 NULL 80 ), 81 IupVbox( 82 IupHbox( 83 IupLabel("Format:"), 84 platformlist, 85 NULL 86 ), 87 IupHbox( 88 blocklist, 89 IupVbox( 90 // IupMatrix(NULL), 91 IupLabel("Checksum:"), 92 NULL 93 ), 94 NULL 95 ) 96 ), 97 NULL 98 ); 99 100 IupSetAttribute(tabs,"TABTITLE0", "Control"); 101 IupSetAttribute(tabs,"TABTITLE1", "Explore"); 102 103 Ihandle* dialog = IupDialog(tabs); 104 IupSetAttribute(dialog, "TITLE", "CrO2 tape emulator"); 105 IupSetAttributeHandle(dialog, "MENU", menu); 106 IupShow(dialog); 107 108 // Run the timer 109 startPolling(); 110 111 IupMainLoop(); 112 113 IupClose(); 114 } 115 16 #include "k5.h" 17 #include "gui.h" 116 18 117 19 int main(int argc, char **argv) 118 20 { 119 //usb_dev_handle *handle = NULL;120 unsigned char buffer[275];121 21 int nBytes = 0; 122 22 123 23 if(argc < 2){ 124 G UI_open(&argc, &argv);24 Gui gui(&argc, &argv); 125 25 exit(0); 126 26 } … … 130 30 131 31 if(strcmp(argv[1], "get") == 0){ 32 unsigned char buffer[275]; 132 33 memset(buffer, 0, 275); 133 34 nBytes = dev.read(buffer, sizeof(buffer)); 134 35 }else if(strcmp(argv[1], "put") == 0){ 135 36 136 // wait for motor on 137 while (dev.getStatus() & 8) 138 usleep(1000000); 37 // load file 38 K5 file(argv[2]); 139 39 140 // load file141 FILE* fptr = fopen(argv[2], "rb");142 int blockid;143 uint8_t blktype, blksize;144 sscanf(argv[3], "%d", &blockid);40 for (int k = 0; k < file.getBlockCount(); k++) 41 { 42 // wait for motor on 43 while (dev.getStatus() & 8) 44 Sleep(1000); 145 45 146 // fast-forward to requested block 147 do 148 { 149 do 150 { 151 fread(&blktype, 1, 1, fptr); 152 if (feof(fptr)) 153 { 154 fprintf(stderr, "end of file.\n"); 155 fclose(fptr); 156 exit(0); 157 } 158 } 159 while(blktype != 0x5A); // skip sync header 46 K5::Block block = file.getBlock(k); 160 47 161 fread(&blktype, 1, 1, fptr); 162 fread(&blksize, 1, 1, fptr); 163 blksize -= 2; 164 fread(buffer, 1, blksize + 1, fptr); 165 if (blktype == 0) 166 { 167 // new file 168 printf("%.11s\n",buffer); 169 } 48 nBytes = dev.write(block.data, block.length - 1, block.type); 49 50 // TODO wait for correct time (read status from usb OR compute from size+type) 51 Sleep(1400); 170 52 } 171 while (blockid --);172 173 fclose(fptr);174 175 nBytes = dev.write(buffer, blksize, blktype);176 53 }else{ 177 54 // TODO print usage … … 186 63 std::cerr << error << std::endl; 187 64 } 65 66 exit(0); 188 67 } 189 68
Note:
See TracChangeset
for help on using the changeset viewer.