Commit 89bf0a7f authored by Timothy Stack's avatar Timothy Stack

A bunch of engineering on the robot code.  I'm sure I've broken something,
but the majority of it is done and I wanted to get a checkpoint in.

	* GNUmakerules: Add rpcgen rules.

	* Makeconf.in: Add PATH and host_cpu variables so
	cross-compilation works properly.  Add JAVAC and JAR for java
	compilation.  Add BRAINSTEM_DIR that refers to a brainstem build
	directory to be used for the robot build.

	* configure, configure.in: Prepend the arm cross-compile dir to
	PATH.  Detect java for building applets.  Add --with-brainstem to
	specify the brainstem build dir.  Add --enable-mezzanine to turn
	on the mezzanine build.

	* robots/GNUmakefile.in: Add client target that builds the
	subdirs.

	* robots/emc/GNUmakefile.in, robots/emc/emcd.h, robots/emc/emcd.c,
	test_emcd.sh.in, robots/rmcd/GNUmakefile.in, robots/rmcd/rmcd.c,
	robots/rmcd/test_rmcd.sh.in, robots/vmcd/test_vmc-client.sh.in,
	robots/vmcd/test_vmcd.sh.in, robots/vmcd/test_vmcd2.sh,
	robots/vmcd/test_vmcd3.sh, robots/vmcd/test_vmcd4.sh,
	robots/vmcd/vmc-client.c, robots/vmcd/vmcd.c: Updates for the mtp
	switch to using rpcgen.

	* robots/emc/test_emcd.config: Restore missing config line.

	* robots/mtp/GNUmakefile.in, robots/mtp/global_bound.java,
	robots/mtp/mtp.h, robots/mtp/mtp.c, robots/mtp/mtp.java,
	robots/mtp/mtp.x, robots/mtp/mtp_command_goto.java,
	robots/mtp/mtp_command_stop.java, robots/mtp/mtp_config_rmc.java,
	robots/mtp/mtp_config_vmc.java, robots/mtp/mtp_control.java,
	robots/mtp/mtp_dump.c, robots/mtp/mtp_garcia_telemetry.java,
	robots/mtp/mtp_opcode_t.java, robots/mtp/mtp_packet.java,
	robots/mtp/mtp_payload.java, robots/mtp/mtp_recv.c,
	robots/mtp/mtp_request_id.java,
	robots/mtp/mtp_request_position.java,
	robots/mtp/mtp_robot_type_t.java, robots/mtp/mtp_role_t.java,
	robots/mtp/mtp_send.c, robots/mtp/mtp_status_t.java,
	robots/mtp/mtp_telemetry.java, robots/mtp/mtp_update_id.java,
	robots/mtp/mtp_update_position.java, robots/mtp/robot_config.java,
	robots/mtp/robot_position.java, robots/mtp/test_mtp.sh: Replace
	hand-generated stubs with xdr stubs for C and java.  Java stubs
	were generated by "remotetea's" jrpcgen.

	* robots/primotion/GNUmakefile.in,
	robots/primotion/buttonManager.hh,
	robots/primotion/buttonManager.cc, robots/primotion/dashboard.hh,
	robots/primotion/dashboard.cc, robots/primotion/flash-user-led.cc,
	robots/primotion/garcia-pilot.cc, robots/primotion/garciaUtil.hh,
	robots/primotion/garciaUtil.cc, robots/primotion/ledManager.hh,
	robots/primotion/ledManager.cc,
	robots/primotion/pilotButtonCallback.hh,
	robots/primotion/pilotButtonCallback.cc,
	robots/primotion/pilotClient.hh, robots/primotion/pilotClient.cc,
	robots/primotion/watch-user-button.cc,
	robots/primotion/wheelManager.hh,
	robots/primotion/wheelManager.cc: Replace gorobot with
	garcia-pilot, a beefed up daemon for controlling the robots.
	Improvements include: making use of the user LED and button to
	give some feedback and let the wrangler run a test sequence,
	reboot, and shutdown the robot; Logging of the battery level, how
	often the robot has moved and for how long, and the distance
	traveled; telemetry is sent back to emulab clients; movements are
	now just pivot-move instead of pivot-move-pivot, since the second
	pivot ends up being extra work most of the time; the robot will
	move backwards to cut down on the amount of rotation; and just
	generic cleanups to the code.

	* robots/primotion/garcia.config: The configuration file currently
	used on the garcias.

	* www/GNUmakefile.in: Add garcia-telemetry subdir to the build.

	* www/dbdefs.php3.in: Add TBNodeClass and TBNodeStatus functions.

	* www/garcia-telemetry/Base64.java,
	www/garcia-telemetry/GNUmakefile.in,
	www/garcia-telemetry/GarciaTelemetry.java,
	www/garcia-telemetry/UpdateThread.java,
	www/garcia-telemetry/main.xml: A telemetry applet for the garcia,
	it displays readouts for the various sensors and other bits of data
	gathered by the garcia-pilot daemon.  Hopefully, it will make a
	handy debugging tool.

	* www/garcia-telemetry.jar, www/mtp.jar, www/oncrpc.jar,
	www/thinlet.jar: Java jars used by the robot telemetry applet.

	* www/servicepipe.php3: A slightly enhanced version of
	ledpipe.php3 that can be used for other services, like robot
	telemetry.

	* www/shownode.php3: Add "Show Telemetry" menu item to robot
	nodes.

	* www/telemetry.php3: Telemetry page for the garcia-telemetry
	applet.
