Commit 58474ad8 authored by Valentin Dudouyt's avatar Valentin Dudouyt

Added minipro-query-db

parent 4341a91b
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
PROGNAME=minipro
COMMON_OBJECTS=byte_utils.o database.o minipro.o
OBJECTS=$(COMMON_OBJECTS) main.o minipro-query-db.o
PROGS=minipro minipro-query-db
MINIPRO=minipro
MINIPRO_QUERY_DB=minipro-query-db
TESTS=$(wildcard tests/test_*.c);
OBJCOPY=objcopy
CFLAGS = `pkg-config --cflags libusb-1.0` -g -O0
LIBS = `pkg-config --libs libusb-1.0`
all: $(OBJECTS)
$(CC) $(LIBS) $(OBJECTS) -o $(PROGNAME)
all: $(OBJECTS) $(PROGS)
minipro: $(COMMON_OBJECTS) main.o
$(CC) $(LIBS) $(COMMON_OBJECTS) main.o -o $(MINIPRO)
minipro-query-db: $(COMMON_OBJECTS) minipro-query-db.o
$(CC) $(LIBS) $(COMMON_OBJECTS) minipro-query-db.o -o $(MINIPRO_QUERY_DB)
clean:
rm -f $(OBJECTS) $(PROGNAME)
rm -f $(OBJECTS) $(PROGS)
test: $(TESTS:.c=.stamp)
$(CC) -c -I. $< $(CFLAGS) -DTEST -o $(<:.c=.o)
$(OBJCOPY) --weaken $(<:.c=.o)
$(CC) $(LIBS) $(OBJECTS) $(<:.c=.o) -o $(<:.c=)
$(CC) $(LIBS) $(COMMON_OBJECTS) $(<:.c=.o) -o $(<:.c=)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "minipro.h"
#include "database.h"
#include "error.h"
void print_help_and_exit(const char *progname) {
fprintf(stderr, "Usage: %s <device>\n", progname);
exit(-1);
}
void print_device_info(device_t *device) {
printf("Name: %s\n", device->name);
/* Memory shape */
printf("Memory: %d", device->code_memory_size);
switch(device->opts4 & 0xFF000000) {
case 0x00000000:
printf(" Bytes");
break;
case 0x01000000:
printf(" Words");
break;
case 0x02000000:
printf(" Bits");
break;
default:
ERROR2("Unknown memory shape: 0x%x\n", device->opts4 & 0xFF000000);
}
if(device->data_memory_size) {
printf(" + %d Bytes", device->data_memory_size);
}
if(device->data_memory2_size) {
printf(" + %d Bytes", device->data_memory2_size);
}
printf("\n");
/* Package info */
printf("Package: ");
if(device->package_details & 0xFF) {
printf("Adapter%d.JPG\n", device->package_details & 0xFF);
} else {
printf("DIP%d\n", (device->package_details & 0xFF000000) >> 8*3);
}
printf("Protocol: 0x%02x\n", device->protocol_id);
printf("Read buffer size: %d Bytes\n", device->read_buffer_size);
printf("Write buffer size: %d Bytes\n", device->write_buffer_size);
}
int main(int argc, char **argv) {
if(argc != 2) {
print_help_and_exit(argv[0]);
}
device_t *device = get_device_by_name(argv[1]);
if(!device) {
ERROR("Unknown device");
}
print_device_info(device);
return(0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment