Send commitlog mailing list submissions to
        [email protected]

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
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

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

   1. r2628 - trunk/src/target/u-boot/patches ([EMAIL PROTECTED])
   2. r2629 - in developers/werner: . neocon ([EMAIL PROTECTED])
--- Begin Message ---
Author: werner
Date: 2007-08-04 06:16:28 +0200 (Sat, 04 Aug 2007)
New Revision: 2628

Modified:
   trunk/src/target/u-boot/patches/boot-menu.patch
Log:
common/bootmenu.c:do_option, bootmenu_hook: renamed variable "aux" to "next"
common/bootmenu.c, include/bootmenu.h, board/neo1973/common/bootmenu.c: added 
  setup items "next_key_action" and "enter_key_name" allow for board-specific
  boot menu instructions



Modified: trunk/src/target/u-boot/patches/boot-menu.patch
===================================================================
--- trunk/src/target/u-boot/patches/boot-menu.patch     2007-08-03 20:50:28 UTC 
(rev 2627)
+++ trunk/src/target/u-boot/patches/boot-menu.patch     2007-08-04 04:16:28 UTC 
(rev 2628)
@@ -24,7 +24,7 @@
 ===================================================================
 --- /dev/null
 +++ u-boot/board/neo1973/common/bootmenu.c
-@@ -0,0 +1,120 @@
+@@ -0,0 +1,122 @@
 +/*
 + * bootmenu.c - Boot menu
 + *
@@ -135,6 +135,8 @@
 +      .enter_key = on_key,
 +      .seconds = seconds,
 +      .idle_action = poweroff_if_idle,
++      .next_key_action = "Press [AUX]",
++      .enter_key_name = "[POWER]",
 +};
 +
 +
@@ -366,7 +368,7 @@
 ===================================================================
 --- /dev/null
 +++ u-boot/common/bootmenu.c
-@@ -0,0 +1,311 @@
+@@ -0,0 +1,312 @@
 +/*
 + * bootmenu.c - Boot menu
 + *
@@ -498,7 +500,8 @@
 +      for (option = options; option != options+num_options; option++)
 +              print_option(option, option == options);
 +
-+      bm_printf("\n\nPress [AUX] to select, [POWER] to execute.\n");
++      bm_printf("\n\n%s to select, %s to execute.\n",
++          setup->next_key_action, setup->enter_key_name);
 +}
 +
 +
@@ -527,7 +530,7 @@
 +
 +static void do_option(const struct option *option)
 +{
-+      int seconds, aux;
++      int seconds, next;
 +
 +      bm_printf(ANSI_CLEAR ANSI_GOTOYX, 1, 1);
 +      redirect_console(1);
@@ -541,16 +544,16 @@
 +      seconds = get_var_positive_int("after_command_wait",
 +          AFTER_COMMAND_WAIT);
 +      if (seconds)
-+              bm_printf("\nPress [AUX] to %s.",
++              bm_printf("\n%s to %s.", setup->next_key_action,
 +                  option ? "return to boot menu" : "power off");
-+      aux = 1; /* require up-down transition */
++      next = 1; /* require up-down transition */
 +      while (seconds) {
 +              int tmp;
 +
 +              tmp = setup->next_key(setup->user);
-+              if (tmp && !aux)
++              if (tmp && !next)
 +                      break;
-+              aux = tmp;
++              next = tmp;
 +              if (setup->seconds(setup->user))
 +                      seconds--;
 +      }
