Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r4920 - developers/werner/wlan/tomato (wer...@docs.openmoko.org)
   2. r4921 - in developers/werner: . bqmeter bqmeter/patches
      (wer...@docs.openmoko.org)
   3. r4922 - developers/werner/ahrt/host/tmc/lib
      (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2009-02-13 03:06:50 +0100 (Fri, 13 Feb 2009)
New Revision: 4920

Modified:
   developers/werner/wlan/tomato/README
Log:
README: explain why there are multiple files.



Modified: developers/werner/wlan/tomato/README
===================================================================
--- developers/werner/wlan/tomato/README        2009-02-13 01:48:32 UTC (rev 
4919)
+++ developers/werner/wlan/tomato/README        2009-02-13 02:06:50 UTC (rev 
4920)
@@ -5,3 +5,7 @@
 
 vanille-short-default is like short-defaultb but with the ESSID set to
   "vanille" instead of "wg".
+
+For each session, four different WLAN cards have sniffed the air.
+wlan0 is a RTL-8185L, wlan4 and wlan5 are RT2561, and wlan6 is an
+AR2413. The last usually caught the largest number of packets.




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-02-13 03:36:49 +0100 (Fri, 13 Feb 2009)
New Revision: 4921

Added:
   developers/werner/bqmeter/
   developers/werner/bqmeter/Makefile
   developers/werner/bqmeter/bqmeter.c
   developers/werner/bqmeter/patches/
   developers/werner/bqmeter/patches/hdq-read-nosleep.patch
   developers/werner/bqmeter/patches/hdq-sysfs-read.patch
   developers/werner/bqmeter/patches/s3c-resume-early-action.patch
   developers/werner/bqmeter/patches/series
Log:
Coulomb-counter based power meter. Work in progress.



Added: developers/werner/bqmeter/Makefile
===================================================================
--- developers/werner/bqmeter/Makefile                          (rev 0)
+++ developers/werner/bqmeter/Makefile  2009-02-13 02:36:49 UTC (rev 4921)
@@ -0,0 +1,35 @@
+CC=arm-angstrom-linux-gnueabi-gcc
+
+CFLAGS=-Wall -Wshadow -g -O -I../pmu
+LDFLAGS=
+
+PREFIX=/usr
+
+NAME=bqmeter
+OBJS=bqmeter.o ../pmu/pmu.o
+
+.PHONY:                all install uninstall clean depend spotless
+
+all:           $(NAME)
+
+$(NAME):       $(OBJS)
+
+install:       $(NAME)
+               install -D $(NAME) $(PREFIX)/bin/$(NAME)
+
+uninstall:
+               rm -f $(PREFIX)/bin/$(NAME)
+
+depend:
+               $(CPP) $(CFLAGS) -MM -MG *.c >.depend || \
+                 { rm -f .depend; exit 1; }
+
+ifeq (.depend,$(wildcard .depend))
+include .depend
+endif
+
+clean:
+               rm -f $(OBJS) .depend
+
+spotless:      clean
+               rm -f $(NAME)

Added: developers/werner/bqmeter/bqmeter.c
===================================================================
--- developers/werner/bqmeter/bqmeter.c                         (rev 0)
+++ developers/werner/bqmeter/bqmeter.c 2009-02-13 02:36:49 UTC (rev 4921)
@@ -0,0 +1,269 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+#include "pmu.h"
+
+
+/*
+ * PMU 1s      |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
+ * bq update  |              |              |               |              |
+ *                                                                 ^
+ *               ^                          ^               ^      |       ^
+ *               |------------->----------->|-------------->|--->->|------>|
+ * Duration      | t_setup       t_wait_bq  | Tbq           |  (*) | t_valid
+ * Time          t_init                     t_start         t_stop t_wake  t_dl
+ *
+ * (*) = t_fuzz, t_wait_rtc
+ *
+ * t_init      Time when we initiate the measurement in suspend process
+ * t_setup     Time until the system has entered suspend (must include t_fuzz)
+ * t_wait_bq   Time to wait until the next bq update interval
+ * t_start     Time at which the measurement begins
+ * Tbq         bq measurement interval
+ * t_stop      Time at which the measurement ends
+ * t_fuzz      Maximum timing error we tolerate
+ * t_wait_rtc  Time to wait for the next second interrupt of the RTC
+ * t_wake      Time at which we schdule a wakeup interrupt
+ * t_valid     Time we have to retrieve the measurement result
+ * t_dl                Time after which the measurement is invalid, t_dl = 
t_stop+Tbq
+ */
+
+
+#define        PMU_RTCSC       0x59            /* RTC second value register */
+
+#define T_BQ_US                5120000L        /* bq updates every 5.12 s */
+#define        T_PMU_US        1000000L        /* PMU updates every second */
+
+#define        T_FUZZ_US       100000L         /* 100 ms */
+
+
+static int pmu_fd;
+
+
+static int sysfs_read(const char *path)
+{
+       FILE *f;
+       int value;
+
+       f = fopen(path, "r");
+       if (!f)
+               goto fail;
+       if (fscanf(f, "%d\n", &value) < 0)
+               goto fail;
+       if (fclose(f) != EOF)
+               return;
+
+fail:
+       perror(path);
+       exit(1);
+}
+
+
+static void sysfs_write(const char *path, int value)
+{
+       FILE *f;
+
+       f = fopen(path, "w");
+       if (!f)
+               goto fail;
+       if (fprintf(f, "%d\n", value) < 0)
+               goto fail;
+       if (fclose(f) != EOF)
+               return;
+
+fail:
+       perror(path);
+       exit(1);
+}
+
+
+static int get_current(void)
+{
+}
+
+
+static void set_current(int high)
+{
+}
+
+
+static uint8_t read_bq(void)
+{
+}
+
+
+static uint8_t read_rtc(void)
+{
+       return pmu_read(pmu_fd, PMU_RTCSC);
+}
+
+
+static void now(struct timeval *t)
+{
+       if (gettimeofday(t, NULL) < 0) {
+               perror("gettimeofday");
+               exit(1);
+       }
+}
+
+
+/*
+ * returns b-a in microseconds. Caps the difference at ~1000 seconds.
+ */
+
+static long delta_us(const struct timeval *a, const struct timeval *b)
+{
+       long s, us;
+       
+       s = b->tv_sec-a->tv_sec;
+       if (s < -1000)
+               return -1000*1000*1000;
+       if (s > 1000)
+               return 1000*1000*1000;
+       us = b->tv_usec-a->tv_usec;
+       return us+1000*1000*s;
+}
+
+
+static void plus_us(struct timeval *t, long add_us)
+{
+       t->tv_usec += add_us;
+       while (t->tv_usec > 999999) {
+               t->tv_usec -= 1000000;
+               t->tv_sec++;
+       }
+}
+
+
+static void next_interval(struct timeval *t, const struct timeval *earliest,
+    long increment)
+{
+       while (1) {
+               if (t->tv_sec > earliest->tv_sec)
+                       return;
+               if (t->tv_sec == earliest->tv_sec &&
+                   t->tv_usec >= earliest->tv_usec)
+                       return;
+               plus_us(t, increment);
+       }
+}
+
+
+static int get_time_changes(struct timeval *bq, struct timeval *rtc)
+{
+       int old_current;
+       uint8_t bq0, rtc0;
+       int need_bq = 1, need_rtc = 1;
+       struct timeval t, next;
+       int ok = 0;
+       long diff;
+
+       old_current = get_current();
+       set_current(0);
+       sleep(6); /* > 5.12s, to make sure meter has taken the low value */
+       now(&t);
+       set_current(1);
+       bq0 = read_bq();
+       rtc0 = read_rtc();
+       while (need_bq || need_rtc) {
+               if (need_bq && bq0 != read_bq()) {
+                       need_bq = 0;
+                       *bq = t;
+               }
+               if (need_rtc && rtc0 != read_rtc()) {
+                       need_rtc = 0;
+                       *rtc = t;
+               }
+               now(&next);
+               diff = delta_us(&t, &next);
+               if (diff > T_FUZZ_US) {
+                       fprintf(stderr, "rejecting result (%ld us > %ld us)\n",
+                           diff, T_FUZZ_US);
+                       goto out;
+               }
+               t = next;
+       }
+       ok = 1;
+out:
+       if (!old_current)
+               set_current(0);
+       return ok;
+}
+
+
+static void foo(long t_setup_us, long t_fuzz_us)
+{
+       struct timeval t_ref, t_init;
+       struct timeval t_start_min, t_start, t_stop;
+       struct timeval t_wake_min, t_wake;
+       struct timeval t_dl, t_end;
+       struct timeval bq, rtc;
+
+       /* synchronize the clocks */
+
+       while (1) {
+               now(&t_ref);
+               if (get_time_changes(&bq, &rtc))
+                       break;
+       }
+       now(&t_init);
+
+       /* find t_start */
+
+       t_start_min = t_init;
+       plus_us(&t_start_min, t_setup_us);
+       t_start = bq;
+       next_interval(&t_start, &t_start_min, T_BQ_US);
+
+       /* find t_stop */
+
+       t_stop = t_start;
+       plus_us(&t_stop, T_BQ_US);
+
+       /* find t_wake */
+
+       t_wake_min = t_stop;
+       plus_us(&t_wake_min, t_fuzz_us);
+       t_wake = rtc;
+       next_interval(&t_wake, &t_wake_min, T_PMU_US);
+
+       /* find t_dl (deadline) */
+
+       t_dl = t_stop;
+       plus_us(&t_dl, T_BQ_US);
+
+       /* @@@ setup */
+       /* @@@ suspend */
+       /* @@@ retrieve result */
+       /* @@@ check deadline */
+
+       now(&t_end);
+
+       printf("t_init   %6.3f\n", delta_us(&t_ref, &t_init)/1000.0);
+       printf("t_start  %6.3f\n", delta_us(&t_ref, &t_start)/1000.0);
+       printf("t_stop   %6.3f\n", delta_us(&t_ref, &t_stop)/1000.0);
+       printf("t_wake   %6.3f\n", delta_us(&t_ref, &t_wake)/1000.0);
+       printf("t_dl     %6.3f\n", delta_us(&t_ref, &t_dl)/1000.0);
+       printf("end      %6.3f\n", delta_us(&t_ref, &t_end)/1000.0);
+
+       /*
+        * @@@ if we're serious about this check, then we should do it in the
+        * kernel, right after retrieving the data.
+        */
+       if (delta_us(&t_dl, &t_end) < 0) {
+               fprintf(stderr, "missed the deadline :-(\n");
+               exit(1);
+       }
+}
+
+
+int main(void)
+{
+       pmu_fd = pmu_open();
+       foo(10, 10);
+       return 0;
+}
+

Added: developers/werner/bqmeter/patches/hdq-read-nosleep.patch
===================================================================
--- developers/werner/bqmeter/patches/hdq-read-nosleep.patch                    
        (rev 0)
+++ developers/werner/bqmeter/patches/hdq-read-nosleep.patch    2009-02-13 
02:36:49 UTC (rev 4921)
@@ -0,0 +1,88 @@
+Index: ktrack/drivers/power/gta02_hdq.c
+===================================================================
+--- ktrack.orig/drivers/power/gta02_hdq.c      2009-02-04 06:38:20.000000000 
-0200
++++ ktrack/drivers/power/gta02_hdq.c   2009-02-04 06:38:51.000000000 -0200
+@@ -121,6 +121,71 @@
+ }
+ EXPORT_SYMBOL_GPL(gta02hdq_write);
+ 
++static inline int get_hdq(void)
++{
++      return s3c2410_gpio_getpin(fiq_ipc.hdq_gpio_pin);
++}
++
++static inline void set_hdq(int on)
++{
++      s3c2410_gpio_setpin(fiq_ipc.hdq_gpio_pin, on);
++}
++
++int gta02hdq_read_nosleep(int address)
++{
++      int i, j;
++      uint8_t res = 0;
++
++      if (!fiq_ipc.hdq_probed)
++              return -EINVAL;
++      /*
++       * It would be nice if we could mutex_trylock here, but that's
++       * forbidden. So we just make sure nothing is horribly wrong.
++       */
++      BUG_ON(mutex_is_locked(&fiq_ipc.hdq_lock));
++
++      s3c2410_gpio_cfgpin(fiq_ipc.hdq_gpio_pin, S3C2410_GPIO_OUTPUT);
++
++      /* send break */
++      set_hdq(0);
++      udelay(200);    /* min 190 us */
++      set_hdq(1);
++      udelay(50);     /* min 40 us */
++
++      /* send address and W/nR */
++      for (i = 0; i != 8; i++) {
++              set_hdq(0);
++              if (address & (1 << i)) {
++                      udelay(20);     /* min 0.5 us, max 50 us */
++              } else {
++                      udelay(100);    /* min 86 us, max 145 us */
++              }
++              set_hdq(1);
++              udelay(200);    /* min 190-tHW us */
++      }
++
++      /* get data byte */
++      s3c2410_gpio_cfgpin(fiq_ipc.hdq_gpio_pin, S3C2410_GPIO_INPUT);
++      for (i = 0; i != 8; i++) {
++              /* tCYCD = max 250 us and we've already have waited 100 us */
++              for (j = 200; !get_hdq() && j; j--)
++                      udelay(1);
++              if (!j)
++                      return -EIO;
++              /* tRSPS = max 320 us from start of W/nR */
++              for (j = 300; get_hdq() && j; j--)
++                      udelay(1);
++              if (!j)
++                      return -EIO;
++              udelay(100);    /* 1: 32-50 us; 0: 80-145 us */
++              if (get_hdq())
++                      res |= 1 << i;
++      }
++
++      return res;
++}
++EXPORT_SYMBOL_GPL(gta02hdq_read_nosleep);
++
+ /* sysfs */
+ 
+ static ssize_t hdq_sysfs_dump(struct device *dev, struct device_attribute 
*attr,
+Index: ktrack/include/linux/gta02_hdq.h
+===================================================================
+--- ktrack.orig/include/linux/gta02_hdq.h      2009-02-04 06:38:20.000000000 
-0200
++++ ktrack/include/linux/gta02_hdq.h   2009-02-04 06:39:20.000000000 -0200
+@@ -12,6 +12,7 @@
+ };
+ 
+ int gta02hdq_read(int address);
++int gta02hdq_read_nosleep(int address);
+ int gta02hdq_write(int address, u8 data);
+ int gta02hdq_initialized(void);
+ 

