summaryrefslogtreecommitdiffstats
path: root/cli.c
diff options
context:
space:
mode:
authorroot <root@iss-tomyspiel-l>2011-06-16 01:26:14 +0200
committerroot <root@iss-tomyspiel-l>2011-06-16 01:26:14 +0200
commitc95df4d43738e1597c348bc7f98ff2902574d720 (patch)
tree1ecf978533c5cf81cc2052db696d2a2422de323e /cli.c
parenta6965d707c82317f31bb7ed8eabea05b7adb6775 (diff)
downloadipecamera-c95df4d43738e1597c348bc7f98ff2902574d720.tar.gz
ipecamera-c95df4d43738e1597c348bc7f98ff2902574d720.tar.bz2
ipecamera-c95df4d43738e1597c348bc7f98ff2902574d720.tar.xz
ipecamera-c95df4d43738e1597c348bc7f98ff2902574d720.zip
Move to new FPGA design
Diffstat (limited to 'cli.c')
-rw-r--r--cli.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/cli.c b/cli.c
index 860fd9e..73449ee 100644
--- a/cli.c
+++ b/cli.c
@@ -397,20 +397,31 @@ int ReadData(pcilib_t *handle, pcilib_bar_t bar, uintptr_t addr, size_t n, acces
}
int ReadRegister(pcilib_t *handle, pcilib_model_t model, const char *bank, const char *reg) {
- int err;
int i;
+ int err;
+ const char *format;
+
+ pcilib_register_bank_t bank_id;
+ pcilib_register_bank_addr_t bank_addr;
+ pcilib_register_description_t *registers = pcilib_model[model].registers;
pcilib_register_value_t value;
if (reg) {
- err = pcilib_read_register(handle, bank, reg, &value);
+ pcilib_register_t regid = pcilib_find_register(handle, bank, reg);
+ bank_id = pcilib_find_bank_by_addr(handle, registers[regid].bank);
+ format = pcilib_model[model].banks[bank_id].format;
+ if (!format) format = "%lu";
+
+ err = pcilib_read_register_by_id(handle, regid, &value);
+ // err = pcilib_read_register(handle, bank, reg, &value);
if (err) printf("Error reading register %s\n", reg);
- else printf("%s = %i\n", reg, value);
+ else {
+ printf("%s = ", reg);
+ printf(format, value);
+ printf("\n");
+ }
} else {
- pcilib_register_bank_t bank_id;
- pcilib_register_bank_addr_t bank_addr;
-
- pcilib_register_description_t *registers = pcilib_model[model].registers;
if (registers) {
if (bank) {
@@ -421,9 +432,20 @@ int ReadRegister(pcilib_t *handle, pcilib_model_t model, const char *bank, const
printf("Registers:\n");
for (i = 0; registers[i].bits; i++) {
if ((registers[i].mode & PCILIB_REGISTER_R)&&((!bank)||(registers[i].bank == bank_addr))) {
+ bank_id = pcilib_find_bank_by_addr(handle, registers[i].bank);
+ format = pcilib_model[model].banks[bank_id].format;
+ if (!format) format = "%lu";
+
err = pcilib_read_register_by_id(handle, i, &value);
- if (err) printf(" %s = error reading value [%i]", registers[i].name, registers[i].defvalue);
- else printf(" %s = %i [%i]", registers[i].name, value, registers[i].defvalue);
+ if (err) printf(" %s = error reading value", registers[i].name);
+ else {
+ printf(" %s = ", registers[i].name);
+ printf(format, value);
+ }
+
+ printf(" [");
+ printf(format, registers[i].defvalue);
+ printf("]");
}
printf("\n");
}