Bekijk de volledige versie : Device::SerialPort in Perl (optware)
halteren
19-06-2007, 09:28
Hi,
I've managed to put OpenWrt (Kamikaze 7.06) on my WL 500GX device, with a small modification to the ftdi_sio kernel module. As a result I now have a serial port device on /dev/usb/tts/0 that controls an FHZ1300PC box (for controlling lights and heating).
I would like to use a Perl script (from http://www.koeniglich.de/fhem/fhem.html) to drive the FHZ1300 box. So, I installed Perl from optware, after following instructions from http://www.nslu2-linux.org/wiki/FAQ/Optware-uClibcBuild to upgrade ipkg and uclibc.
Now that I got this far, I found out that Device::SerialPort is not available from the optware feed.
Is there someone who can make Device::SerialPort available? - Or, alternatively, how can I build that package myself?
Thanks,
Aart.
You can prepare package yourself. Send me a .mk when done and I will include it.
halteren
20-06-2007, 11:12
You can prepare package yourself. Send me a .mk when done and I will include it.
Using the perl-device-serialport.mk file below I'm getting a long way, but I'm not there yet. Apparenty the Device-SerialPort configure script does not generate a Makefile. Can you have a look?
################################################## #########
#
# perl-device-serialport
#
################################################## #########
#
# PERL-DEVICE-SERIALPORT_VERSION, PERL-DEVICE-SERIALPORT_SITE and PERL-DEVICE-SERIALPORT_SOURCE define
# the upstream location of the source code for the package.
# PERL-DEVICE-SERIALPORT_DIR is the directory which is created when the source
# archive is unpacked.
# PERL-DEVICE-SERIALPORT_UNZIP is the command used to unzip the source.
# It is usually "zcat" (for .gz) or "bzcat" (for .bz2)
#
# You should change all these variables to suit your package.
# Please make sure that you add a description, and that you
# list all your packages' dependencies, seperated by commas.
#
# If you list yourself as MAINTAINER, please give a valid email
# address, and indicate your irc nick if it cannot be easily deduced
# from your name or email address. If you leave MAINTAINER set to
# "NSLU2 Linux" other developers will feel free to edit.
#
PERL-DEVICE-SERIALPORT_SITE=http://search.cpan.org/CPAN/authors/id/C/CO/COOK
PERL-DEVICE-SERIALPORT_VERSION=1.002001
PERL-DEVICE-SERIALPORT_SOURCE=Device-SerialPort-$(PERL-DEVICE-SERIALPORT_VERSION).tar.gz
PERL-DEVICE-SERIALPORT_DIR=Device-SerialPort-$(PERL-DEVICE-SERIALPORT_VERSION)
PERL-DEVICE-SERIALPORT_UNZIP=zcat
PERL-DEVICE-SERIALPORT_MAINTAINER=NSLU2 Linux <nslu2-linux@yahoogroups.com>
PERL-DEVICE-SERIALPORT_DESCRIPTION=Describe perl-device-serialport here.
PERL-DEVICE-SERIALPORT_SECTION=
PERL-DEVICE-SERIALPORT_PRIORITY=optional
PERL-DEVICE-SERIALPORT_DEPENDS=
PERL-DEVICE-SERIALPORT_SUGGESTS=
PERL-DEVICE-SERIALPORT_CONFLICTS=
#
# PERL-DEVICE-SERIALPORT_IPK_VERSION should be incremented when the ipk changes.
#
PERL-DEVICE-SERIALPORT_IPK_VERSION=1
#
# PERL-DEVICE-SERIALPORT_CONFFILES should be a list of user-editable files
PERL-DEVICE-SERIALPORT_CONFFILES=/opt/etc/perl-device-serialport.conf /opt/etc/init.d/SXXperl-device-serialport
#
# PERL-DEVICE-SERIALPORT_PATCHES should list any patches, in the the order in
# which they should be applied to the source code.
#
#PERL-DEVICE-SERIALPORT_PATCHES=$(PERL-DEVICE-SERIALPORT_SOURCE_DIR)/configure.patch
#
# If the compilation of the package requires additional
# compilation or linking flags, then list them here.
#
PERL-DEVICE-SERIALPORT_CPPFLAGS=
PERL-DEVICE-SERIALPORT_LDFLAGS=
#
# PERL-DEVICE-SERIALPORT_BUILD_DIR is the directory in which the build is done.
# PERL-DEVICE-SERIALPORT_SOURCE_DIR is the directory which holds all the
# patches and ipkg control files.
# PERL-DEVICE-SERIALPORT_IPK_DIR is the directory in which the ipk is built.
# PERL-DEVICE-SERIALPORT_IPK is the name of the resulting ipk files.
#
# You should not change any of these variables.
#
PERL-DEVICE-SERIALPORT_BUILD_DIR=$(BUILD_DIR)/perl-device-serialport
PERL-DEVICE-SERIALPORT_SOURCE_DIR=$(SOURCE_DIR)/perl-device-serialport
PERL-DEVICE-SERIALPORT_IPK_DIR=$(BUILD_DIR)/perl-device-serialport-$(PERL-DEVICE-SERIALPORT_VERSION)-ipk
PERL-DEVICE-SERIALPORT_IPK=$(BUILD_DIR)/perl-device-serialport_$(PERL-DEVICE-SERIALPORT_VERSION)-$(PERL-DEVICE-SERIALPORT_IPK_VERSION)_$(TARGET_ARCH).ipk
.PHONY: perl-device-serialport-source perl-device-serialport-unpack perl-device-serialport perl-device-serialport-stage perl-device-serialport-ipk perl-device-serialport-clean perl-device-serialport-dirclean perl-device-serialport-check
#
# This is the dependency on the source code. If the source is missing,
# then it will be fetched from the site using wget.
#
$(DL_DIR)/$(PERL-DEVICE-SERIALPORT_SOURCE):
$(WGET) -P $(DL_DIR) $(PERL-DEVICE-SERIALPORT_SITE)/$(PERL-DEVICE-SERIALPORT_SOURCE) || \
$(WGET) -P $(DL_DIR) $(SOURCES_NLO_SITE)/$(PERL-DEVICE-SERIALPORT_SOURCE)
#
# The source code depends on it existing within the download directory.
# This target will be called by the top level Makefile to download the
# source code's archive (.tar.gz, .bz2, etc.)
#
perl-device-serialport-source: $(DL_DIR)/$(PERL-DEVICE-SERIALPORT_SOURCE) $(PERL-DEVICE-SERIALPORT_PATCHES)
#
# This target unpacks the source code in the build directory.
# If the source archive is not .tar.gz or .tar.bz2, then you will need
# to change the commands here. Patches to the source code are also
# applied in this target as required.
#
# This target also configures the build within the build directory.
# Flags such as LDFLAGS and CPPFLAGS should be passed into configure
# and NOT $(MAKE) below. Passing it to configure causes configure to
# correctly BUILD the Makefile with the right paths, where passing it
# to Make causes it to override the default search paths of the compiler.
#
# If the compilation of the package requires other packages to be staged
# first, then do that first (e.g. "$(MAKE) <bar>-stage <baz>-stage").
#
# If the package uses GNU libtool, you should invoke $(PATCH_LIBTOOL) as
# shown below to make various patches to it.
#
$(PERL-DEVICE-SERIALPORT_BUILD_DIR)/.configured: $(DL_DIR)/$(PERL-DEVICE-SERIALPORT_SOURCE) $(PERL-DEVICE-SERIALPORT_PATCHES) make/perl-device-serialport.mk
# $(MAKE) <bar>-stage <baz>-stage
rm -rf $(BUILD_DIR)/$(PERL-DEVICE-SERIALPORT_DIR) $(PERL-DEVICE-SERIALPORT_BUILD_DIR)
$(PERL-DEVICE-SERIALPORT_UNZIP) $(DL_DIR)/$(PERL-DEVICE-SERIALPORT_SOURCE) | tar -C $(BUILD_DIR) -xvf -
if test -n "$(PERL-DEVICE-SERIALPORT_PATCHES)" ; \
then cat $(PERL-DEVICE-SERIALPORT_PATCHES) | \
patch -d $(BUILD_DIR)/$(PERL-DEVICE-SERIALPORT_DIR) -p0 ; \
fi
if test "$(BUILD_DIR)/$(PERL-DEVICE-SERIALPORT_DIR)" != "$(PERL-DEVICE-SERIALPORT_BUILD_DIR)" ; \
then mv $(BUILD_DIR)/$(PERL-DEVICE-SERIALPORT_DIR) $(PERL-DEVICE-SERIALPORT_BUILD_DIR) ; \
fi
(cd $(PERL-DEVICE-SERIALPORT_BUILD_DIR); \
$(TARGET_CONFIGURE_OPTS) \
CPPFLAGS="$(STAGING_CPPFLAGS) $(PERL-DEVICE-SERIALPORT_CPPFLAGS)" \
LDFLAGS="$(STAGING_LDFLAGS) $(PERL-DEVICE-SERIALPORT_LDFLAGS)" \
./configure \
--build=$(GNU_HOST_NAME) \
--host=$(GNU_TARGET_NAME) \
--target=$(GNU_TARGET_NAME) \
--prefix=/opt \
--disable-nls \
--disable-static \
)
# $(PATCH_LIBTOOL) $(PERL-DEVICE-SERIALPORT_BUILD_DIR)/libtool
touch $@
perl-device-serialport-unpack: $(PERL-DEVICE-SERIALPORT_BUILD_DIR)/.configured
#
# This builds the actual binary.
#
$(PERL-DEVICE-SERIALPORT_BUILD_DIR)/.built: $(PERL-DEVICE-SERIALPORT_BUILD_DIR)/.configured
rm -f $@
$(MAKE) -C $(PERL-DEVICE-SERIALPORT_BUILD_DIR)
touch $@
#
# This is the build convenience target.
#
perl-device-serialport: $(PERL-DEVICE-SERIALPORT_BUILD_DIR)/.built
#
# If you are building a library, then you need to stage it too.
#
$(PERL-DEVICE-SERIALPORT_BUILD_DIR)/.staged: $(PERL-DEVICE-SERIALPORT_BUILD_DIR)/.built
rm -f $@
$(MAKE) -C $(PERL-DEVICE-SERIALPORT_BUILD_DIR) DESTDIR=$(STAGING_DIR) install
touch $@
perl-device-serialport-stage: $(PERL-DEVICE-SERIALPORT_BUILD_DIR)/.staged
This makefile looks like it misses ipk build part. You can start with creating
stock one with simple
mv make/perl-device-serialport.mk /tmp
make make/perl-device-serialport.mk
And then change variables there.
halteren
21-06-2007, 12:57
I 've recreated the .mk file using your recipe (see attachment), but that really is not the problem. After the configure phase no Makefile is created.
checking normal CTS/RTS flow control... yes
configure: creating ./config.status
config.status: creating config.h
touch /home/user/openwrt/optware/builds/perl-device-serialport/.configured
rm -f /home/user/openwrt/optware/builds/perl-device-serialport/.built
make -C /home/user/openwrt/optware/builds/perl-device-serialport
make[1]: Entering directory `/home/user/openwrt/optware/builds/perl-device-serialport'
make[1]: *** No targets specified and no makefile found. Stop.
make[1]: Leaving directory `/home/user/openwrt/optware/builds/perl-device-serialport'
make: *** [/home/user/openwrt/optware/builds/perl-device-serialport/.built] Error 2
I can create a Makefile manually for Device-SerialPort, using 'perl Makefile.PL', but the resulting Makefile is not suitable for cross-compiling. I dont know how to convince Makefile.PL to output a suitable Makefile.
See changeset #6280 (http://trac.nslu2-linux.org/optware/changeset/6280) for serial port makefile. I have not tested it, but I expect that it works.
It was somehow tricky as it uses configure inside Makefile.PL. I am still not shure it configure created config.h well. If not then we need config.cache run
with configure on router itself.
Visit serial port homepage (http://sendpage.org/device-serialport/) for instructions and report if it does not work.
Note that package may not appear for day or so as we are stopped autobuild machine to softland new OpenWRT Kamikaze Optware targets.
halteren
22-06-2007, 20:20
Thanks for your efforts. It seems to work OK.