Read RDT files.
This commit is contained in:
parent
16216043d2
commit
5d62415cfb
1
radio.c
1
radio.c
@ -125,6 +125,7 @@ void radio_read_image(char *filename)
|
|||||||
}
|
}
|
||||||
switch (st.st_size) {
|
switch (st.st_size) {
|
||||||
case 851968:
|
case 851968:
|
||||||
|
case 852533:
|
||||||
device = &radio_uv380;
|
device = &radio_uv380;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
34
uv380.c
34
uv380.c
@ -30,6 +30,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@ -1092,8 +1093,37 @@ static void uv380_print_config(FILE *out, int verbose)
|
|||||||
//
|
//
|
||||||
static void uv380_read_image(FILE *img)
|
static void uv380_read_image(FILE *img)
|
||||||
{
|
{
|
||||||
if (fread(&radio_mem[0], 1, MEMSZ, img) != MEMSZ) {
|
struct stat st;
|
||||||
fprintf(stderr, "Error reading image data.\n");
|
|
||||||
|
// Guess device type by file size.
|
||||||
|
if (fstat(fileno(img), &st) < 0) {
|
||||||
|
fprintf(stderr, "Cannot get file size.\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
switch (st.st_size) {
|
||||||
|
case 851968:
|
||||||
|
// IMG file.
|
||||||
|
if (fread(&radio_mem[0], 1, MEMSZ, img) != MEMSZ) {
|
||||||
|
fprintf(stderr, "Error reading image data.\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 852533:
|
||||||
|
// RTD file.
|
||||||
|
// Header 0x225 bytes and footer 0x10 bytes at 0x40225.
|
||||||
|
fseek(img, 0x225, SEEK_SET);
|
||||||
|
if (fread(&radio_mem[0], 1, 0x40000, img) != 0x40000) {
|
||||||
|
fprintf(stderr, "Error reading image data.\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
fseek(img, 0x10, SEEK_CUR);
|
||||||
|
if (fread(&radio_mem[0x40000], 1, MEMSZ - 0x40000, img) != MEMSZ - 0x40000) {
|
||||||
|
fprintf(stderr, "Error reading image data.\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unrecognized file size %u bytes.\n", (int) st.st_size);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user