Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934864AbYBHSBq (ORCPT ); Fri, 8 Feb 2008 13:01:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932591AbYBHR5q (ORCPT ); Fri, 8 Feb 2008 12:57:46 -0500 Received: from 81-174-11-161.static.ngi.it ([81.174.11.161]:38132 "EHLO mail.enneenne.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933346AbYBHR5i (ORCPT ); Fri, 8 Feb 2008 12:57:38 -0500 From: Rodolfo Giometti To: linux-kernel@vger.kernel.org Cc: Andrew Morton , David Woodhouse , Dave Jones , Rodolfo Giometti Date: Fri, 8 Feb 2008 19:00:43 +0100 Message-Id: <12024936442887-git-send-email-giometti@linux.it> X-Mailer: git-send-email 1.5.2.5 In-Reply-To: <12024936441151-git-send-email-giometti@linux.it> References: <1202493644764-git-send-email-giometti@linux.it> <120249364418-git-send-email-giometti@linux.it> <12024936442252-git-send-email-giometti@linux.it> <12024936441531-git-send-email-giometti@linux.it> <12024936442967-git-send-email-giometti@linux.it> <1202493644247-git-send-email-giometti@linux.it> <12024936441151-git-send-email-giometti@linux.it> X-SA-Exim-Connect-IP: 192.168.32.1 X-SA-Exim-Mail-From: giometti@enneenne.com Subject: [PATCH 7/8] PPS: example program to enable PPS support on serial ports. X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000) X-SA-Exim-Scanned: Yes (on mail.enneenne.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2221 Lines: 93 Signed-off-by: Rodolfo Giometti --- Documentation/pps/Makefile | 2 +- Documentation/pps/ppsctl.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletions(-) create mode 100644 Documentation/pps/ppsctl.c diff --git a/Documentation/pps/Makefile b/Documentation/pps/Makefile index af4f9b4..8ef4f47 100644 --- a/Documentation/pps/Makefile +++ b/Documentation/pps/Makefile @@ -1,4 +1,4 @@ -TARGETS = ppstest +TARGETS = ppstest ppsctl CFLAGS += -Wall -O2 -D_GNU_SOURCE CFLAGS += -I . diff --git a/Documentation/pps/ppsctl.c b/Documentation/pps/ppsctl.c new file mode 100644 index 0000000..83fd08a --- /dev/null +++ b/Documentation/pps/ppsctl.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void usage(char *name) +{ + fprintf(stderr, "usage: %s [enable|disable]\n", name); + + exit(EXIT_FAILURE); +} + +int main(int argc, char *argv[]) +{ + int fd; + int ret; + struct serial_struct ss; + + if (argc < 2) + usage(argv[0]); + + fd = open(argv[1], O_RDWR); + if (fd < 0) { + perror("open"); + exit(EXIT_FAILURE); + } + + ret = ioctl(fd, TIOCGSERIAL, &ss); + if (ret < 0) { + perror("ioctl(TIOCGSERIAL)"); + exit(EXIT_FAILURE); + } + + if (argc < 3) { /* just read PPS status */ + printf("PPS is %sabled\n", + ss.flags & ASYNC_HARDPPS_CD ? "en" : "dis"); + exit(EXIT_SUCCESS); + } + + if (argv[2][0] == 'e' || argv[2][0] == '1') + ss.flags |= ASYNC_HARDPPS_CD; + else if (argv[2][0] == 'd' || argv[2][0] == '0') + ss.flags &= ~ASYNC_HARDPPS_CD; + else { + fprintf(stderr, "invalid state argument \"%s\"\n", argv[2]); + exit(EXIT_FAILURE); + } + + ret = ioctl(fd, TIOCSSERIAL, &ss); + if (ret < 0) { + perror("ioctl(TIOCSSERIAL)"); + exit(EXIT_FAILURE); + } + + return 0; +} -- 1.5.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/