Added: developers/werner/bqmeter/patches/hdq-sysfs-read.patch
===================================================================
--- developers/werner/bqmeter/patches/hdq-sysfs-read.patch                      
        (rev 0)
+++ developers/werner/bqmeter/patches/hdq-sysfs-read.patch      2009-02-13 
02:36:49 UTC (rev 4921)
@@ -0,0 +1,53 @@
+Index: ktrack/drivers/power/gta02_hdq.c
+===================================================================
+--- ktrack.orig/drivers/power/gta02_hdq.c      2009-02-04 05:41:48.000000000 
-0200
++++ ktrack/drivers/power/gta02_hdq.c   2009-02-04 05:56:41.000000000 -0200
+@@ -26,6 +26,10 @@
+ #define HDQ_READ 0
+ #define HDQ_WRITE 0x80
+ 
++
++static atomic_t hdq_read_addr; /* address for sysfs read */
++
++
+ static int fiq_busy(void)
+ {
+       int request = (volatile u8)fiq_ipc.hdq_request_ctr;
+@@ -180,12 +184,37 @@
+       return count;
+ }
+ 
++static ssize_t hdq_sysfs_read_get(struct device *dev,
++    struct device_attribute *attr, char *buf)
++{
++      /* cache address so that we don't race with hdq_sysfs_read_set */
++      int addr = atomic_read(&hdq_read_addr);
++      uint8_t data;
++
++      data = gta02hdq_read(addr);
++
++      /*
++       * We also return the address so that the reader can retry or complain
++       * if there was a race with another user of the single-register read.
++       */
++      return sprintf(buf, "%d %u\n", addr, data);
++}
++
++static ssize_t hdq_sysfs_read_set(struct device *dev,
++    struct device_attribute *attr, const char *buf, size_t count)
++{
++      atomic_set(&hdq_read_addr, atoi(buf));
++      return 0;
++}
++
+ static DEVICE_ATTR(dump, 0400, hdq_sysfs_dump, NULL);
+ static DEVICE_ATTR(write, 0600, NULL, hdq_sysfs_write);
++static DEVICE_ATTR(read, 0600, hdq_sysfs_read_get, hdq_sysfs_read_set);
+ 
+ static struct attribute *gta02hdq_sysfs_entries[] = {
+       &dev_attr_dump.attr,
+       &dev_attr_write.attr,
++      &dev_attr_read.attr,
+       NULL
+ };
+ 

