Don't directly read static device
This commit is contained in:
parent
8f544cfa95
commit
7fbcba54fd
17
radio.c
17
radio.c
@ -61,7 +61,15 @@ radio_tab_t* get_radio_tab() {
|
|||||||
return radio_tab;
|
return radio_tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
static radio_device_t *device; // Device-dependent interface
|
static radio_device_t *active_device; // Device-dependent interface
|
||||||
|
|
||||||
|
radio_device_t* get_active_device() {
|
||||||
|
return active_device;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_active_device(radio_device_t* d) {
|
||||||
|
active_device = d;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char radio_mem [1024*1024*2]; // Radio memory contents, up to 2 Mbytes
|
unsigned char radio_mem [1024*1024*2]; // Radio memory contents, up to 2 Mbytes
|
||||||
int radio_progress; // Read/write progress counter
|
int radio_progress; // Read/write progress counter
|
||||||
@ -113,7 +121,7 @@ radio_device_t* radio_connect()
|
|||||||
}
|
}
|
||||||
fprintf(stderr, "Connect to %s.\n", dev->name);
|
fprintf(stderr, "Connect to %s.\n", dev->name);
|
||||||
|
|
||||||
device = dev;
|
set_active_device(dev);
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +243,7 @@ radio_device_t* radio_read_image(const char *filename)
|
|||||||
dev->read_image(dev, img);
|
dev->read_image(dev, img);
|
||||||
fclose(img);
|
fclose(img);
|
||||||
|
|
||||||
device = dev;
|
set_active_device(dev);
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,11 +408,12 @@ void radio_write_csv(radio_device_t* device, const char *filename)
|
|||||||
//
|
//
|
||||||
int radio_is_compatible(const char *name)
|
int radio_is_compatible(const char *name)
|
||||||
{
|
{
|
||||||
|
radio_device_t* dev = get_active_device();
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0; radio_tab[i].ident; i++) {
|
for (i=0; radio_tab[i].ident; i++) {
|
||||||
// Radio is compatible when it has the same parse routine.
|
// Radio is compatible when it has the same parse routine.
|
||||||
if (device->parse_parameter == radio_tab[i].device->parse_parameter &&
|
if (dev->parse_parameter == radio_tab[i].device->parse_parameter &&
|
||||||
strcasecmp(name, radio_tab[i].device->name) == 0) {
|
strcasecmp(name, radio_tab[i].device->name) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user