@@ -562,7 +565,7 @@
 +
 +static void bootmenu_hook(int activity)
 +{
-+      static int aux = 1, on = 1;
++      static int next = 1, on = 1;
 +      static const struct option *option = options;
 +      static int seconds = 0;
 +      int tmp;
@@ -570,7 +573,7 @@
 +      if (activity)
 +              seconds = 0;
 +      tmp = setup->next_key(setup->user);
-+      if (tmp && !aux) {
++      if (tmp && !next) {
 +              print_option(option, 0);
 +              option++;
 +              if (option == options+num_options)
@@ -578,7 +581,7 @@
 +              print_option(option, 1);
 +              seconds = 0;
 +      }
-+      aux = tmp;
++      next = tmp;
 +      tmp = setup->enter_key(setup->user);
 +      if (tmp && !on) {
 +              do_option(option);
@@ -682,7 +685,7 @@
 ===================================================================
 --- /dev/null
 +++ u-boot/include/bootmenu.h
-@@ -0,0 +1,71 @@
+@@ -0,0 +1,79 @@
 +/*
 + * bootmenu.h - Boot menu
 + *
@@ -728,8 +731,16 @@
 +      /* action to take if the boot menu times out */
 +      void (*idle_action)(void *user);
 +
-+      /* user-specific data, passes "as is" to the functions above */
++      /* user-specific data, passed "as is" to the functions above */
 +      void *user;
++
++      /* Action to invoke the "next" function. Begins in upper case. E.g.,
++         "Press [AUX]". */
++      const char *next_key_action;
++
++      /* Name of the "enter" key, optionally with an action (in lower case).
++         E.g., "[POWER]" or "tap the screen". */
++      const char *enter_key_name;
 +};
 +
 +
@@ -758,7 +769,7 @@
 ===================================================================
 --- u-boot.orig/include/configs/neo1973_gta01.h
 +++ u-boot/include/configs/neo1973_gta01.h
-@@ -160,6 +160,8 @@
+@@ -155,6 +155,8 @@
  /* valid baudrates */
  #define CFG_BAUDRATE_TABLE    { 9600, 19200, 38400, 57600, 115200 }
  




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2007-08-04 08:02:22 +0200 (Sat, 04 Aug 2007)
New Revision: 2629

Added:
   developers/werner/neocon/
   developers/werner/neocon/Makefile
   developers/werner/neocon/README
   developers/werner/neocon/neocon.c
Log:
A simple interface for tty devices that pop in and out of existence.



Added: developers/werner/neocon/Makefile
===================================================================
--- developers/werner/neocon/Makefile   2007-08-04 04:16:28 UTC (rev 2628)
+++ developers/werner/neocon/Makefile   2007-08-04 06:02:22 UTC (rev 2629)
@@ -0,0 +1,16 @@
+PREFIX=/usr/local
+
+CFLAGS=-Wall -g
+
+.PHONY:        all clean install uninstall
+
+all:           neocon
+
+clean:
+               rm -f neocon
+
+install:       neocon
+               install -m 555 neocon $(PREFIX)/bin
+
+uninstall:
+               rm -f $(PREFIX)/bin/neocon

Added: developers/werner/neocon/README
===================================================================
--- developers/werner/neocon/README     2007-08-04 04:16:28 UTC (rev 2628)
+++ developers/werner/neocon/README     2007-08-04 06:02:22 UTC (rev 2629)
@@ -0,0 +1,9 @@
+"neocon" is a simple serial console utility that tries to open a
+ttys that may exist on a system until one such open succeeds. It
+then passes terminal input and output, until there is a read or
+write failure on the tty, in which case it disconnects, and the
+process restarts.
+
+This is mainly intended for serial over USB interfaces that
+disappear when the Neo or debug board is restarted. E.g.,
+neocon /dev/ttyUSB0 /dev/ttyUSB1

Added: developers/werner/neocon/neocon.c
===================================================================
--- developers/werner/neocon/neocon.c   2007-08-04 04:16:28 UTC (rev 2628)
+++ developers/werner/neocon/neocon.c   2007-08-04 06:02:22 UTC (rev 2629)
@@ -0,0 +1,224 @@
+/*
+ * neocon.c - An interface for changing tty devices
+ *
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by Werner Almesberger <[EMAIL PROTECTED]>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <sys/select.h>
+
+static char *const *ttys;
+static int num_ttys;
+static int bps = B115200;
+static struct termios console, tty;
+
+
+static void make_raw(int fd, struct termios *old)
+{
+    struct termios t;
+    long flags;
+
+    if (tcgetattr(fd, &t) < 0) {
+       perror("tcgetattr");
+       exit(1);
+    }
+    if (old)
+       *old = t;
+    cfmakeraw(&t);
+    if (fd) {
+       t.c_iflag  &= ~(IXON | IXOFF);
+       t.c_cflag |= CLOCAL;
+       t.c_cflag &= ~CRTSCTS;
+       if (cfsetispeed(&t, bps) < 0) {
+           perror("cfsetispeed");
+           exit(1);
+       }
+       if (cfsetospeed(&t, bps) < 0) {
+           perror("cfsetospeed");
+           exit(1);
+       }
+    }
+    if (tcsetattr(fd, TCSANOW, &t) < 0) {
+       perror("tcsetattr");
+       exit(1);
+    }
+    flags = fcntl(fd,F_GETFL);
+    if (flags < 0) {
+       perror("fcntl F_GETFL");
+       exit(1);
+    }
+    if (fcntl(fd,F_SETFL,flags & ~O_NONBLOCK) < 0) {
+       perror("fcntl F_GETFL");
+       exit(1);
+    }
+}
+
+
+static int open_first_tty(void)
+{
+    int i, fd = -1;
+
+    for (i = 0; i != num_ttys; i++) {
+       fd = open(ttys[i], O_RDWR | O_NDELAY);
+       if (fd >= 0)
+           break;
+    }
+    if (fd >= 0)
+       make_raw(fd, &tty);
+    return fd;
+}
+
+
+static void scan(const char *s, size_t len)
+{
+    static int state = 0;
+    size_t i;
+
+    for (i = 0; i != len; i++)
+       switch (state) {
+           case 0:
+               if (s[i] == '~')
+                   state++;
+               else
+                   state = 0;
+               break;
+           case 1:
+               if (s[i] == '.')
+                   exit(0);
+               state = 0;
+               break;
+       }
+}
+
+
+static int copy(int in, int out, int scan_escape)
+{
+    char buffer[2048];
+    ssize_t got, wrote, pos;
+ 
+    got = read(in, buffer, sizeof(buffer));
+    if (got < 0)
+       return 0;
+    if (scan_escape)
+       scan(buffer, got);
+    for (pos = 0; pos != got; pos += wrote) {
+       wrote = write(out, buffer+pos, got-pos);
+       if (wrote < 0)
+           return 0;
+    }
+    return 1;
+}
+
+
+static void write_string(const char *s)
+{
+    int len = strlen(s);
+
+    while (len) {
+       ssize_t wrote;
+
+       wrote = write(1, s, len);
+       if (wrote < 0) {
+           perror("write");
+           exit(1);
+       }
+       s += wrote;
+       len -= wrote;
+    }
+}
+
+
+static void cleanup(void)
+{
+    if (tcsetattr(0, TCSANOW, &console) < 0)
+       perror("tcsetattr");
+}
+
+
+static void usage(const char *name)
+{
+    fprintf(stderr, "usage: %s [-b bps] tty ...\n", name);
+    exit(1);
+}
+
+
+int main(int argc, char *const *argv)
+{
+    char *end;
+    int c;
+    int fd = -1;
+
+    while ((c = getopt(argc, argv, "")) != EOF)
+       switch (c) {
+           case 'b':
+               bps = strtoul(optarg, &end, 0);
+               if (!*end)
+                   usage(*argv);
+               break;
+           default:
+               usage(*argv);
+       }
+    num_ttys = argc-optind;
+    ttys = argv+optind;
+
+    make_raw(0, &console);
+    atexit(cleanup);
+    while (1) {
+       struct timeval tv;
+       fd_set set;
+       int res;
+
+       if (fd < 0) {
+           fd = open_first_tty();
+           if (fd > 0)
+               write_string("\r\n[Open]\r\n");
+       }
+       FD_ZERO(&set);
+       FD_SET(0, &set);
+       if (fd >= 0)
+           FD_SET(fd, &set);
+       tv.tv_sec = 0;
+       tv.tv_usec = 100000;
+       res = select(fd < 0 ? 1 : fd+1, &set, NULL, NULL, &tv);
+       if (res < 0) {
+           perror("select");
+           return 1;
+       }
+       if (FD_ISSET(0, &set))
+           if (!copy(0, fd, 1))
+               goto failed;
+       if (fd >= 0 && FD_ISSET(fd, &set))
+           if (!copy(fd, 1, 0))
+               goto failed;
+       continue;
+
+failed:
+       write_string("\r\n[Closed]\r\n");
+       (void) close(fd);
+       fd = -1;
+    }
+    return 0;
+}




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to