Added: developers/werner/bqmeter/patches/s3c-resume-early-action.patch
===================================================================
--- developers/werner/bqmeter/patches/s3c-resume-early-action.patch             
                (rev 0)
+++ developers/werner/bqmeter/patches/s3c-resume-early-action.patch     
2009-02-13 02:36:49 UTC (rev 4921)
@@ -0,0 +1,32 @@
+Index: ktrack/arch/arm/plat-s3c/include/plat/pm.h
+===================================================================
+--- ktrack.orig/arch/arm/plat-s3c/include/plat/pm.h    2009-02-04 
13:21:00.000000000 -0200
++++ ktrack/arch/arm/plat-s3c/include/plat/pm.h 2009-02-04 13:22:43.000000000 
-0200
+@@ -182,3 +182,5 @@
+ extern void s3c_pm_save_core(void);
+ extern void s3c_pm_restore_core(void);
+ 
++/* Early callback for instrumentation */
++extern void (*s3c_pm_resume_early_action)(void);
+Index: ktrack/arch/arm/plat-s3c/pm.c
+===================================================================
+--- ktrack.orig/arch/arm/plat-s3c/pm.c 2009-02-04 13:22:56.000000000 -0200
++++ ktrack/arch/arm/plat-s3c/pm.c      2009-02-04 13:23:16.000000000 -0200
+@@ -34,6 +34,7 @@
+ /* for external use */
+ 
+ unsigned long s3c_pm_flags;
++void (*s3c_pm_resume_early_action)(void);
+ 
+ /* Debug code:
+  *
+@@ -320,6 +321,9 @@
+       s3c_pm_restore_uarts();
+       s3c_pm_restore_gpios();
+ 
++      if (s3c_pm_resume_early_action)
++              s3c_pm_resume_early_action();
++
+       s3c_pm_debug_init();
+ 
+       /* check what irq (if any) restored the system */

