diff options
Diffstat (limited to 'dmascc')
-rw-r--r-- | dmascc/Makefile.am | 14 | ||||
-rw-r--r-- | dmascc/Makefile.in | 359 | ||||
-rw-r--r-- | dmascc/README.dmascc | 69 | ||||
-rw-r--r-- | dmascc/dmascc_cfg.1 | 101 | ||||
-rw-r--r-- | dmascc/dmascc_cfg.c | 191 |
5 files changed, 734 insertions, 0 deletions
diff --git a/dmascc/Makefile.am b/dmascc/Makefile.am new file mode 100644 index 0000000..1af785f --- /dev/null +++ b/dmascc/Makefile.am @@ -0,0 +1,14 @@ + +sbin_PROGRAMS = dmascc_cfg + +dmascc_cfg_SOURCE = dmascc_cfg.c + +man_MANS = dmascc_cfg.1 + +EXTRA_DIST = $(man_MANS) $(doc_DATA) + +docdir=$(prefix)/doc/ax25-tools +doc_DATA = README.dmascc + +installconf: + diff --git a/dmascc/Makefile.in b/dmascc/Makefile.in new file mode 100644 index 0000000..e27dab5 --- /dev/null +++ b/dmascc/Makefile.in @@ -0,0 +1,359 @@ +# Makefile.in generated automatically by automake 1.4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AWK = @AWK@ +AX25IO_LIB = @AX25IO_LIB@ +AX25_LIB = @AX25_LIB@ +CC = @CC@ +MAKEINFO = @MAKEINFO@ +NCURSES_LIB = @NCURSES_LIB@ +PACKAGE = @PACKAGE@ +UTIL_LIB = @UTIL_LIB@ +VERSION = @VERSION@ +Z_LIB = @Z_LIB@ + +sbin_PROGRAMS = dmascc_cfg + +dmascc_cfg_SOURCE = dmascc_cfg.c + +man_MANS = dmascc_cfg.1 + +EXTRA_DIST = $(man_MANS) $(doc_DATA) + +docdir = $(prefix)/doc/ax25-tools +doc_DATA = README.dmascc +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(sbin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +dmascc_cfg_SOURCES = dmascc_cfg.c +dmascc_cfg_OBJECTS = dmascc_cfg.o +dmascc_cfg_LDADD = $(LDADD) +dmascc_cfg_DEPENDENCIES = +dmascc_cfg_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +man1dir = $(mandir)/man1 +MANS = $(man_MANS) + +NROFF = nroff +DATA = $(doc_DATA) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +SOURCES = dmascc_cfg.c +OBJECTS = dmascc_cfg.o + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps dmascc/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-sbinPROGRAMS: + +clean-sbinPROGRAMS: + -test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS) + +distclean-sbinPROGRAMS: + +maintainer-clean-sbinPROGRAMS: + +install-sbinPROGRAMS: $(sbin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(sbindir) + @list='$(sbin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-sbinPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(sbin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +.c.o: + $(COMPILE) -c $< + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +dmascc_cfg: $(dmascc_cfg_OBJECTS) $(dmascc_cfg_DEPENDENCIES) + @rm -f dmascc_cfg + $(LINK) $(dmascc_cfg_LDFLAGS) $(dmascc_cfg_OBJECTS) $(dmascc_cfg_LDADD) $(LIBS) + +install-man1: + $(mkinstalldirs) $(DESTDIR)$(man1dir) + @list='$(man1_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ + done + +uninstall-man1: + @list='$(man1_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ + rm -f $(DESTDIR)$(man1dir)/$$inst; \ + done +install-man: $(MANS) + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-man1 +uninstall-man: + @$(NORMAL_UNINSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 + +install-docDATA: $(doc_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(docdir) + @list='$(doc_DATA)'; for p in $$list; do \ + if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(docdir)/$$p"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(docdir)/$$p; \ + else if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(docdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(docdir)/$$p; \ + fi; fi; \ + done + +uninstall-docDATA: + @$(NORMAL_UNINSTALL) + list='$(doc_DATA)'; for p in $$list; do \ + rm -f $(DESTDIR)$(docdir)/$$p; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = dmascc + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-sbinPROGRAMS +install-exec: install-exec-am + +install-data-am: install-man install-docDATA +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-sbinPROGRAMS uninstall-man uninstall-docDATA +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(mandir)/man1 \ + $(DESTDIR)$(docdir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-sbinPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-sbinPROGRAMS clean-compile clean-tags clean-generic \ + mostlyclean-am + +clean: clean-am + +distclean-am: distclean-sbinPROGRAMS distclean-compile distclean-tags \ + distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-sbinPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \ +clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \ +install-sbinPROGRAMS mostlyclean-compile distclean-compile \ +clean-compile maintainer-clean-compile install-man1 uninstall-man1 \ +install-man uninstall-man uninstall-docDATA install-docDATA tags \ +mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir info-am info dvi-am dvi check check-am installcheck-am \ +installcheck install-exec-am install-exec install-data-am install-data \ +install-am install uninstall-am uninstall all-redirect all-am all \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +installconf: + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/dmascc/README.dmascc b/dmascc/README.dmascc new file mode 100644 index 0000000..fcd7746 --- /dev/null +++ b/dmascc/README.dmascc @@ -0,0 +1,69 @@ +The dmascc_cfg utility +====================== + +Use this utility to configure the dmascc driver. + +Usage: +------ + +dmascc_cfg <interface> [ options ... ] + +Options: +-------- + +--show Show all configurable parameters for this port. + May be specified at any time by any user. + +All other options change parameters and thus may only be specified + - by root + - when the interface is down + +--speed <f> Set frequency of baud rate generator. A value of 0 disables + the baud rate generator and the digital PLL. Use the + --show option to check whether the frequency you selected + could be approximated with sufficient accuracy. + +--nrzi 0 | 1 0 selects NRZ mode, 1 selects NRZI mode. + +--clocks <i> Set clock mode. You may OR together three choices (other + values are not supported and may cause strange results): + + TX clock pin: 0x00 input + 0x05 output TX clock * + 0x06 output baud rate generator * + 0x07 output digital PLL * + + TX clock source: 0x00 RX clock pin + 0x08 TX clock pin # + 0x10 baud rate generator + 0x18 digital PLL + + + RX clock source: 0x00 RX clock pin + 0x20 TX clock pin + 0x40 baud rate generator + 0x60 digital PLL + + + * Not allowed on PI2 Port A if J3 is installed. + # TX clock pin must be configured as input + + Speed must be equal to 32 times the baud rate. + +--txdelay <f> Set transmit delay in ms (0 < f < 2500). + +--txtime <f> Set maximum time in s the transmitter may be active + (0 < f). + +--sqdelay <f> Set squelch delay in ms (0 < f < 2500). + +--slottime <f> Set slot time in ms (0 < f < 2500). + +--waittime <f> Set the minimum time in ms between transmitter off and + transmitter on (0 < f < 2500). + +--persist <i> Set persistence parameter (0 <= i <= 255). + +--dma <i> Set DMA channel (0, 1, or 3). 0 disables DMA. + +<f> ... floating-point argument, <i> ... integer argument. +Parameters are not checked for validity. The driver or the kernel may crash +if you specify invalid values. + diff --git a/dmascc/dmascc_cfg.1 b/dmascc/dmascc_cfg.1 new file mode 100644 index 0000000..f5884ea --- /dev/null +++ b/dmascc/dmascc_cfg.1 @@ -0,0 +1,101 @@ +.TH DMASCC_CFG 1 "30 June 1999" Linux "Linux Programmer's Manual" +.SH NAME +dmascc_cfg \- Configure dmascc devices +.SH SYNOPSIS +.B dmascc <interface> [<options>] +.SH DESCRIPTION +.LP +.B dmascc_cfg +is used to configure dmascc devices such as PI2 and PackeTwin cards. The +\fB\-\-show\fR option can be used by any user, all other options must be +used by root. +.SH OPTIONS +.TP 10 +.BI "\-\-speed "\fIfrequency\fR +Set frequency of baud rate generator to \fIfrequency\fR. A value of 0 +disables the baud rate generator and the digital PLL. Use the \fB\-\-show\fR +option to check whether the frequency you selected could be approximated +with sufficient accuracy. +.TP 10 +.BI "\-\-nrzi "\fR[\fI0\fR|\fI1\fR] +\fI0\fR selects NRZ mode, \fI1\fR selects NRZI mode. +.TP 10 +.BI "\-\-clocks "\fIinteger\fR +Set the clock mode. You may \fBOR\fR together three choices (other values +are not supported and may cause strange results). +.PP +TX clock pin: +.IP +.ta 1.5i +0x00 input +.br +0x05 output TX clock * +.br +0x06 output baud rate generator * +.br +0x07 output digital PLL * +.PP +TX clock source: +.IP +.ta 1.5i +0x00 RX clock pin +.br +0x08 TX clock pin # +.br +0x10 baud rate generator +.br +0x18 digital PLL + +.br +.PP +RX clock source: +.IP +.ta 1.5i +0x00 RX clock pin +.br +0x20 TX clock pin +.br +0x40 baud rate generator +.br +0x60 digital PLL + +.br +.PP +* Not allowed on PI2 Port A if J3 is installed. +.PP +# TX clock pin must be configured as input. +.PP ++ Speed must be equal to 32 times the baud rate. +.TP 10 +.BI "\-\-txdelay "\fImilliseconds\fR +Set transmit delay to \fImilliseconds\fR. Maximum is 2500 ms. +.TP 10 +.BI "\-\-txtime "\fIseconds\fR +Set maximum time the transmitter may be active to \fIseconds\fR. +.TP 10 +.BI "\-\-sqdelay "\fImilliseconds\fR +Set the squelch delay to \fImilliseconds\fR. Maximum delay is 2500 ms. +.TP 10 +.BI "\-\-slottime "\fImilliseconds\fR +Set the slot time to \fImilliseconds\fR. Maximum slottime is 2500 ms. +.TP 10 +.BI "\-\-waittime "\fImilliseconds\fR +Set the minimum time between the transmitter turning off to when it turns +on to \fImilliseconds\fR. Maximum wait time is 2500 ms. +.TP 10 +.BI "\-\-persist "\fIf\fR +Set the persistance parameter to \fIf\fR. Must be between 0 and 255 +(inclusive). +.TP 10 +.BI "\-\-dma "\fIchannel\fR +Set the DMA channel to \fIchannel\fR. Can be 1 or 3. Setting to 0 disables +DMA. +.LP +.SH BUGS +.B dmascc_cfg +does not check the parameters for validity. The driver or kernel may crash +if you specify invalid values. +.SH AUTHORS +.nf +Klaus Kudielka +.br +This manual page written by Craig Small <csmall@small.dropbear.id.au> +.fi diff --git a/dmascc/dmascc_cfg.c b/dmascc/dmascc_cfg.c new file mode 100644 index 0000000..abf7673 --- /dev/null +++ b/dmascc/dmascc_cfg.c @@ -0,0 +1,191 @@ +/* + * $Id: dmascc_cfg.c,v 0.7 1997/12/02 11:31:21 oe1kib Exp $ + * + * Configuration utility for dmascc driver + * Copyright (C) 1997 Klaus Kudielka + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <linux/if.h> +#include <linux/dmascc.h> +#include <asm/param.h> + +void usage(char *name) +{ + fprintf(stderr, + "usage: %s <interface> [ options ... ]\n\n" + "options: --show show configuration\n" + " --speed <f> set baud rate\n" + " --nrzi 0 | 1 set NRZ or NRZI encoding\n" + " --clocks <i> set clock mode\n" + " --txdelay <f> set transmit delay in ms\n" + " --txtime <f> set maximum transmit time in s\n" + " --sqdelay <f> set squelch delay in ms\n" + " --slottime <f> set slot time in ms\n" + " --waittime <f> set wait time after transmit in ms\n" + " --persist <i> set persistence parameter\n" + " --dma <i> set DMA channel\n", name); +} + +int main(int argc, char *argv[]) +{ + int sk, show = 0, set = 0, error = 0; + struct ifreq ifr; + struct scc_param param; + char **option, *end; + + if (argc < 2) { + usage(argv[0]); + return 1; + } + + if ((sk = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("socket"); + return 2; + } + + strncpy(ifr.ifr_name, argv[1], IFNAMSIZ); + ifr.ifr_data = (caddr_t) ¶m; + if (ioctl(sk, SIOCGSCCPARAM, &ifr) < 0) { + perror("ioctl"); + close(sk); + return 3; + } + + option = argv + 2; + while (!error && *option != NULL) { + if (!strcmp(*option, "--show")) { + show = 1; + option++; + } else if (!strcmp(*option, "--speed")) { + option++; + if (*option != NULL) { + double speed; + set = 1; + speed = strtod(*option++, &end); + if (*end) error = 1; else { + if (speed <= 0.0) param.brg_tc = -1; + else param.brg_tc = param.pclk_hz / (speed * 2) - 2; + if (param.brg_tc > 0xffff) param.brg_tc = -1; + } + } else error = 1; + } else if (!strcmp(*option, "--nrzi")) { + option++; + if (*option != NULL) { + set = 1; + param.nrzi = strtol(*option++, &end, 0); + if (*end) error = 1; + } else error = 1; + } else if (!strcmp(*option, "--clocks")) { + option++; + if (*option != NULL) { + set = 1; + param.clocks = strtol(*option++, &end, 0); + if (*end) error = 1; + } else error = 1; + } else if (!strcmp(*option, "--txdelay")) { + option++; + if (*option != NULL) { + set = 1; + param.txdelay = TMR_0_HZ * strtod(*option++, &end) / 1000.0; + if (*end) error = 1; + } else error = 1; + } else if (!strcmp(*option, "--txtime")) { + option++; + if (*option != NULL) { + set = 1; + param.txtime = HZ * strtod(*option++, &end); + if (*end) error = 1; + } else error = 1; + } else if (!strcmp(*option, "--sqdelay")) { + option++; + if (*option != NULL) { + set = 1; + param.sqdelay = TMR_0_HZ * strtod(*option++, &end) / 1000.0; + if (*end) error = 1; + } else error = 1; + } else if (!strcmp(*option, "--slottime")) { + option++; + if (*option != NULL) { + set = 1; + param.slottime = TMR_0_HZ * strtod(*option++, &end) / 1000.0; + if (*end) error = 1; + } else error = 1; + } else if (!strcmp(*option, "--waittime")) { + option++; + if (*option != NULL) { + set = 1; + param.waittime = TMR_0_HZ * strtod(*option++, &end) / 1000.0; + if (*end) error = 1; + } else error = 1; + } else if (!strcmp(*option, "--persist")) { + option++; + if (*option != NULL) { + set = 1; + param.persist = strtol(*option++, &end, 0); + if (*end) error = 1; + } else error = 1; + } else if (!strcmp(*option, "--dma")) { + option++; + if (*option != NULL) { + set = 1; + param.dma = strtol(*option++, &end, 0); + if (*end) error = 1; + } else error = 1; + } else error = 1; + } + + if (error) { + usage(argv[0]); + close(sk); + return 1; + } + + if (set) { + if (ioctl(sk, SIOCSSCCPARAM, &ifr) < 0) { + perror("ioctl"); + close(sk); + return 4; + } + } + + if (show) { + double speed; + if (param.brg_tc < 0) speed = 0.0; + else speed = ((double) param.pclk_hz) / ( 2 * (param.brg_tc + 2)); + printf("speed = %.2f\nnrzi = %d\nclocks = 0x%02X\n" + "txdelay = %.2f ms\ntxtime = %.2f s\nsqdelay = %.2f ms\n" + "slottime = %.2f ms\nwaittime = %.2f ms\npersist = %d\n" + "dma = %d\n", + speed, param.nrzi, param.clocks, + param.txdelay * 1000.0 / TMR_0_HZ, + (double) param.txtime / HZ, + param.sqdelay * 1000.0 / TMR_0_HZ, + param.slottime * 1000.0 / TMR_0_HZ, + param.waittime * 1000.0 / TMR_0_HZ, + param.persist, param.dma); + } + + close(sk); + return 0; +} |