Changeset 5e633b6 in thomson
- Timestamp:
- Jan 24, 2012, 9:01:07 PM (12 years ago)
- Branches:
- main
- Children:
- 96bc8fa
- Parents:
- 197a1cc
- Location:
- elec/CrO2/software
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
elec/CrO2/software/Makefile
r197a1cc r5e633b6 13 13 endif 14 14 15 CC = g cc16 C FLAGS = $(USBFLAGS) -O -Wall -std=c9917 LIBS = $(USBLIBS) 15 CC = g++ 16 CPPFLAGS = $(USBFLAGS) -O -Wall -I/usr/include/IUP/ 17 LIBS = $(USBLIBS) -L/usr/lib/ -mwindows -liup -lcomctl32 -lole32 18 18 19 19 PROJECT = CrO2 … … 22 22 23 23 all: $(PROGRAM) 24 25 .c.o:26 $(CC) $(CFLAGS) -c $<27 24 28 25 $(PROGRAM): $(PROJECT).o -
elec/CrO2/software/cro2.cpp
r197a1cc r5e633b6 23 23 #include <unistd.h> 24 24 25 #include <iup.h> 26 #include <iupcontrols.h> 27 25 28 #include <lusb0_usb.h> /* this is libusb, see http://libusb.sourceforge.net/ */ 26 29 … … 31 34 */ 32 35 33 #define VENDORSTRING "pulkomandy.ath.cx"36 #define VENDORSTRING (char*)"pulkomandy.ath.cx" 34 37 #define PRODUCTSTRING "CrO2" 35 38 … … 39 42 #define PSCMD_PUT 2 40 43 #define PSCMD_STATUS 3 41 42 static void usage(char *name)43 {44 fprintf(stderr, "usage:\n");45 fprintf(stderr, " %s status\n", name);46 fprintf(stderr, " %s on <port> [<duration>]\n", name);47 fprintf(stderr, " %s off <port> [<duration>]\n", name);48 fprintf(stderr, " %s test\n\n", name);49 fprintf(stderr, "Ports are single digits in the range 0...7\n");50 fprintf(stderr, "The pulse duration for switching temporarily is given in seconds.\n");51 }52 53 44 54 45 static int usbGetStringAscii(usb_dev_handle *dev, int index, int langid, char *buf, int buflen) … … 156 147 } 157 148 149 150 int menu_open(Ihandle* that) 151 { 152 IupPopup(IupFileDlg(), IUP_CENTER, IUP_CENTER); 153 return IUP_DEFAULT; 154 } 155 156 157 void GUI_open(int* argc, char*** argv) 158 { 159 IupOpen(argc, argv); 160 // IupControlsOpen(); 161 162 IupSetFunction("OPEN", menu_open); 163 164 Ihandle* menu = IupMenu( 165 IupSubmenu("File", 166 IupMenu( 167 IupItem("Open", "OPEN"), 168 IupItem("Exit", "IUP_CLOSE"), 169 NULL 170 ) 171 ), 172 NULL 173 ); 174 175 Ihandle* platformlist = IupList(NULL); 176 IupSetAttribute(platformlist, "EXPAND", "HORIZONTAL"); 177 IupSetAttribute(platformlist, "DROPDOWN", "YES"); 178 IupSetAttribute(platformlist, "1", "MO5"); 179 IupSetAttribute(platformlist, "VALUE", "1"); 180 181 Ihandle* blocklist = IupTree(); 182 IupSetAttribute(blocklist, "EXPAND", "VERTICAL"); 183 184 Ihandle* tabs = IupTabs( 185 IupVbox( 186 IupLabel("Hello World"), 187 NULL 188 ), 189 IupVbox( 190 IupHbox( 191 IupLabel("Format:"), 192 platformlist, 193 NULL 194 ), 195 IupHbox( 196 blocklist, 197 IupVbox( 198 // IupMatrix(NULL), 199 IupLabel("Checksum:"), 200 NULL 201 ), 202 NULL 203 ) 204 ), 205 NULL 206 ); 207 208 IupSetAttribute(tabs,"TABTITLE0", "Control"); 209 IupSetAttribute(tabs,"TABTITLE1", "Explore"); 210 211 Ihandle* dialog = IupDialog(tabs); 212 IupSetAttribute(dialog, "TITLE", "CrO2 tape emulator"); 213 IupSetAttributeHandle(dialog, "MENU", menu); 214 IupShow(dialog); 215 216 IupMainLoop(); 217 218 IupClose(); 219 } 220 221 158 222 int main(int argc, char **argv) 159 223 { 160 usb_dev_handle *handle = NULL;161 unsigned char buffer[275];162 int nBytes;224 usb_dev_handle *handle = NULL; 225 unsigned char buffer[275]; 226 int nBytes = 0; 163 227 164 228 if(argc < 2){ 165 usage(argv[0]);166 exit(1);229 GUI_open(&argc, &argv); 230 exit(0); 167 231 } 168 232 usb_init(); 169 if(usbOpenDevice(&handle, USBDEV_SHARED_VENDOR, VENDORSTRING, USBDEV_SHARED_PRODUCT, PRODUCTSTRING) != 0){233 if(usbOpenDevice(&handle, USBDEV_SHARED_VENDOR, VENDORSTRING, USBDEV_SHARED_PRODUCT, (char*)PRODUCTSTRING) != 0){ 170 234 fprintf(stderr, "Could not find USB device \""PRODUCTSTRING"\" with vid=0x%x pid=0x%x\n", USBDEV_SHARED_VENDOR, USBDEV_SHARED_PRODUCT); 171 235 exit(1); … … 227 291 nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | rqtype, PSCMD_PUT, blktype,0 /*checksum*/, (char*)buffer, blksize, 5000); 228 292 }else{ 229 fprintf(stderr,"Unknown command: %s.\n", argv[1]); 230 usage(argv[0]); 231 nBytes = 0; 232 // TODO manage return code 293 GUI_open(&argc, &argv); 233 294 } 234 295
Note:
See TracChangeset
for help on using the changeset viewer.