Added: developers/werner/bqmeter/patches/series
===================================================================
--- developers/werner/bqmeter/patches/series                            (rev 0)
+++ developers/werner/bqmeter/patches/series    2009-02-13 02:36:49 UTC (rev 
4921)
@@ -0,0 +1,3 @@
+hdq-sysfs-read.patch
+hdq-read-nosleep.patch
+s3c-resume-early-action.patch




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-02-13 03:40:35 +0100 (Fri, 13 Feb 2009)
New Revision: 4922

Modified:
   developers/werner/ahrt/host/tmc/lib/decode.py
   developers/werner/ahrt/host/tmc/lib/dxplore.py
   developers/werner/ahrt/host/tmc/lib/meter.py
Log:
- added experimental I2C decoding (note: dual-edged trigger is the wrong
  approach. Should just give the decoder the raw bitstream and let it
  figure out what makes sense as a trigger. That approach will also work
  for protocols with a hidden timebase, such as RS-232.)
- basic access functions for multimeters. Work in progress.



Modified: developers/werner/ahrt/host/tmc/lib/decode.py
===================================================================
--- developers/werner/ahrt/host/tmc/lib/decode.py       2009-02-13 02:36:49 UTC 
(rev 4921)
+++ developers/werner/ahrt/host/tmc/lib/decode.py       2009-02-13 02:40:35 UTC 
(rev 4922)
@@ -568,6 +568,69 @@
     return d_usb(inverted)
 
 
