cmhacks escribió:AFIYEMG escribió:cmhacks escribió:offtopic
Safetycar!!! omg
Ayer comentabas que si salia un .flash, para este dispositivo funcionarian lo .hex, verdad???
Pues creo que ya está?
Donde esta?
Estoy viendo las carreras
#include <stdio.h>
#include <usb.h>
void printhex(char * bytes, unsigned int length);
int open_dev();
usb_dev_handle *devh = NULL;
void printhex(char * bytes, unsigned int length)
{
unsigned int i;
for(i = 0; i < length; i++)
{
printf("%2.2X", bytes[i]);
}
printf("\n");
}
int open_dev()
{
struct usb_bus *bus;
struct usb_device *dev;
usb_init();
usb_find_busses();
usb_find_devices();
for (bus = usb_get_busses(); bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
if (dev->descriptor.idVendor == 0xAAAA && dev->descriptor.idProduct == 0xF1A2)
{
devh = usb_open(dev);
printf("device found and opened\n");
return 1;
}
}
}
return 0;
}
int main(int argc, char* argv[])
{
FILE *fp;
char ret, serial[8], buffer[0x80];
if(open_dev())
{
usb_control_msg(devh, 0xA1, 0, 0, 0, serial, 8, 1000);
printf("serial: ");
printhex(serial, 8);
if(argc > 1)
{
if((fp = fopen(argv[1], "rb")))
{
if(usb_control_msg(devh, 0xA1, 0, 0, 0, &ret, 1, 1000) == 1)
{
if(ret == 1)
{
printf("flashing:");
while(fread(buffer, 1, 0x80, fp) == 0x80 && ret)
{
usb_control_msg(devh, 0x21, 1, 0, 0, buffer, 0x80, 10000);
usb_control_msg(devh, 0xA1, 0, 0, 0, &ret, 1, 1000);
printf(".");
}
printf("\n");
if(ret == 4)
{
printf("flash completed successfully!!!\n");
}
else
{
printf("FLASH FAILED: %d\n", ret);
}
usb_control_msg(devh, 0xA1, 0, 0, 0, serial, 8, 1000);
printf("serial: ");
printhex(serial, 8);
}
else
{
printf("please unplug and replug\n");
}
}
else
{
printf("comm fail\n");
}
fclose(fp);
usb_close(devh);
return 0;
}
else
{
printf("couldn't open fla file\n");
}
}
else
{
printf("usage: flasher <.fla file>\n");
}
}
else
{
printf("no dongle found\n");
}
return -1;
}