Changeset d46151a in thomson
- Timestamp:
- Jan 15, 2012, 10:44:59 AM (12 years ago)
- Branches:
- main
- Children:
- 88642a4
- Parents:
- 0da6f01
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
elec/CrO2/software/powerSwitch.c
r0da6f01 rd46151a 20 20 #include <stdlib.h> 21 21 #include <string.h> 22 #include <stdint.h> 22 23 #include <lusb0_usb.h> /* this is libusb, see http://libusb.sourceforge.net/ */ 23 24 … … 176 177 hexdump(buffer, sizeof(buffer)); 177 178 }else if(strcmp(argv[1], "put") == 0){ 178 hexdump(buffer, sizeof(buffer)); 179 nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, PSCMD_PUT, 0,0, (char*)buffer, 200, 5000); 179 180 FILE* fptr = fopen(argv[2], "rb"); 181 int blockid; 182 uint8_t blktype, blksize; 183 sscanf(argv[3], "%d", &blockid); 184 185 do 186 { 187 fread(buffer, 1, 18, fptr); // skip sync header 188 fread(&blktype, 1, 1, fptr); 189 fread(&blksize, 1, 1, fptr); 190 blksize -= 2; 191 fread(buffer, 1, blksize + 1, fptr); 192 } 193 while (blockid --); 194 195 fclose(fptr); 196 197 hexdump(buffer, blksize); 198 int rqtype = (blksize == 0) ? USB_ENDPOINT_IN:USB_ENDPOINT_OUT; 199 nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | rqtype, PSCMD_PUT, blktype,0 /*checksum*/, (char*)buffer, blksize, 5000); 180 200 }else{ 181 201 fprintf(stderr,"Unknown command: %s.\n", argv[1]);
Note:
See TracChangeset
for help on using the changeset viewer.