+def d_i2c_payload(bits):
+    if len(bits) < 7:
+       return d_byte_msb(bits)
+    s = "%02X" % d_msb(bits[0:7])
+    del bits[0:7]
+
+    if not len(bits):
+       return s
+    if bits[0] == "X":
+       s += "X"
+    else:
+       s += ("W", "R")[bits[0]]
+    del bits[0]
+
+    while len(bits):
+       if bits[0] == "X":
+           s += "X"
+       else:
+           s += ("", "N")[bits[0]]
+       del bits[0]
+
+       if len(bits) < 8:
+           return s+d_byte_msb(bits)
+       s += "."+d_byte_msb(bits[0:8])
+       del bits[0:8]
+
+    return s
+
+
+def d_i2c_sda(bits):
+    if not len(bits):
+       return ""
+    if bits[0]:
+       return "?"
+    del bits[0]
+
+    s = "S"
+    p = []
+    while len(bits) > 1:
+       if bits[0] == 1 and bits[1] == 0:
+           s += d_i2c_payload(p)+".Sr"
+           r = []
+       elif bits[0] == 0 and bits[1] == 1:
+           return s+d_i2c_payload(p)+".P"
+       else:
+           p.append(bits[0])
+       del bits[0:2]
+
+    if len(bits):
+       p.append(bits[0])
+    if len(p):
+       s += d_i2c_payload(p)
+    return s
+ 
+
+def d_i2c_scl(bits):
+    n = len(bits)
+    if n == 0:
+       return ""
+    else:
+       return str(n/2)
+
+
 def d_set_table(table):
     global d_table
 
