From 6e61a6fdd297ca254cf3c3c524c5ec043feef34c Mon Sep 17 00:00:00 2001 From: Wouter R Date: Mon, 26 Aug 2013 09:53:58 +0200 Subject: [PATCH] Merge d3dapi changes; remove setportspeed (usbconnectiontester is a new repo); change Openwrt package category to 'Doodle3D'. --- Makefile | 5 +- src/Makefile | 5 +- src/script/d3dapi | 2 +- src/script/wifibox_init | 4 +- src/util/setportspeed/Makefile | 17 ---- src/util/setportspeed/setportspeed.c | 113 --------------------------- 6 files changed, 6 insertions(+), 140 deletions(-) delete mode 100644 src/util/setportspeed/Makefile delete mode 100644 src/util/setportspeed/setportspeed.c diff --git a/Makefile b/Makefile index 688c872..ab0f481 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ include $(INCLUDE_DIR)/package.mk define Package/wifibox SECTION:=mods - CATEGORY:=Miscellaneous + CATEGORY:=Doodle3D MENU:=1 # DEFAULT:=y TITLE:=Doodle3D WifiBox firmware @@ -73,7 +73,6 @@ endef WIFIBOX_BASE_DIR := $(PKG_BUILD_DIR) GPX_BASE_DIR := $(PKG_BUILD_DIR)/util/GPX.git -SETPORTSPEED_BASE_DIR := $(PKG_BUILD_DIR)/util/setportspeed TGT_LUA_DIR_SUFFIX := usr/share/lua/wifibox define Package/wifibox/install @@ -123,8 +122,6 @@ endif ### install gpx utility $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(GPX_BASE_DIR)/gpx $(1)/usr/bin - - $(INSTALL_BIN) $(SETPORTSPEED_BASE_DIR)/setportspeed $(1)/usr/bin endef define Package/wifibox/postinst diff --git a/src/Makefile b/src/Makefile index db977bc..fdf09fd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,12 +1,9 @@ GPX_PATH := util/GPX.git -SETPORTSPEED_PATH := util/setportspeed -.PHONY: $(GPX_PATH) $(SETPORTSPEED_PATH) +.PHONY: $(GPX_PATH) all: $(MAKE) -C $(GPX_PATH) - $(MAKE) -C $(SETPORTSPEED_PATH) clean: $(MAKE) -C $(GPX_PATH) clean - $(MAKE) -C $(SETPORTSPEED_PATH) clean diff --git a/src/script/d3dapi b/src/script/d3dapi index 5296f58..46e343a 100755 --- a/src/script/d3dapi +++ b/src/script/d3dapi @@ -9,7 +9,7 @@ LOG_FILE=/tmp/wifibox.log cd $SCRIPT_PATH echo "CGI invocation" >> $LOG_FILE -$LUA ./cmdmain.lua $@ 2>> $LOG_FILE +strace - /tmp/trace-$$.log $LUA ./cmdmain.lua $@ 2>> $LOG_FILE exit $? diff --git a/src/script/wifibox_init b/src/script/wifibox_init index 0e8382f..46d43e9 100755 --- a/src/script/wifibox_init +++ b/src/script/wifibox_init @@ -1,6 +1,8 @@ #!/bin/sh /etc/rc.common -START=18 +# start after networking +START=22 + LOGGER="logger -s -t autowifi -p 6" boot() { diff --git a/src/util/setportspeed/Makefile b/src/util/setportspeed/Makefile deleted file mode 100644 index efdd7b4..0000000 --- a/src/util/setportspeed/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -SRC := setportspeed.c -OBJ := setportspeed.o -EXEC := setportspeed -CFLAGS += -Wall - -all: $(EXEC) - -$(EXEC): $(OBJ) - $(CC) $(LDFLAGS) -o $@ $(OBJ) - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -.PHONY: clean -clean: - rm -f $(EXEC) - rm -f $(OBJ) diff --git a/src/util/setportspeed/setportspeed.c b/src/util/setportspeed/setportspeed.c deleted file mode 100644 index 44a8014..0000000 --- a/src/util/setportspeed/setportspeed.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * USB serial connectivity tester - * - * based on: http://lists.uclibc.org/pipermail/uclibc/2008-January/039683.html - * see: http://marc.info/?l=linux-serial&m=120661887111805&w=2 - */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -static int serial_fd; -static char* serial_dev; -static int baud_rate; - -typedef enum SET_SPEED_RESULT { - SSR_OK = 0, SSR_IO_GET, SSR_IO_SET, SSR_IO_MGET, SSR_IO_MSET1, SSR_IO_MSET2 -} SET_SPEED_RESULT; - -/* based on setSerialSpeed in UltiFi */ -static int setPortSpeed(int fd, int speed) { - int rv; - struct termios2 options; - int modemBits; - - if (ioctl(fd, TCGETS2, &options) < 0) return SSR_IO_GET; - - cfmakeraw(&options); - - // Enable the receiver - options.c_cflag |= CREAD; - - // Clear handshake, parity, stopbits and size - options.c_cflag &= ~CLOCAL; - options.c_cflag &= ~CRTSCTS; - options.c_cflag &= ~PARENB; - options.c_cflag &= ~CSTOPB; - options.c_cflag &= ~CSIZE; - - //set speed - options.c_ospeed = options.c_ispeed = speed; - options.c_cflag &= ~CBAUD; - options.c_cflag |= BOTHER; - - options.c_cflag |= CS8; - options.c_cflag |= CLOCAL; - - if (ioctl(fd, TCSETS2, &options) < 0) return SSR_IO_SET; - - //toggle DTR - if (ioctl(fd, TIOCMGET, &modemBits) < 0) return SSR_IO_MGET); - modemBits |= TIOCM_DTR; - if (ioctl(fd, TIOCMSET, &modemBits) < 0) return SSR_IO_MSET1); - usleep(100 * 1000); - modemBits &=~TIOCM_DTR; - if (ioctl(fd, TIOCMSET, &modemBits) < 0) return SSR_IO_MSET2); - - return SSR_OK; -} - -int main(int argc, char** argv) { - SET_SPEED_RESULT spdResult; - - if (argc < 2) { - fprintf(stderr, "%s: please supply a port name, optionally followed by the port speed\n", argv[0]); - exit(1); - } - - serial_dev = argv[1]; - - if (argc >= 3) { - baud_rate = strtol(argv[2], NULL, 10); - } else { - baud_rate = 115200; - } - - serial_fd = open(serial_dev, O_RDWR); - if (serial_fd == -1) { - fprintf(stderr, "%s: could not open port %s (%s)\n", argv[0], portname, strerror(errno)); - exit(2); - } - - printf("using port %s with speed %i\n", serial_dev, baud_rate); - - spdResult = setPortSpeed(baud_rate); - switch (spdResult) { - case SSR_OK: - printf("port opened ok\n"); - break; - case SSR_IO_GET: fprintf(stderr, "ioctl error in setPortSpeed() on TCGETS2 (%s)\n", strerror(errno)); - case SSR_IO_SET: fprintf(stderr, "ioctl error in setPortSpeed() on TCSETS2 (%s)\n", strerror(errno)); - case SSR_IO_MGET: fprintf(stderr, "ioctl error in setPortSpeed() on TIOCMGET (%s)\n", strerror(errno)); - case SSR_IO_MSET1: fprintf(stderr, "ioctl error in setPortSpeed() on TIOCMSET1 (%s)\n", strerror(errno)); - case SSR_IO_MSET2: fprintf(stderr, "ioctl error in setPortSpeed() on TIOCMSET2 (%s)\n", strerror(errno)); - - exit(1); - break; - } - - //TODO: rename this program to something like 'usb_serial_tester' (also change in Makefile etc.) - //TODO: make existing code above compile and behave as intended - //TODO: (maybe): add timing messages to detect how long everything takes and when (if) things get stuck - //TODO: periodically send message and check if it is returned (by tiny program on arduino which echoes everything back) - - close(serial_fd); - exit(0); -}