From 43f179d6d8482f15958248cb45c1fc437bab6ee4 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 18 May 2011 13:34:26 -0300 Subject: [PATCH] tools/lib/: new helper function for daemonification - include/daemon.h (daemonize), lib/daemon.c: shed all ties with the process' previous surroundings - lib/Makefile (OBJS): added daemon.o --- prod/doc/index.html | 108 ++++++++++++++++++++++++++++++++++++++++- tools/include/daemon.h | 22 +++++++++ tools/lib/Makefile | 2 +- tools/lib/daemon.c | 41 ++++++++++++++++ 4 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 tools/include/daemon.h create mode 100644 tools/lib/daemon.c diff --git a/prod/doc/index.html b/prod/doc/index.html index a3a636c..527fa18 100644 --- a/prod/doc/index.html +++ b/prod/doc/index.html @@ -29,6 +29,9 @@ Devices accepted for further use can then be packaged for shipping. Defective devices can be discarded or retained for a deeper analysis. + + +

Terminology

@@ -73,16 +76,89 @@ Defective devices can be discarded or retained for a deeper analysis.
-

Setup

+ + + +

Software setup

+ +Before performing any production tests, various pieces of software +need to be installed on Ben and PC, and configuration settings +@@@ + + + +

PC software installation

-

Ben software installation

+ +@@@ + +

Install ben-wpan tools

+ +@@@ + +

Register Ben host name

+ +To simplify accessing the Ben via TCP/IP, its IP address should be +registered in the hosts file on the PC. If the Ben is running OpenWrt, +use the following command: +
+echo 192.168.254.101 ben >>/etc/hosts
+
+

+If the Ben is running Jlime, the address would be as follows: +

+echo 192.168.1.202 ben >>/etc/hosts
+
+

+If using the same PC with Bens running OpenWrt and Jlime, one may choose +different host names depending on the distribution, and adapt the commands +used in the production and testing process accordingly. For example, +

+echo 192.168.254.101 ben >>/etc/hosts
+echo 192.168.1.202 jlime >>/etc/hosts
+
+ + + + +

Ben software setup

+ +This needs to be done each time the Ben is booted. + +

Enable network access

+

Silence other 8:10 card users

+ + + + + +

Ben software installation

+ +

Password-less remote access

+ +To enable password-less remote access from the PC, setup to betwork +access to the Ben and run the following command: +
+ssh ben 'cat >>/etc/dropbear/authorized_keys' <~/.ssh/id_rsa.pub
+
+ + + + +

Test profiles

+ + +

Flashing (atusb only)

+ + +

Flashing the boot loader

@@ -90,6 +166,9 @@ Defective devices can be discarded or retained for a deeper analysis.

+ + +

Flashing the application

@@ -97,28 +176,53 @@ Defective devices can be discarded or retained for a deeper analysis.

+ + +

Functional test

+ + +

Test setup for atben

+ + +

Test setup for atusb

+ + +

Test procedure

+ + + +

Fault analysis

+ + +

Component placement and orientation

+ + +

Supply voltages

+ + +

Clock frequency

The flawless performance of the crystal oscillator is crucial for diff --git a/tools/include/daemon.h b/tools/include/daemon.h new file mode 100644 index 0000000..bb33fa6 --- /dev/null +++ b/tools/include/daemon.h @@ -0,0 +1,22 @@ +/* + * include/daemon.h - Helper functions for proper daemonification + * + * Written 2011 by Werner Almesberger + * Copyright 2011 Werner Almesberger + * + * 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. + */ + + +#ifndef DAEMON_H +#define DAEMON_H + +#include + + +pid_t daemonize(void); + +#endif /* !DAEMON_H */ diff --git a/tools/lib/Makefile b/tools/lib/Makefile index 1c03d90..ec9676c 100644 --- a/tools/lib/Makefile +++ b/tools/lib/Makefile @@ -19,7 +19,7 @@ OBJS_host = atusb.o usbopen.o OBJS_ben_jlime = atben.o OBJS_ben_openwrt = atben.o -OBJS = atrf.o atnet.o misctxrx.o cwtest.o netio.o $(OBJS_$(TARGET)) +OBJS = atrf.o atnet.o misctxrx.o cwtest.o netio.o daemon.o $(OBJS_$(TARGET)) .PHONY: all clean spotless diff --git a/tools/lib/daemon.c b/tools/lib/daemon.c new file mode 100644 index 0000000..38b3109 --- /dev/null +++ b/tools/lib/daemon.c @@ -0,0 +1,41 @@ +/* + * lib/daemon.c - Helper functions for proper daemonification + * + * Written 2011 by Werner Almesberger + * Copyright 2011 Werner Almesberger + * + * 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. + */ + + +#include +#include +#include + +#include "daemon.h" + + +pid_t daemonize(void) +{ + pid_t pid; + int i; + + pid = fork(); + if (pid < 0) { + perror("fork"); + exit(1); + } + if (pid) + return pid; + if (setsid() < 0) { + perror("setsid"); + exit(1); + } + for (i = 0; i <= 2; i++) + (void) close(i); + (void) chdir("/"); + return 0; +}