mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 12:59:21 +02:00
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
This commit is contained in:
parent
e86997e94d
commit
43f179d6d8
@ -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.
|
||||
|
||||
|
||||
<!-- ====================================================================== -->
|
||||
|
||||
|
||||
<H2>Terminology</H2>
|
||||
|
||||
<DL>
|
||||
@ -73,16 +76,89 @@ Defective devices can be discarded or retained for a deeper analysis.
|
||||
</DL>
|
||||
|
||||
|
||||
<H2>Setup</H2>
|
||||
<!-- ====================================================================== -->
|
||||
|
||||
|
||||
<H2>Software setup</H2>
|
||||
|
||||
Before performing any production tests, various pieces of software
|
||||
need to be installed on Ben and PC, and configuration settings
|
||||
@@@
|
||||
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>PC software installation</H3>
|
||||
<H3>Ben software installation</H3>
|
||||
|
||||
@@@
|
||||
|
||||
<H4>Install ben-wpan tools</H4>
|
||||
|
||||
@@@
|
||||
|
||||
<H4>Register Ben host name</H4>
|
||||
|
||||
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:
|
||||
<PRE>
|
||||
echo 192.168.254.101 ben >>/etc/hosts
|
||||
</PRE>
|
||||
<P>
|
||||
If the Ben is running Jlime, the address would be as follows:
|
||||
<PRE>
|
||||
echo 192.168.1.202 ben >>/etc/hosts
|
||||
</PRE>
|
||||
<P>
|
||||
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,
|
||||
<PRE>
|
||||
echo 192.168.254.101 ben >>/etc/hosts
|
||||
echo 192.168.1.202 jlime >>/etc/hosts
|
||||
</PRE>
|
||||
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Ben software setup</H3>
|
||||
|
||||
This needs to be done each time the Ben is booted.
|
||||
|
||||
<H4>Enable network access</H4>
|
||||
<H4>Silence other 8:10 card users</H4>
|
||||
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Ben software installation</H3>
|
||||
|
||||
<H4>Password-less remote access</H4>
|
||||
|
||||
To enable password-less remote access from the PC, setup to betwork
|
||||
access to the Ben and run the following command:
|
||||
<PRE>
|
||||
ssh ben 'cat >>/etc/dropbear/authorized_keys' <~/.ssh/id_rsa.pub
|
||||
</PRE>
|
||||
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Test profiles</H3>
|
||||
|
||||
|
||||
<!-- ====================================================================== -->
|
||||
|
||||
|
||||
<H2>Flashing (atusb only)<H2>
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Flashing the boot loader</H3>
|
||||
|
||||
<P>
|
||||
@ -90,6 +166,9 @@ Defective devices can be discarded or retained for a deeper analysis.
|
||||
<P>
|
||||
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Flashing the application</H3>
|
||||
|
||||
<P>
|
||||
@ -97,28 +176,53 @@ Defective devices can be discarded or retained for a deeper analysis.
|
||||
<P>
|
||||
|
||||
|
||||
<!-- ====================================================================== -->
|
||||
|
||||
|
||||
<H2>Functional test</H2>
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Test setup for atben</H3>
|
||||
|
||||
<P>
|
||||
<IMG src="setup-A.png">
|
||||
<P>
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Test setup for atusb</H3>
|
||||
|
||||
<P>
|
||||
<IMG src="setup-B.png">
|
||||
<P>
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Test procedure</H3>
|
||||
|
||||
|
||||
<!-- ====================================================================== -->
|
||||
|
||||
|
||||
<H2>Fault analysis</H2>
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Component placement and orientation</H3>
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Supply voltages</H3>
|
||||
|
||||
<!-- ---------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<H3>Clock frequency</H3>
|
||||
|
||||
The flawless performance of the crystal oscillator is crucial for
|
||||
|
22
tools/include/daemon.h
Normal file
22
tools/include/daemon.h
Normal file
@ -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 <unistd.h>
|
||||
|
||||
|
||||
pid_t daemonize(void);
|
||||
|
||||
#endif /* !DAEMON_H */
|
@ -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
|
||||
|
||||
|
41
tools/lib/daemon.c
Normal file
41
tools/lib/daemon.c
Normal file
@ -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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user