@@ -576,12 +639,14 @@
 
 decoders = [
     #  0123456789abcdef -- maximum length is 16 characters
-    ( "LSB->MSB",              d_byte_lsb ),
-    ( "MSB->LSB",              d_byte_msb ),
-    ( "SDIO CMD",              d_sdio_cmd ),
-    ( "SDIO RESP (SD)",                d_sdio_resp_sd ),
-    ( "SDIO RESP (SPI)",       d_sdio_resp_spi ),
-    ( "SDIO R5 (SPI)",         d_sdio_r5_spi ),
-    ( "USB D+",                        d_usb_dp ),
-    ( "USB D-",                        d_usb_dm ),
+    ( "LSB->MSB",              d_byte_lsb,             False ),
+    ( "MSB->LSB",              d_byte_msb,             False ),
+    ( "SDIO CMD",              d_sdio_cmd,             False ),
+    ( "SDIO RESP (SD)",                d_sdio_resp_sd,         False ),
+    ( "SDIO RESP (SPI)",       d_sdio_resp_spi,        False ),
+    ( "SDIO R5 (SPI)",         d_sdio_r5_spi,          False ),
+    ( "USB D+",                        d_usb_dp,               False ),
+    ( "USB D-",                        d_usb_dm,               False ),
+    ( "I2C SDA",               d_i2c_sda,              False ),
+    ( "I2C SCL",               d_i2c_scl,              True  ),
 ]

Modified: developers/werner/ahrt/host/tmc/lib/dxplore.py
===================================================================
--- developers/werner/ahrt/host/tmc/lib/dxplore.py      2009-02-13 02:36:49 UTC 
(rev 4921)
+++ developers/werner/ahrt/host/tmc/lib/dxplore.py      2009-02-13 02:40:35 UTC 
(rev 4922)
@@ -1,7 +1,7 @@
 #
 # dxplore.py - GUI for interactive exploration of digital waveforms
 #
-# Copyright (C) 2008 by OpenMoko, Inc.
+# Copyright (C) 2008, 2009 by OpenMoko, Inc.
 # Written by Werner Almesberger <wer...@openmoko.org>
 # All Rights Reserved
 #
@@ -132,8 +132,9 @@
     def deselect(self):
        self.main.w.itemconfig(self.tag, fill = self.color_normal)
 
-    def set_decoder(self, decoder):
+    def set_decoder(self, decoder, both_edges):
        self.decoder = decoder
+       self.both_edges = both_edges
 
     def begin_decode(self, pos):
        x0 = self.x(pos)
@@ -492,12 +493,13 @@
            # Brilliant hack. Found it described here:
            # http://infohost.nmt.edu/tcc/help/pubs/tkinter/extra-args.html
 
