Changeset d46151a in thomson


Ignore:
Timestamp:
Jan 15, 2012, 10:44:59 AM (12 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
88642a4
Parents:
0da6f01
Message:

Load data from K7 file.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • elec/CrO2/software/powerSwitch.c

    r0da6f01 rd46151a  
    2020#include <stdlib.h>
    2121#include <string.h>
     22#include <stdint.h>
    2223#include <lusb0_usb.h>    /* this is libusb, see http://libusb.sourceforge.net/ */
    2324
     
    176177                hexdump(buffer, sizeof(buffer));
    177178    }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);
    180200    }else{
    181201                fprintf(stderr,"Unknown command: %s.\n", argv[1]);
Note: See TracChangeset for help on using the changeset viewer.