mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 02:53:49 +01:00
Merge d3dapi changes; remove setportspeed (usbconnectiontester is a new repo); change Openwrt package category to 'Doodle3D'.
This commit is contained in:
parent
c5b91a2416
commit
6e61a6fdd2
5
Makefile
5
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
|
||||
|
@ -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
|
||||
|
@ -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 $?
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=18
|
||||
# start after networking
|
||||
START=22
|
||||
|
||||
LOGGER="logger -s -t autowifi -p 6"
|
||||
|
||||
boot() {
|
||||
|
@ -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)
|
@ -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 <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <linux/serial.h>
|
||||
#include <linux/termios.h>
|
||||
|
||||
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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user