-           def handler(ch = ch, decoder = dec[1], button = mb, label = dec[0]):
-               ch.set_decoder(decoder)
+           def handler(ch = ch, decoder = dec[1], both_edges = dec[2],
+             button = mb, label = dec[0]):
+               ch.set_decoder(decoder, both_edges)
                button.config(text = label)
 
            mb.menu.add_command(label = dec[0], command = handler)
-           ch.set_decoder(decoders[0][1])
+           ch.set_decoder(decoders[0][1], decoders[0][2])
 
     def move(self, event):
        self.cur.move(event.x)
@@ -728,19 +730,20 @@
            i = self.decode_from
            while i <= self.cur.pos:
                if self.selected.d[i-1] != self.selected.d[i] and \
-                 self.selected.d[i] == self.selected.d[self.decode_from]:
+                 (self.selected.d[i] == self.selected.d[self.decode_from] or
+                 self.selected.both_edges):
                    if ch.d[i-1] == ch.d[i]:
                        bits.append(ch.d[i])
                    else:
                        bits.append("X")
                i += 1
            by_ch[ch] = bits
-           ch.pre_decode(ch is self.selected, bits)
+           ch.pre_decode(ch is self.selected and not ch.both_edges, bits)
 
        d_set_table(d_table)
 
        for ch in self.ch:
-           ch.decode(ch is self.selected, by_ch[ch])
+           ch.decode(ch is self.selected and not ch.both_edges, by_ch[ch])
 
     def end_decode(self):
        for ch in self.ch:

Modified: developers/werner/ahrt/host/tmc/lib/meter.py
===================================================================
--- developers/werner/ahrt/host/tmc/lib/meter.py        2009-02-13 02:36:49 UTC 
(rev 4921)
+++ developers/werner/ahrt/host/tmc/lib/meter.py        2009-02-13 02:40:35 UTC 
(rev 4922)
@@ -1,7 +1,7 @@
 #
 # meter.py - Multimeter control
 #
-# Copyright (C) 2008 by OpenMoko, Inc.
+# Copyright (C) 2008, 2009 by OpenMoko, Inc.
 # Written by Werner Almesberger <wer...@openmoko.org>
 # All Rights Reserved
 # 
@@ -11,20 +11,64 @@
 # (at your option) any later version.
 #
 
+#
+# async:
+#
+# - setup measurement
+# - start capture
+# - notify(capture ends)/stop capture
+# - retrieve and process
+#
+# .start(samples = Null)
+# .wait -> return vector
+# .stop -> return vector
+#
 
+
 from tmc.instrument import instrument, setting
 
 
 class meter(instrument):
-    # Warning: "meter" doesn't lock itself !
-    pass
+    def __init__(self, *args):
+       # Warning: "meter" doesn't lock itself !
+       instrument.__init__(self, *args)
 
+       self.avg = setting(self, "CALC:FUNC AVER;:CALC:STAT",
+         lambda x: x == 1,
+         lambda x: ("OFF", "ON")[x != 0])
+       self.min = setting(self, "CALC:AVER:MIN",
+         lambda x: float(x), None)
+       self.max = setting(self, "CALC:AVER:MAX",
+         lambda x: float(x), None)
+       self.avg = setting(self, "CALC:AVER:AVER",
+         lambda x: float(x), None)
+       self.count = setting(self, "CALC:AVER:COUNT",
+         lambda x: int(x), None)
 
+    def sample(self):
+       return float(self.query("READ?"))
+
+    def average(self, n):
+       sum = 0
+       for i in range(0, n):
+           sum += self.sample()
+       return sum/n
+
+    def v(self):
+       self.send("CONF:VOLT:DC")
+
+    def i(self):
+       self.send("CONF:CURR:DC MAX")
+
+
 class fluke_8845a(meter):
 
     def __init__(self, name):
        meter.__init__(self, "telnet", "tries=3", name)
        self.lock_attr()
+# Reset often activates some relays, so we shouldn't use it carelessly.
+#      self.send("*RST")
+       self.send(":SYST:REM")
 
 
 class picotest_m3500a(meter):




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to