From df2b297d9140d16f65a831c48f93cbe01668b4ad Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Sun, 10 Sep 2017 22:13:07 +0200 Subject: [PATCH] bugix read tx power --- .../osd/arduino-settingsmanager/README.md | 5 +++ .../arduino-settingsmanager/extended-rf-api.c | 14 +++++-- .../arduino-settingsmanager/project-conf.h | 4 +- .../arduino-settingsmanager/shell-merkur.c | 4 +- .../osd/arduino-settingsmanager/sketch.pde | 42 +++++++++++++++++++ 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/examples/osd/arduino-settingsmanager/README.md b/examples/osd/arduino-settingsmanager/README.md index 0f020a4e9..52d697a48 100644 --- a/examples/osd/arduino-settingsmanager/README.md +++ b/examples/osd/arduino-settingsmanager/README.md @@ -45,6 +45,11 @@ txpower : change transmission power 0 (3dbm, default) to 15 (-17.2dbm) ------------------------------------------------------------------------------ quit picocom, you need to press Ctrl-a , then Ctrl-q ------------------------------------------------------------------------------ +Read eeprom to disk: +avrdude -p m256rfr2 -c stk500v2 -P /dev/ttyUSB0 -b 57600 -U eeprom:r:eeprom_img.hex:i +Write eeprom to Merkurboard: +avrdude -p m256rfr2 -c stk500v2 -P /dev/ttyUSB0 -b 57600 -U eeprom:w:eeprom_img.hex:i + todo: bugfix: txpower : change transmission power 0 (3dbm, default) to 15 (-17.2dbm) diff --git a/examples/osd/arduino-settingsmanager/extended-rf-api.c b/examples/osd/arduino-settingsmanager/extended-rf-api.c index 3d716ded3..e0b844727 100644 --- a/examples/osd/arduino-settingsmanager/extended-rf-api.c +++ b/examples/osd/arduino-settingsmanager/extended-rf-api.c @@ -46,6 +46,7 @@ struct rf_consts { }; static struct rf_consts consts; +static radio_value_t tmpv; void print_64bit_addr(const uint8_t *addr) @@ -115,9 +116,12 @@ radio_result_t get_param(radio_param_t param, radio_value_t *value) { radio_result_t rv; - - rv = NETSTACK_RADIO.get_value(param, value); - + if(param == RADIO_PARAM_TXPOWER){ + value = tmpv; + rv = RADIO_RESULT_OK; + } else { + rv = NETSTACK_RADIO.get_value(param, value); + } switch(rv) { case RADIO_RESULT_ERROR: printf("Radio returned an error\n"); @@ -142,7 +146,9 @@ radio_result_t set_param(radio_param_t param, radio_value_t value) { radio_result_t rv; - + if(param == RADIO_PARAM_TXPOWER){ + tmpv = value; + } rv = NETSTACK_RADIO.set_value(param, value); switch(rv) { diff --git a/examples/osd/arduino-settingsmanager/project-conf.h b/examples/osd/arduino-settingsmanager/project-conf.h index acd60b21f..6efd21174 100644 --- a/examples/osd/arduino-settingsmanager/project-conf.h +++ b/examples/osd/arduino-settingsmanager/project-conf.h @@ -37,7 +37,9 @@ #define PLATFORM_HAS_BATTERY 1 -#define LOOP_INTERVAL (30 * CLOCK_SECOND) +#define LOOP_INTERVAL (20 * CLOCK_SECOND) + +//#define SETTINGS_MAX_SIZE 255 /* Save energy */ //#define RDC_CONF_PT_YIELD_OFF diff --git a/examples/osd/arduino-settingsmanager/shell-merkur.c b/examples/osd/arduino-settingsmanager/shell-merkur.c index f231435c0..394c2cdd1 100644 --- a/examples/osd/arduino-settingsmanager/shell-merkur.c +++ b/examples/osd/arduino-settingsmanager/shell-merkur.c @@ -85,10 +85,10 @@ PROCESS_THREAD(shell_txpower_process, ev, data) /* If no transmission power was given on the command line, we print out the current txpower. */ - if(newptr == data) { + if(newptr == data) { if(get_param(RADIO_PARAM_TXPOWER, &value) == RADIO_RESULT_OK) { - } +// value = params_get_txpower(); } else { set_param(RADIO_PARAM_TXPOWER, value); } diff --git a/examples/osd/arduino-settingsmanager/sketch.pde b/examples/osd/arduino-settingsmanager/sketch.pde index 5c2159b8e..eea529328 100644 --- a/examples/osd/arduino-settingsmanager/sketch.pde +++ b/examples/osd/arduino-settingsmanager/sketch.pde @@ -17,6 +17,8 @@ extern "C" { #include "serial-shell.h" #include "shell-merkur.h" +#include "lib/settings.h" + extern resource_t res_led, res_battery, res_cputemp; uint8_t led_pin=4; @@ -25,6 +27,8 @@ uint8_t led_status; void setup (void) { + settings_status_t status; + // switch off the led pinMode(led_pin, OUTPUT); digitalWrite(led_pin, HIGH); @@ -46,6 +50,44 @@ void setup (void) void loop (void) { + int i; + settings_iter_t iter; + char hostname[30]; + uint16_t panid; + uint16_t channel; + /*************************************************************************/ + /* Iterating thru all settings */ + for(iter = settings_iter_begin(); iter; iter = settings_iter_next(iter)) { + settings_length_t len = settings_iter_get_value_length(iter); + eeprom_addr_t addr = settings_iter_get_value_addr(iter); + uint8_t byte; + + union { + settings_key_t key; + char bytes[0]; + } u; + + u.key = settings_iter_get_key(iter); + + if(u.bytes[0] >= 32 && u.bytes[0] < 127 + && u.bytes[1] >= 32 && u.bytes[1] < 127 + ) { + printf("settings-example: [%c%c] = <",u.bytes[0],u.bytes[1]); + } else { + printf("settings-example: <0x%04X> = <",u.key); + } + + for(; len; len--, addr++) { + eeprom_read(addr, &byte, 1); + printf("%02X", byte); + if(len != 1) { + printf(" "); + } + } + + printf(">\n"); + } + printf("settings-example: Done.\n"); }