parent 34c4029e
......@@ -62,6 +62,12 @@ vpath % $(SRCDIR) $(MOSTLY_SRCDIRS)
%.o: %.cc
$(CXX) -c -o $@ $(CXXFLAGS) $<
%_xdr.h: %.x
rpcgen -h $< > $@
%_xdr.c: %.x %_xdr.h
rpcgen -c $< > $@
#
# Rules to regen configure written files.
#
......
......@@ -4,6 +4,10 @@
# this fragment
#
# Need the PATH because the older autoconf does not support
# AC_PATH_TOOL which is needed for cross-compilation to work.
export PATH = @PATH@
export CC = @CC@
export CXX = @CXX@
export LD = @CC@ ${CFLAGS}
......@@ -11,6 +15,9 @@ export STRIP = @STRIP@
export RANLIB = @RANLIB@
export AR = @AR@
export JAVAC = @JAVAC@
export JAR = @JAR@
prefix = @prefix@
exec_prefix = @exec_prefix@
......@@ -63,3 +70,6 @@ LOG_TESTBED = @LOG_TESTBED@
EVENTSYS = @EVENTSYS@
HAVE_MEZZANINE = @HAVE_MEZZANINE@
GTK_CONFIG = @GTK_CONFIG@
BRAINSTEM_DIR = @BRAINSTEM_DIR@
host_cpu = @host_cpu@
......@@ -24,6 +24,8 @@ ac_help="$ac_help
--with-rcdir Specify path to install rc.d scripts (/usr/local/etc/rc.d default)"
ac_help="$ac_help
--with-apache-config Specify path to install apache config files (/usr/local/etc/apache default)"
ac_help="$ac_help
--with-brainstem=<DIR> Specify the path to the brainstem installation."
ac_help="$ac_help
--enable-debug Build with debug flags (-g -DDEBUG)
--disable-debug Build with optimization flags (-O2 -DNDEBUG -UDEBUG)"
......@@ -31,6 +33,8 @@ ac_help="$ac_help
--disable-events Disable events (requires Elvin libraries)"
ac_help="$ac_help
--enable-windows Enable Windows XP support (requires third-party software)"
ac_help="$ac_help
--enable-mezzanine Enable mezzanine support"
ac_help="$ac_help
--enable-testmode Enable test mode
--disable-testmode Disable test mode"
......@@ -577,6 +581,21 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
for tbarch in arm/3.4.1; do
PATH="/usr/local/$tbarch/bin:${PATH}"
done
if test x"${JAVA_HOME}" != x""; then
PATH="${JAVA_HOME}/bin:${PATH}"
else
for jdk in /usr/local/jdk*; do
PATH="${jdk}/bin:${PATH}"
break
done
fi
# Make sure we can run config.sub.
if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
......@@ -584,7 +603,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
echo "configure:588: checking host system type" >&5
echo "configure:607: checking host system type" >&5
host_alias=$host
case "$host_alias" in
......@@ -605,7 +624,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
echo "configure:609: checking build system type" >&5
echo "configure:628: checking build system type" >&5
build_alias=$build
case "$build_alias" in
......@@ -631,7 +650,7 @@ fi
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:635: checking for $ac_word" >&5
echo "configure:654: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -663,7 +682,7 @@ fi
# Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args.
set dummy ${ac_tool_prefix}g++; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:667: checking for $ac_word" >&5
echo "configure:686: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -695,7 +714,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:699: checking for $ac_word" >&5
echo "configure:718: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -727,7 +746,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:731: checking for $ac_word" >&5
echo "configure:750: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -759,7 +778,7 @@ fi
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:763: checking for $ac_word" >&5
echo "configure:782: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -788,10 +807,82 @@ fi
# Extract the first word of "javac", so it can be a program name with args.
set dummy javac; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:815: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_JAVAC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
case "$JAVAC" in
/*)
ac_cv_path_JAVAC="$JAVAC" # Let the user override the test with a path.
;;
?:/*)
ac_cv_path_JAVAC="$JAVAC" # Let the user override the test with a dos path.
;;
*)
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_path_JAVAC="$ac_dir/$ac_word"
break
fi
done
IFS="$ac_save_ifs"
;;
esac
fi
JAVAC="$ac_cv_path_JAVAC"
if test -n "$JAVAC"; then
echo "$ac_t""$JAVAC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
# Extract the first word of "jar", so it can be a program name with args.
set dummy jar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:850: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_JAR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
case "$JAR" in
/*)
ac_cv_path_JAR="$JAR" # Let the user override the test with a path.
;;
?:/*)
ac_cv_path_JAR="$JAR" # Let the user override the test with a dos path.
;;
*)
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_path_JAR="$ac_dir/$ac_word"
break
fi
done
IFS="$ac_save_ifs"
;;
esac
fi
JAR="$ac_cv_path_JAR"
if test -n "$JAR"; then
echo "$ac_t""$JAR" 1>&6
else
echo "$ac_t""no" 1>&6
fi
# Extract the first word of "${ac_tool_prefix}ssh", so it can be a program name with args.
set dummy ${ac_tool_prefix}ssh; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:795: checking for $ac_word" >&5
echo "configure:886: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_SSH'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -1329,6 +1420,27 @@ fi
#
# Path to garcia installation
#
# Check whether --with-brainstem or --without-brainstem was given.
if test "${with_brainstem+set}" = set; then
withval="$with_brainstem"
if test x"$withval" != x""; then
BRAINSTEM_DIR="$withval"
else
{ echo "configure: error: You must specify a brainstem directory" 1>&2; exit 1; };
fi
else
BRAINSTEM_DIR=""
fi
#
# Optionally build with optimization or aggressive non-optimization
......@@ -1429,7 +1541,7 @@ fi
# Check for the robot vision system dependencies.
#
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:1433: checking how to run the C preprocessor" >&5
echo "configure:1545: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
......@@ -1444,13 +1556,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 1448 "configure"
#line 1560 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1454: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1566: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
......@@ -1461,13 +1573,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 1465 "configure"
#line 1577 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1471: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1583: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
......@@ -1478,13 +1590,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 1482 "configure"
#line 1594 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1488: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1600: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
......@@ -1512,17 +1624,17 @@ for ac_hdr in linux/videodev.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1516: checking for $ac_hdr" >&5
echo "configure:1628: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1521 "configure"
#line 1633 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1526: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1638: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -1555,7 +1667,7 @@ done
# Extract the first word of "gtk-config", so it can be a program name with args.
set dummy gtk-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1559: checking for $ac_word" >&5
echo "configure:1671: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_GTK_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -1582,8 +1694,15 @@ else
fi
# Check whether --enable-mezzanine or --disable-mezzanine was given.
if test "${enable_mezzanine+set}" = set; then
enableval="$enable_mezzanine"
:
fi
if test x"$HAVE_LINUX_VIDEODEV_H" != x"" && test x"$GTK_CONFIG" != x""; then
HAVE_MEZZANINE="yes"
HAVE_MEZZANINE="$enable_mezzanine"
cat >> confdefs.h <<\EOF
#define HAVE_MEZZANINE 1
EOF
......@@ -1627,7 +1746,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:1631: checking for a BSD compatible install" >&5
echo "configure:1750: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -1789,7 +1908,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/link_config utils/import_commitlog utils/dhcpd_wrapper \
utils/opsreboot utils/deletenode utils/webdeletenode utils/spewleds \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
www/swish.conf www/websearch \
www/swish.conf www/websearch www/garcia-telemetry/GNUmakefile \
vis/GNUmakefile vis/webvistopology vis/dbvistopology \
vis/prerender vis/prerender_all vis/render \
vis/floormap vis/webfloormap \
......@@ -1961,6 +2080,7 @@ s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@PATH@%$PATH%g
s%@host@%$host%g
s%@host_alias@%$host_alias%g
s%@host_cpu@%$host_cpu%g
......@@ -1976,6 +2096,8 @@ s%@CXX@%$CXX%g
s%@AR@%$AR%g
s%@RANLIB@%$RANLIB%g
s%@STRIP@%$STRIP%g
s%@JAVAC@%$JAVAC%g
s%@JAR@%$JAR%g
s%@SSH@%$SSH%g
s%@optional_subdirs@%$optional_subdirs%g
s%@TBDBNAME@%$TBDBNAME%g
......@@ -2081,6 +2203,7 @@ s%@ASSIGN@%$ASSIGN%g
s%@SSH_ARGS@%$SSH_ARGS%g
s%@INSTALL_RCDIR@%$INSTALL_RCDIR%g
s%@INSTALL_APACHE_CONFIG@%$INSTALL_APACHE_CONFIG%g
s%@BRAINSTEM_DIR@%$BRAINSTEM_DIR%g
s%@OPT_CFLAGS@%$OPT_CFLAGS%g
s%@EVENTSYS@%$EVENTSYS%g
s%@WINSUPPORT@%$WINSUPPORT%g
......
......@@ -6,11 +6,30 @@ AC_CONFIG_AUX_DIR(${srcdir}/autoconf)
AC_PREFIX_DEFAULT(/usr/testbed)
AC_CONFIG_HEADER(config.h)
for tbarch in arm/3.4.1; do
PATH="/usr/local/$tbarch/bin:${PATH}"
done
if test x"${JAVA_HOME}" != x""; then
PATH="${JAVA_HOME}/bin:${PATH}"
else
for jdk in /usr/local/jdk*; do
PATH="${jdk}/bin:${PATH}"
break
done
fi
AC_SUBST(PATH)
AC_CHECK_TOOL(CC,gcc)
AC_CHECK_TOOL(CXX,g++)
AC_CHECK_TOOL(AR,ar)
AC_CHECK_TOOL(RANLIB,ranlib)
AC_CHECK_TOOL(STRIP,strip)
AC_PATH_PROG(JAVAC,javac)
AC_PATH_PROG(JAR,jar)
AC_CHECK_TOOL(SSH,ssh)
AC_SUBST(optional_subdirs)
......@@ -415,6 +434,22 @@ AC_ARG_WITH(apache-config-dir,
])
AC_SUBST(INSTALL_APACHE_CONFIG)
#
# Path to garcia installation
#
AC_ARG_WITH(brainstem,
[ --with-brainstem=<DIR> Specify the path to the brainstem installation.],
[
if test x"$withval" != x""; then
BRAINSTEM_DIR="$withval"
else
AC_MSG_ERROR([You must specify a brainstem directory]);
fi
],[
BRAINSTEM_DIR=""
])
AC_SUBST(BRAINSTEM_DIR)
#
# Optionally build with optimization or aggressive non-optimization
......@@ -508,8 +543,11 @@ AC_CHECK_HEADERS([linux/videodev.h],
HAVE_LINUX_VIDEODEV_H="yes"])
AC_CHECK_PROG(GTK_CONFIG, gtk-config, gtk-config)
AC_ARG_ENABLE(mezzanine,
[ --enable-mezzanine Enable mezzanine support])
if test x"$HAVE_LINUX_VIDEODEV_H" != x"" && test x"$GTK_CONFIG" != x""; then
HAVE_MEZZANINE="yes"
HAVE_MEZZANINE="$enable_mezzanine"
AC_DEFINE([HAVE_MEZZANINE])
else
HAVE_MEZZANINE="no"
......@@ -646,7 +684,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/link_config utils/import_commitlog utils/dhcpd_wrapper \
utils/opsreboot utils/deletenode utils/webdeletenode utils/spewleds \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
www/swish.conf www/websearch \
www/swish.conf www/websearch www/garcia-telemetry/GNUmakefile \
vis/GNUmakefile vis/webvistopology vis/dbvistopology \
vis/prerender vis/prerender_all vis/render \
vis/floormap vis/webfloormap \
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# Copyright (c) 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -26,6 +26,7 @@ endif
SUBDIRS = $(MEZZDIR) mtp $(EMCDIR) vmcd primotion rmcd
all: all-subdirs
client: client-subdirs
check: check-subdirs
install: install-subdirs
......@@ -40,4 +41,3 @@ clean: clean-subdirs
%-subdirs: $(addsuffix /%.MAKE,$(SUBDIRS)) ;
.PHONY: $(SUBDIRS)
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# Copyright (c) 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -15,12 +15,13 @@ PROGS = emcd loclistener
TESTS = test_emcd.sh
all: $(PROGS)
client:
include $(TESTBED_SRCDIR)/GNUmakerules
OBJS = emcd.o robot_list.o
CFLAGS += -O -g -Wall -I${OBJDIR} -I/usr/local/include
CFLAGS += -I${SRCDIR}/../mtp -I${SRCDIR}/../../event/lib
CFLAGS += -I${SRCDIR}/../mtp -I../mtp -I${SRCDIR}/../../event/lib
CFLAGS += -I${SRCDIR}/../../lib/libtb
CFLAGS += `elvin-config --cflags vin4c`
LDFLAGS = -L../mtp -L${OBJDIR}/lib/libtb -L${OBJDIR}/event/lib
......
......@@ -38,6 +38,7 @@
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
......@@ -67,7 +68,7 @@ static char *pideid;
static char *progname;
static int debug = 0;
static int debug;
static int port = EMC_SERVER_PORT;
static int command_seq_no = 0;
......@@ -86,9 +87,12 @@ struct robot_list *position_queue = NULL;
static elvin_error_t elvin_error;
static struct rmc_client rmc_data = { -1 };
static struct vmc_client vmc_data = { -1 };
static int emulab_sock = -1;
static struct mtp_packet config_rmc;
static struct mtp_packet config_vmc;
static struct rmc_client rmc_data;
static struct vmc_client vmc_data;
static mtp_handle_t emulab_handle = NULL;
static void ev_callback(event_handle_t handle,
event_notification_t notification,
......@@ -290,6 +294,8 @@ int main(int argc, char *argv[])
else
loginit(1, "emcd");
}
debug = 1;
signal(SIGSEGV, sigpanic);
signal(SIGBUS, sigpanic);
......@@ -443,7 +449,7 @@ void parse_config_file(char *config_file) {
char *delim = " \t\n";
char *state = NULL;
struct emc_robot_config *rc;
struct position *p;
struct robot_position *p;
struct hostent *he;
++line_no;
......@@ -505,7 +511,7 @@ void parse_config_file(char *config_file) {
rc->token = ~0;
robot_list_append(hostname_list,id,(void*)rc);
p = (struct position *)malloc(sizeof(struct position *));
p = (struct robot_position *)malloc(sizeof(struct robot_position *));
p->x = init_x;
p->y = init_y;
p->theta = init_theta;
......@@ -514,6 +520,33 @@ void parse_config_file(char *config_file) {
// next line!
}
{
struct robot_config *robot_val, *rc;
struct robot_list_enum *e;
int lpc = 0;
robot_val = malloc(sizeof(robot_config) * hostname_list->item_count);
e = robot_list_enum(hostname_list);
while ((rc = (struct robot_config *)
robot_list_enum_next_element(e)) != NULL) {
robot_val[lpc] = *rc;
lpc += 1;
}
robot_list_enum_destroy(e);
mtp_init_packet(&config_rmc,
MA_Opcode, MTP_CONFIG_RMC,
MA_Role, MTP_ROLE_EMC,
MA_RobotLen, hostname_list->item_count,
MA_RobotVal, robot_val,
MA_TAG_DONE);
mtp_init_packet(&config_vmc,
MA_Opcode, MTP_CONFIG_VMC,
MA_Role, MTP_ROLE_EMC,
MA_RobotLen, hostname_list->item_count,
MA_RobotVal, robot_val,
MA_TAG_DONE);
}
}
void parse_movement_file(char *movement_file) {
......@@ -549,7 +582,7 @@ void parse_movement_file(char *movement_file) {
char *token = NULL;
char *delim = " \t";
char *state = NULL;
struct position *p;
struct robot_position *p;
++line_no;
......@@ -583,7 +616,7 @@ void parse_movement_file(char *movement_file) {
// now we save this data to the lists:
p = (struct position *)malloc(sizeof(struct position *));
p = (struct robot_position *)malloc(sizeof(struct robot_position *));
p->x = init_x;
p->y = init_y;
p->theta = init_theta;
......@@ -620,10 +653,9 @@ void ev_callback(event_handle_t handle,
error("no match for host\n");
}
else {
struct mtp_command_goto mcg;
char *value, args[BUFSIZ];
float x, y, orientation;
struct mtp_packet *mp;
struct mtp_packet mp;
event_notification_get_arguments(handle, notification, args, sizeof(args));
......@@ -650,24 +682,23 @@ void ev_callback(event_handle_t handle,
orientation = orientation * M_PI / 180.0;
mcg.command_id = 1;
mcg.robot_id = match->id;
mcg.position.x = x;
mcg.position.y = y;
mcg.position.theta = orientation;
if ((mp = mtp_make_packet(MTP_COMMAND_GOTO,
MTP_ROLE_EMULAB,
&mcg)) == NULL) {
error("could not allocate packet\n");
}
else if (rmc_data.sock_fd != -1) {
mtp_send_packet(rmc_data.sock_fd, mp);
mtp_init_packet(&mp,
MA_Opcode, MTP_COMMAND_GOTO,
MA_Role, MTP_ROLE_EMC,
MA_CommandID, 1,
MA_RobotID, match->id,
MA_X, x,
MA_Y, y,
MA_Theta, orientation,
MA_TAG_DONE);
if (rmc_data.handle != NULL) {
mtp_send_packet(rmc_data.handle, &mp);
}
else {
mtp_print_packet(stdout, mp);
mtp_print_packet(stdout, &mp);
#if defined(TBDB_EVENTTYPE_COMPLETE)
event_do(handle,
EA_Experiment, pideid,
EA_Type, TBDB_OBJECTTYPE_NODE,
......@@ -676,10 +707,10 @@ void ev_callback(event_handle_t handle,
EA_ArgInteger, "ERROR", 0,
EA_ArgInteger, "CTOKEN", match->token,
EA_TAG_DONE);
#endif
}
mtp_free_packet(mp);
mp = NULL;
mtp_free_packet(&mp);
// XXX What to do with the data?
......@@ -723,8 +754,9 @@ int unknown_client_callback(elvin_io_handler_t handler,
void *rock,
elvin_error_t eerror)
{
mtp_packet_t *mp = NULL;
mtp_packet_t mp_data, *mp = &mp_data;
int rc, retval = 0;
mtp_handle_t mh;
/*
* NB: We remove the handler before adding the new one because elvin calls
......@@ -733,91 +765,52 @@ int unknown_client_callback(elvin_io_handler_t handler,
*/
elvin_sync_remove_io_handler(handler, eerror);
if (((rc = mtp_receive_packet(fd, &mp)) != MTP_PP_SUCCESS) ||
(mp->version != MTP_VERSION) ||
(mp->opcode != MTP_CONTROL_INIT)) {
error("invalid client %p\n", mp);
if ((mh = mtp_create_handle(fd)) == NULL) {
error("mtp_create_handle\n");
}
else if (((rc = mtp_receive_packet(mh, mp)) != MTP_PP_SUCCESS) ||
(mp->vers != MTP_VERSION) ||
(mp->data.opcode != MTP_CONTROL_INIT)) {
error("invalid client %d %p\n", rc, mp);
}
else {
switch (mp->role) {
case MTP_ROLE_RMC:
if (rmc_data.sock_fd != -1) {
if (rmc_data.handle != NULL) {
error("rmc client is already connected\n");
}
else if ((retval = mtp_send_packet(mh, &config_rmc)) != MTP_PP_SUCCESS) {
error("unable to send rmc_config packet");
}
else if (elvin_sync_add_io_handler(NULL,
fd,
ELVIN_READ_MASK,
rmc_callback,
&rmc_data,
eerror) == NULL) {
error("unable to add rmc_callback handler");
}