Permalink
Browse files

adding frequency handling to memedit

  • Loading branch information...
rcc committed Mar 12, 2012
1 parent c55cb07 commit da69aef28c7ce917992f74c15cf4b7d91b38c808
Showing with 138 additions and 2 deletions.
  1. +2 −0 pgmscripts/defaults.pgm
  2. +20 −0 pgmscripts/frs_murs.pgm
  3. +41 −0 src/cmds/memory.c
  4. +67 −2 src/vx7if/vx7if.c
  5. +8 −0 src/vx7if/vx7if.h
View
@@ -0,0 +1,2 @@
+# invalidate all memory locations
+meminvalidate
View
@@ -0,0 +1,20 @@
+memedit --tag=FRS_01 --freq=462562000 --txpwr=L1 --skip M401
+memedit --tag=FRS_02 --freq=462587000 --txpwr=L1 --skip M402
+memedit --tag=FRS_03 --freq=462612500 --txpwr=L1 --skip M403
+memedit --tag=FRS_04 --freq=462637000 --txpwr=L1 --skip M404
+memedit --tag=FRS_05 --freq=462662000 --txpwr=L1 --skip M405
+memedit --tag=FRS_06 --freq=462687000 --txpwr=L1 --skip M406
+memedit --tag=FRS_07 --freq=462712500 --txpwr=L1 --skip M407
+memedit --tag=FRS_08 --freq=467562000 --txpwr=L1 --skip M408
+memedit --tag=FRS_09 --freq=467587000 --txpwr=L1 --skip M409
+memedit --tag=FRS_10 --freq=467612500 --txpwr=L1 --skip M410
+memedit --tag=FRS_11 --freq=467637000 --txpwr=L1 --skip M411
+memedit --tag=FRS_12 --freq=467662000 --txpwr=L1 --skip M412
+memedit --tag=FRS_13 --freq=467687000 --txpwr=L1 --skip M413
+memedit --tag=FRS_14 --freq=467712500 --txpwr=L1 --skip M414
+
+memedit --tag=MURS_1 --freq=151820000 --txpwr=L3 --skip M415
+memedit --tag=MURS_2 --freq=151880000 --txpwr=L3 --skip M416
+memedit --tag=MURS_3 --freq=151940000 --txpwr=L3 --skip M417
+memedit --tag=MURS_4 --freq=154570000 --txpwr=L3 --skip M418
+memedit --tag=MURS_5 --freq=154600000 --txpwr=L3 --skip M419
View
@@ -39,16 +39,28 @@
#include <stdlib.h>
#include <string.h>
+static int get_uint_opt(const char *opt, uint32_t *val, struct dictionary *opts)
+{
+ const char *str = dict_str_for_key(opts, opt);
+ if((str == NULL) || (strlen(str) == 0)) {
+ return -1;
+ }
+ *val = (uint32_t)strtol(str, NULL, 0);
+ return 0;
+}
CMDHANDLER(memedit)
{
+ struct vx7_clone_data *clone;
uint32_t memidx;
enum vx7_mem_type memtype;
+ int new = 0;
if(APPDATA->clone == NULL) {
logerror("no loaded clone\n");
return -1;
}
+ clone = APPDATA->clone;
if(argc < 1) {
logerror("invalid usage\n");
@@ -62,10 +74,39 @@ CMDHANDLER(memedit)
logdebug("Memory Type: %d, Memory Index: %u\n", (int)memtype, memidx);
+ /* If it's a new entry, enable it */
+ if(!vx7if_mem_entry_valid(clone, memidx, memtype)) {
+ new = 1;
+ vx7if_mem_entry_set_status(clone, memidx, memtype,
+ VX7_MEMSTATUS_VALID);
+ vx7if_mem_entry_set_flag(clone, memidx, memtype,
+ VX7_MEMFLAG_NORMAL);
+ }
+
+ /* Handle frequency */
+ if(dict_has_key(opts, "freq")) {
+ uint32_t freq;
+ if(get_uint_opt("freq", &freq, opts) != 0) {
+ logerror("must specify frequency value\n");
+ return -1;
+ }
+ if(vx7if_mem_entry_set_freq(clone, memidx, memtype, freq) != 0)
+ return -1;
+ }
+
+ /* If it's a new entry, set the defaults now that the frequency is
+ * set.
+ */
+ if(new) {
+ if(vx7if_mem_entry_set_defaults(clone, memidx, memtype) != 0)
+ return -1;
+ }
+
return 1;
}
START_CMD_OPTS(memedit_opts)
+ CMD_OPT(freq, '\0', "freq", "set station frequency in Hz")
END_CMD_OPTS;
APPCMD_OPT(memedit, &memedit, "edit a memory location",
View
@@ -455,7 +455,7 @@ int vx7if_mem_entry_set_flag(struct vx7_clone_data *clone,
} else if(flag == VX7_MEMFLAG_SKIP) {
INSERTBF(MEMFLAG_SKIP_ODD, 1,
clone->mem_flag_table[i / 2]);
- } else {
+ } else if(flag != VX7_MEMFLAG_NORMAL) {
logerror("invalid flag\n");
return -1;
}
@@ -468,7 +468,7 @@ int vx7if_mem_entry_set_flag(struct vx7_clone_data *clone,
} else if(flag == VX7_MEMFLAG_SKIP) {
INSERTBF(MEMFLAG_SKIP, 1,
clone->mem_flag_table[i / 2]);
- } else {
+ } else if(flag != VX7_MEMFLAG_NORMAL) {
logerror("invalid flag\n");
return -1;
}
@@ -491,6 +491,71 @@ enum vx7_mem_flag vx7if_mem_entry_get_flag(const struct vx7_clone_data *clone,
return VX7_MEMFLAG_NORMAL;
}
+int vx7if_mem_entry_set_freq(struct vx7_clone_data *clone,
+ uint32_t index, enum vx7_mem_type type, uint32_t freq)
+{
+ struct vx7_mem_entry *m = vx7if_mem_entry(clone, index, type);
+
+ if(m == NULL)
+ return -1;
+
+ logdebug("setting freq %u\n", freq);
+
+ m->freq_100M_10M = ((freq / 100000000) & 0xF) << 4;
+ freq %= 100000000;
+ m->freq_100M_10M |= ((freq / 10000000) & 0xF);
+ freq %= 10000000;
+ m->freq_1M_100K = ((freq / 1000000) & 0xF) << 4;
+ freq %= 1000000;
+ m->freq_1M_100K |= ((freq / 100000) & 0xF);
+ freq %= 100000;
+ m->freq_10K_1K = ((freq / 10000) & 0xF) << 4;
+ freq %= 10000;
+ m->freq_10K_1K |= ((freq / 1000) & 0xF);
+ /* freq %= 1000; */
+
+ return 0;
+}
+
+uint32_t vx7if_mem_entry_get_freq(struct vx7_clone_data *clone,
+ uint32_t index, enum vx7_mem_type type)
+{
+ uint32_t freq = 0;
+ struct vx7_mem_entry *m = vx7if_mem_entry(clone, index, type);
+
+ if(m == NULL)
+ return 0;
+
+ freq = 100000000 * ((m->freq_100M_10M >> 4) & 0xF);
+ freq += 10000000 * ((m->freq_100M_10M >> 0) & 0xF);
+ freq += 1000000 * ((m->freq_1M_100K >> 4) & 0xF);
+ freq += 100000 * ((m->freq_1M_100K >> 0) & 0xF);
+ freq += 10000 * ((m->freq_10K_1K >> 4) & 0xF);
+ freq += 1000 * ((m->freq_10K_1K >> 0) & 0xF);
+ if(m->freq_10K_1K == 0x12)
+ freq += 500;
+
+ return freq;
+}
+
+int vx7if_mem_entry_set_defaults(struct vx7_clone_data *clone,
+ uint32_t index, enum vx7_mem_type type)
+{
+ struct vx7_mem_entry *m = vx7if_mem_entry(clone, index, type);
+#if 0
+ uint32_t freq = 0;
+ uint32_t tx_freq = 0;
+ uint32_t freq_step = 0;
+#endif
+
+ if(m == NULL)
+ return -1;
+
+ //freq = vx7if_mem_entry_get_freq(clone, index, type);
+
+ return 0;
+}
+
/******************************* Communication ******************************/
static int vx7if_wait_for_ack(struct serial_device *dev)
{
View
@@ -134,6 +134,14 @@ int vx7if_mem_entry_set_flag(struct vx7_clone_data *clone,
enum vx7_mem_flag vx7if_mem_entry_get_flag(const struct vx7_clone_data *clone,
uint32_t index, enum vx7_mem_type type);
+int vx7if_mem_entry_set_freq(struct vx7_clone_data *clone,
+ uint32_t index, enum vx7_mem_type type, uint32_t freq);
+uint32_t vx7if_mem_entry_get_freq(struct vx7_clone_data *clone,
+ uint32_t index, enum vx7_mem_type type);
+
+int vx7if_mem_entry_set_defaults(struct vx7_clone_data *clone,
+ uint32_t index, enum vx7_mem_type type);
+
/******************************* Communication ******************************/
/* FUNCTION: vx7if_clone_receive
*

0 comments on commit da69aef

Please sign in to comment.