|
From: Mattias A. <mat...@us...> - 2001-03-21 20:50:18
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btinit.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
added SIGTERMI in sighandler to cope with atexit() functionality
added option -i used to set default speed on physdev
minor changes
The diff of the modified file(s):
--- btinit.c 2001/03/13 22:21:17 1.2
+++ btinit.c 2001/03/21 20:50:17 1.3
@@ -107,6 +107,7 @@
=20
static int btd_pid;
static char local_name[LOCAL_NAME_LENGTH+1]; /* 'friendly' name in HW modu=
le */
+static int init_hw_speed =3D 0; /* not set */
static int do_hwinit =3D 1; /* do vendor specific initialization */
static int do_reset =3D 0; /* reset hw using I/O pins */
static int phys_fd =3D -1; /* physical device e.g ttyS0 */
@@ -155,6 +156,11 @@
{
switch(opt)
{
+ case 'i':
+ /* uart device */
+ init_hw_speed =3D atoi(optarg);
+ syslog(LOG_INFO, "init_hw_speed %d baud\n", init_hw_speed);
+ break;
=20
case 'n':
printf("setting local name to %s\n", optarg);
@@ -205,12 +211,16 @@
}
=20
/* Set default speed */
+
+ if (init_hw_speed !=3D 0)
+ fd_setup(phys_fd, init_hw_speed, 1);
+ else
init_phys(phys_fd);
=20
/* Set the current tty to the bluetooth discpline */
set_bt_line_disc(phys_fd, bt_disc, physdev);
=20=20=20
- bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY);
+ bt_cfd =3D bt_openctrl();
=20
init_stack(bt_cfd, atoi(speedstr));
=20
@@ -237,6 +247,7 @@
sigemptyset(&act.sa_mask);
act.sa_flags =3D 0;
sigaction(SIGUSR1, &act, 0);
+ sigaction(SIGTERM, &act, 0);
/* other sigs ? */
}
=20
@@ -253,6 +264,10 @@
btd_cleanup();
=20=20
longjmp(jmpbuffer, 1);
+ }
+ if (sig =3D=3D SIGUSR1)
+ {
+ exit(0);
}
return;
}
|
|
From: Mattias A. <mat...@us...> - 2001-03-22 11:12:12
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btinit.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
fixed typo, SIGTERM calls exit which activates atexit function
The diff of the modified file(s):
--- btinit.c 2001/03/21 20:50:17 1.3
+++ btinit.c 2001/03/22 11:12:10 1.4
@@ -265,7 +265,7 @@
=20=20
longjmp(jmpbuffer, 1);
}
- if (sig =3D=3D SIGUSR1)
+ if (sig =3D=3D SIGTERM)
{
exit(0);
}
|
|
From: Mattias A. <mat...@us...> - 2001-03-30 12:45:13
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btinit.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
minor changes, now btinit works with usermode stack
The diff of the modified file(s):
--- btinit.c 2001/03/22 11:12:10 1.4
+++ btinit.c 2001/03/30 12:45:11 1.5
@@ -96,7 +96,6 @@
#include "bt_vendor.h"
#include "bt_misc.h"
#include "bt_if.h"
-#include "bt_ipa.h"
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
/* General BTD stuff */
@@ -110,9 +109,9 @@
static int init_hw_speed =3D 0; /* not set */
static int do_hwinit =3D 1; /* do vendor specific initialization */
static int do_reset =3D 0; /* reset hw using I/O pins */
-static int phys_fd =3D -1; /* physical device e.g ttyS0 */
static jmp_buf jmpbuffer; /* used to jump back in program after doing rese=
t */
static int sdpsrv_pid =3D 0;
+int phys_fd =3D -1; /* physical device e.g ttyS0 */
=20
/* long option list */
static struct option long_options[] =3D
@@ -141,7 +140,6 @@
=20
syslog(LOG_INFO, "Bluetooth daemon starting\n");
=20
-
if (atexit(btd_cleanup) < 0)
{
printf("btd failed to register cleanup function.\n");
@@ -290,6 +288,7 @@
static void
btd_cleanup(void)
{
+ printf("btd_cleanup : Shutting down stack and terminating childs\n");
syslog(LOG_INFO, "btd_cleanup\n");
btd_killchilds();
=20
|
|
From: Peter K. <pk...@us...> - 2001-05-31 12:38:54
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btinit.c 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Use sigsetjmp()/siglongjmp() instead of setjmp()/longjmp() as
we need to call siglongjmp() from a signal handler.
The diff of the modified file(s):
--- btinit.c 2001/05/17 10:36:36 1.8
+++ btinit.c 2001/05/31 12:38:54 1.9
@@ -109,7 +109,7 @@
static int init_hw_speed =3D 0; /* not set */
static int do_hwinit =3D 1; /* do vendor specific initialization */
static int do_reset =3D 0; /* reset hw using I/O pins */
-static jmp_buf jmpbuffer; /* used to jump back in program after doing rese=
t */
+static sigjmp_buf jmpbuffer; /* used to jump back in program after doing r=
eset */
static int sdpsrv_pid =3D 0;
int phys_fd =3D -1; /* physical device e.g ttyS0 */
=20
@@ -188,7 +188,7 @@
}
=20
/* Set restart point */
- if (setjmp(jmpbuffer) !=3D 0)
+ if (sigsetjmp(jmpbuffer, 1) !=3D 0)
{
syslog(LOG_INFO, "restart...\n\n\n\n");
}
@@ -258,7 +258,7 @@
=20=20=20=20=20
btd_cleanup();
=20=20
- longjmp(jmpbuffer, 1);
+ siglongjmp(jmpbuffer, 1);
}
if (sig =3D=3D SIGTERM)
{
|
|
From: Peter K. <pk...@us...> - 2001-06-08 09:56:38
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btinit.c 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Synchronised with btd.c
The diff of the modified file(s):
--- btinit.c 2001/05/31 12:38:54 1.9
+++ btinit.c 2001/06/08 09:56:37 1.10
@@ -53,7 +53,7 @@
Sets which uart device that will be used by the stack
default: ttyS0
=20=20=20
- -n, --local-name
+ -n, --local-name <prefix>
prefix used for the local bluetooth device name
default: nothing
=20=20=20
@@ -61,6 +61,10 @@
reset bluetooth hardware before use
default: no reset
=20=20=20
+ -i, --initial-speed <speed>
+ sets initial uart speed
+ default: 115200 baud
+
-s, --speed <speed>
sets uart speed
9600, 19200, 38400, 57600, 115200, 230400, 460800
@@ -69,27 +73,21 @@
e.g
./bti --reset --speed 460800 --physdev /dev/ttyS0 --local-name OpenBT
=20
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - =
- */
=20
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <fcntl.h>
-#include <time.h>
#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <termios.h>
#include <stdlib.h>
#include <string.h>
-#include <syslog.h>
+#include <unistd.h>
#include <errno.h>
-#include <stdarg.h>
+#include <fcntl.h>
#include <signal.h>
+#include <syslog.h>
#include <getopt.h>
#include <setjmp.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
=20
#include "btd.h"
#include "bt_conf.h"
@@ -97,6 +95,8 @@
#include "bt_misc.h"
#include "bt_if.h"
=20
+#define D(x) //x
+
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
/* General BTD stuff */
=20
@@ -116,6 +116,7 @@
/* long option list */
static struct option long_options[] =3D
{
+ {"initial-speed", 1, NULL, 'i'}, /* initial uart speed */
{"physdev", 1, NULL, 'u'}, /* phys device used from stack */
{"local-name", 1, NULL, 'n'}, /* set local bluetooth name */
{"reset", 1, NULL, 'R'}, /* reset BT HW */
@@ -138,7 +139,7 @@
int opt;
int bt_disc =3D N_BT;
=20
- syslog(LOG_INFO, "Bluetooth daemon starting\n");
+ syslog(LOG_INFO, "Bluetooth daemon starting");
=20
if (atexit(btd_cleanup) < 0)
{
@@ -155,30 +156,30 @@
case 'i':
/* uart device */
init_hw_speed =3D atoi(optarg);
- syslog(LOG_INFO, "init_hw_speed %d baud\n", init_hw_speed);
+ D(syslog(LOG_INFO, "init_hw_speed %d baud", init_hw_speed));
break;
=20
case 'n':
- printf("setting local name to %s\n", optarg);
+ D(syslog(LOG_INFO, "setting local name to %s", optarg));
strncpy(local_name, optarg, LOCAL_NAME_LENGTH);
local_name[LOCAL_NAME_LENGTH] =3D '\0';
break;
=20
case 'R':
/* try to reset the hardware */
- printf("reset HW\n");
+ D(syslog(LOG_INFO, "reset HW"));
do_reset =3D 1;
break;
=20
case 's':
/* speed */
- printf("phys dev running at %s\n", optarg);
+ D(syslog(LOG_INFO, "phys dev running at %s", optarg));
speedstr =3D optarg;
break;
=20
case 'u':
/* uart device */
- printf("phys dev : %s\n", optarg);
+ D(syslog(LOG_INFO, "phys dev: %s", optarg));
physdev =3D optarg;
break;
=20
@@ -190,23 +191,19 @@
/* Set restart point */
if (sigsetjmp(jmpbuffer, 1) !=3D 0)
{
- syslog(LOG_INFO, "restart...\n\n\n\n");
+ syslog(LOG_INFO, "Restart...");
+ sleep(1);
}
=20
init();
=20
- /* Hardreset of BT hardware */
- if (do_reset)
- reset_hw();
-
if ((phys_fd =3D open(physdev, O_RDWR | O_NOCTTY)) < 0)
{
- perror("could not open phys dev\n");
+ perror("Could not open phys dev");
exit(1);
}
=20
- /* Set default speed */
-
+ /* Sets initial HW baudrate */
if (init_hw_speed !=3D 0)
fd_setup(phys_fd, init_hw_speed, USE_FLOW_CTRL, hw_vendor() =3D=3D HW_=
CSR_BCSP);
else
@@ -217,6 +214,12 @@
=20=20=20
bt_cfd =3D bt_openctrl();
=20
+ tcflush(phys_fd, TCIOFLUSH);
+
+ /* Hardreset of BT hardware */
+ if (do_reset)
+ reset_hw();
+
init_stack(bt_cfd, atoi(speedstr));
=20
if (do_hwinit)
@@ -225,8 +228,7 @@
/* All initialized and ready to accept connections in other BT apps */
=20
while (1)
- sleep(1);
-
+ sleep(100);
} /* main */
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
@@ -237,30 +239,26 @@
{
struct sigaction act;
=20
- syslog(LOG_INFO, "Initiating signal handler\n");
+ D(syslog(LOG_INFO, "Initiating signal handler"));
act.sa_handler =3D sighandler;
sigemptyset(&act.sa_mask);
act.sa_flags =3D 0;
- sigaction(SIGUSR1, &act, 0);
- sigaction(SIGTERM, &act, 0);
- /* other sigs ? */
+ sigaction(SIGUSR1, &act, 0); /* Restart application */
+ sigaction(SIGTERM, &act, 0); /* Terminate application */
}
=20
static void
sighandler(int sig)
{
- printf("Sighandler : %d\n", sig);
+ D(syslog(LOG_INFO, "Sighandler got signal: %d", sig));
=20
- /* Restart stack on SIGUSR1 */
if (sig =3D=3D SIGUSR1)
{
- syslog(LOG_INFO, "Restart stack\n");
-=20=20=20=20
+ /* Shutdown all and restart */
btd_cleanup();
-=20
siglongjmp(jmpbuffer, 1);
}
- if (sig =3D=3D SIGTERM)
+ else if (sig =3D=3D SIGTERM)
{
exit(0);
}
@@ -285,13 +283,12 @@
static void
btd_cleanup(void)
{
- printf("btd_cleanup : Shutting down stack and terminating childs\n");
- syslog(LOG_INFO, "btd_cleanup\n");
+ D(syslog(LOG_INFO, __FUNCTION__));
btd_killchilds();
=20
- syslog(LOG_INFO, "shutdown_stack\n");
+ printf("Shutting down Bluetooth stack\n");
shutdown_stack(bt_cfd);
- syslog(LOG_INFO, "shutdown_stack done\n");
+ printf("Bluetooth stack shut down\n");
=20
if (bt_cfd !=3D -1)
{
@@ -317,10 +314,9 @@
static void
btd_killchilds(void)
{
- syslog(LOG_INFO, "btd_killchilds\n");
if (sdpsrv_pid > 0)
{
- syslog(LOG_INFO, "Killing SDP server\n");
+ D(syslog(LOG_INFO, "Killing SDP server"));
kill(sdpsrv_pid, SIGTERM);
=20=20=20=20=20
if (waitpid(sdpsrv_pid, NULL, 0) < 0)
|
|
From: Mattias A. <mat...@us...> - 2001-06-13 12:38:13
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btinit.c 1.10 1.11=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* added call to init_failed if init stack failed...
* minor changes
The diff of the modified file(s):
--- btinit.c 2001/06/08 09:56:37 1.10
+++ btinit.c 2001/06/13 12:17:34 1.11
@@ -204,6 +204,7 @@
}
=20
/* Sets initial HW baudrate */
+
if (init_hw_speed !=3D 0)
fd_setup(phys_fd, init_hw_speed, USE_FLOW_CTRL, hw_vendor() =3D=3D HW_=
CSR_BCSP);
else
@@ -220,7 +221,8 @@
if (do_reset)
reset_hw();
=20
- init_stack(bt_cfd, atoi(speedstr));
+ if (init_stack(bt_cfd, atoi(speedstr)) < 0)
+ init_failed(bt_cfd, phys_fd, atoi(speedstr));
=20
if (do_hwinit)
init_hw(bt_cfd, phys_fd, atoi(speedstr));
@@ -288,7 +290,6 @@
=20
printf("Shutting down Bluetooth stack\n");
shutdown_stack(bt_cfd);
- printf("Bluetooth stack shut down\n");
=20
if (bt_cfd !=3D -1)
{
|
|
From: Alain P. <apa...@us...> - 2002-04-22 14:22:55
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added option -D that allow to use RTS to reset a module if you don't use fl=
ow control.
The diff of the modified file(s):
--- btinit.c 16 Oct 2001 15:02:20 -0000 1.17
+++ btinit.c 22 Apr 2002 14:22:53 -0000 1.18
@@ -140,11 +140,34 @@
static void sighandler(int sig);
=20
=20
+void unreset_force_rts()
+{
+ int iosettings;
+
+ /* Normally, the RTS should be LOW after having opened the serial port */
+ /* Wait 200 ms to be sure to have a valid reset */
+
+ usleep(200000);
+ if (ioctl (phys_fd, TIOCMGET, &iosettings) !=3D 0) {
+ fprintf(stderr, "btinit : Error for ioctl TIOCMGET\n");
+ }
+ iosettings &=3D ~TIOCM_RTS;
+ if (ioctl (phys_fd, TIOCMSET, &iosettings) !=3D 0) {
+ fprintf(stderr, "btinit : Error for ioctl TIOCMSET\n");
+ }
+ D(syslogprintf("btinit : RTS set to HIGH\n"));
+ sleep(2); /* Wait that module boot. 1 second is too short */
+
+}
+
+
+
int
main(int argc, char **argv)
{=20=20
int opt;
int bt_disc =3D N_BT;
+ volatile int rts_hard_reset =3D 0;
=20
syslog(LOG_INFO, "Bluetooth daemon starting");
=20
@@ -155,7 +178,7 @@
}
=20
/* now parse options */
- while ((opt =3D getopt_long(argc, argv, "fi:nRs:u:",
+ while ((opt =3D getopt_long(argc, argv, "fi:nRs:u:D",
long_options, &option_index)) !=3D -1)
{
switch(opt)
@@ -196,11 +219,24 @@
physdev =3D optarg;
break;
=20
+ case 'D':
+ /* If called with -f option, set RTS to 1 after the port has been op=
ened */
+ /* It's usefull if you command a reset by the RTS pin */
+ D(syslog(LOG_INFO, "Use RTS for hard reset", optarg));
+ rts_hard_reset =3D 1;
default:
break;
}
}
=20
+ /* Verify that options if we have -D option, we have -f too */
+ if (rts_hard_reset & !(flow_control =3D=3D USE_NO_FLOW))
+ {
+ fprintf(stderr, "You can't use -D option without -f option.\n");
+ fprintf(stderr, "bti won't care about -D option\n");
+ rts_hard_reset =3D 0;
+ }
+=09
/* Set restart point */
if (sigsetjmp(jmpbuffer, 1) !=3D 0)
{
@@ -228,6 +264,10 @@
=20=20=20
bt_cfd =3D bt_openctrl();
=20
+ /* Use RTS to reset/unreset the card (only if option selected) */
+ if (rts_hard_reset)
+ unreset_force_rts();
+=20=20
tcflush(phys_fd, TCIOFLUSH);
=20
/* Hardreset of BT hardware */
|
|
From: Alain P. <apa...@us...> - 2002-04-22 15:08:07
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.18 1.19=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Just add a break that has been forgotten.
The diff of the modified file(s):
--- btinit.c 22 Apr 2002 14:22:53 -0000 1.18
+++ btinit.c 22 Apr 2002 15:00:22 -0000 1.19
@@ -224,6 +224,8 @@
/* It's usefull if you command a reset by the RTS pin */
D(syslog(LOG_INFO, "Use RTS for hard reset", optarg));
rts_hard_reset =3D 1;
+ break;
+
default:
break;
}
|
|
From: Alain P. <apa...@us...> - 2002-05-15 13:07:56
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.19 1.20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added long option and documentation for reset on RTS.
The diff of the modified file(s):
--- btinit.c 22 Apr 2002 15:00:22 -0000 1.19
+++ btinit.c 15 May 2002 13:07:56 -0000 1.20
@@ -74,6 +74,10 @@
force uart communication to not use CTS and RTS
default: flow control activated if defined hardware support it
=20
+ -D, --user-rts
+ Use RTS for hard reset
+ default: no use of RTS
+
e.g
./bti --reset --speed 460800 --physdev /dev/ttyS0 --local-name OpenBT
./bti --reset --speed 1000000/1 --physdev /dev/ttyS0 --local-name OpenBT
@@ -128,6 +132,7 @@
{ "local-name", 1, NULL, 'n' }, /* set local bluetooth name */
{ "reset", 0, NULL, 'R' }, /* reset BT HW */
{ "speed", 1, NULL, 's' }, /* uart speed towards hw */
+ { "use-rts", 1, NULL, 'D' }, /* user rts for hard reset */
{ 0, 0, 0, 0 }
};
=20
|
|
From: Alain P. <apa...@us...> - 2002-08-16 14:24:24
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.22 1.23=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Changed the value of reset on DTR port : Reset is active high.
The diff of the modified file(s):
--- btinit.c 22 Jul 2002 17:22:13 -0000 1.22
+++ btinit.c 16 Aug 2002 14:24:22 -0000 1.23
@@ -152,25 +152,27 @@
/* Normally, the RTS should be LOW after having opened the serial port */
/* Wait 200 ms to be sure to have a valid reset */
=20
+ /* If we set the bit to 1 in the DTR register, this will result */
+ /* in a value of 0 on the port. So make &=3D to put the output to 1 */
=20=09
if (ioctl (phys_fd, TIOCMGET, &iosettings) !=3D 0) {
fprintf(stderr, "btinit : Error for ioctl TIOCMGET\n");
}
printf("Set DTR to 0\n");
- iosettings &=3D ~TIOCM_DTR;
+ iosettings |=3D TIOCM_DTR;
if (ioctl (phys_fd, TIOCMSET, &iosettings) !=3D 0) {
fprintf(stderr, "btinit : Error for ioctl TIOCMSET\n");
}
usleep(500000);=09
printf("Set DTR to 1\n");
- iosettings |=3D TIOCM_DTR;
+ iosettings &=3D ~TIOCM_DTR;
ioctl (phys_fd, TIOCMSET, &iosettings);
- //DBG ("Resetting the module");
+
usleep(200000); /*Sleep 200 ms for reset*/
printf("Set DTR to 0 again\n");
- iosettings &=3D ~TIOCM_DTR;
+ iosettings |=3D TIOCM_DTR;
ioctl (phys_fd, TIOCMSET, &iosettings);
- //DBG ("End of reset");
+
D(syslogprintf("btinit : DTR set to HIGH\n"));
sleep(2); /* Wait that module boot. 1 second is too short */
=20=09
|
|
From: Alain P. <apa...@us...> - 2002-08-16 15:23:01
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.23 1.24=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Invert again the signals for reset... sorry.
The diff of the modified file(s):
--- btinit.c 16 Aug 2002 14:24:22 -0000 1.23
+++ btinit.c 16 Aug 2002 15:23:01 -0000 1.24
@@ -158,19 +158,19 @@
if (ioctl (phys_fd, TIOCMGET, &iosettings) !=3D 0) {
fprintf(stderr, "btinit : Error for ioctl TIOCMGET\n");
}
- printf("Set DTR to 0\n");
- iosettings |=3D TIOCM_DTR;
+ printf("Set DTR to 1\n");
+ iosettings &=3D ~TIOCM_DTR;
if (ioctl (phys_fd, TIOCMSET, &iosettings) !=3D 0) {
fprintf(stderr, "btinit : Error for ioctl TIOCMSET\n");
}
usleep(500000);=09
- printf("Set DTR to 1\n");
- iosettings &=3D ~TIOCM_DTR;
+ printf("Set DTR to 0\n");
+ iosettings |=3D TIOCM_DTR;
ioctl (phys_fd, TIOCMSET, &iosettings);
=20
usleep(200000); /*Sleep 200 ms for reset*/
- printf("Set DTR to 0 again\n");
- iosettings |=3D TIOCM_DTR;
+ printf("Set DTR to 1 again\n");
+ iosettings &=3D ~TIOCM_DTR;
ioctl (phys_fd, TIOCMSET, &iosettings);
=20
D(syslogprintf("btinit : DTR set to HIGH\n"));
|
|
From: Alain P. <apa...@us...> - 2002-08-19 15:18:59
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.24 1.25=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Because the DTR signal is automatically set to 0 when we open the serial po=
rt, it was stupid to suppose that the module could be reseted when DTR is o=
n 0. So I assume that DTR should be to 1 for reseting the module.
The diff of the modified file(s):
--- btinit.c 16 Aug 2002 15:23:01 -0000 1.24
+++ btinit.c 19 Aug 2002 15:18:57 -0000 1.25
@@ -158,19 +158,19 @@
if (ioctl (phys_fd, TIOCMGET, &iosettings) !=3D 0) {
fprintf(stderr, "btinit : Error for ioctl TIOCMGET\n");
}
- printf("Set DTR to 1\n");
- iosettings &=3D ~TIOCM_DTR;
+ printf("Set DTR to 1\n"); /* Output of PC */
+ iosettings |=3D TIOCM_DTR;
if (ioctl (phys_fd, TIOCMSET, &iosettings) !=3D 0) {
fprintf(stderr, "btinit : Error for ioctl TIOCMSET\n");
}
usleep(500000);=09
printf("Set DTR to 0\n");
- iosettings |=3D TIOCM_DTR;
+ iosettings &=3D ~TIOCM_DTR;
ioctl (phys_fd, TIOCMSET, &iosettings);
=20
usleep(200000); /*Sleep 200 ms for reset*/
printf("Set DTR to 1 again\n");
- iosettings &=3D ~TIOCM_DTR;
+ iosettings |=3D TIOCM_DTR;
ioctl (phys_fd, TIOCMSET, &iosettings);
=20
D(syslogprintf("btinit : DTR set to HIGH\n"));
|
|
From: Anders J. <and...@us...> - 2003-10-21 10:09:46
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.25 1.26=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
bti is now a daemon as default. Override with -n.=20
The diff of the modified file(s):
--- btinit.c 2002/08/19 15:18:57 1.25
+++ btinit.c 2003/10/21 09:15:56 1.26
@@ -129,10 +129,11 @@ static struct option long_options[] =3D
{ "noflow", 1, NULL, 'f' }, /* do not use flow control */
{ "initial-speed", 1, NULL, 'i' }, /* initial uart speed */
{ "physdev", 1, NULL, 'u' }, /* phys device used from stack */
- { "local-name", 1, NULL, 'n' }, /* set local bluetooth name */
+ { "local-name", 1, NULL, 'l' }, /* set local bluetooth name */
{ "reset", 0, NULL, 'R' }, /* reset BT HW */
{ "speed", 1, NULL, 's' }, /* uart speed towards hw */
{ "use-dtr", 1, NULL, 'D' }, /* user dtr for hard reset */
+ { "nodaemon", 0, NULL, 'n' }, /* don't daemonize */
{ 0, 0, 0, 0 }
};
=20
@@ -143,6 +144,7 @@ static void init_sighandler(void);
static void btd_cleanup(void);
static void btd_killchilds(void);
static void sighandler(int sig);
+static void daemonize(void);
=20
=20
void unreset_force_rts()
@@ -188,21 +190,20 @@ main(int argc, char **argv)
int opt;
int bt_disc =3D N_BT;
volatile int dtr_hard_reset =3D 0;
+ int daemon =3D 1;
=20
syslog(LOG_INFO, "Bluetooth daemon starting");
=20
- if (atexit(btd_cleanup) < 0)
- {
- printf("btd failed to register cleanup function.\n");
- exit(1);
- }
-
/* now parse options */
- while ((opt =3D getopt_long(argc, argv, "fi:n:Rs:u:D",
+ while ((opt =3D getopt_long(argc, argv, "fi:l:Rs:u:Dn",
long_options, &option_index)) !=3D -1)
{
switch(opt)
{
+ case 'n':
+ daemon =3D 0;
+ break;
+=20=20=20=20=20=20
case 'f':
/* do not use flow control */
flow_control =3D USE_NO_FLOW;
@@ -215,7 +216,7 @@ main(int argc, char **argv)
D(syslog(LOG_INFO, "init_hw_speed %s baud", init_hw_speedstr));
break;
=20
- case 'n':
+ case 'l':
local_name =3D optarg;
D(syslog(LOG_INFO, "setting local name to %s", local_name));
break;
@@ -300,11 +301,51 @@ main(int argc, char **argv)
init_hw(bt_cfd, phys_fd, speedstr);
=20=20=20
/* All initialized and ready to accept connections in other BT apps */
+ if(daemon)
+ {
+ daemonize();
+ }
+
+ if (atexit(btd_cleanup) < 0)
+ {
+ printf("btd failed to register cleanup function.\n");
+ exit(1);
+ }
+ init_sighandler();
=20
while (1)
sleep(100);
} /* main */
=20
+static void daemonize(void) /* go to background */
+{
+ switch (fork())
+ {
+ case -1: /* fork failed */
+ fprintf(stderr,"fork() failed!\n");
+ syslog(LOG_ERR, "Exit after failure to fork. %m");
+ exit(EXIT_FAILURE);
+ case 0: /* child continues */
+ if (chdir("/"))
+ {
+ syslog(LOG_ERR, "Failed changing working directory to '/': %m");
+ exit(EXIT_FAILURE);
+ }
+ break;
+ default: /* parent quits */
+ exit(EXIT_SUCCESS);
+ }
+ if (setsid() =3D=3D -1)
+ {
+ fprintf(stderr,"setsid() failed!\n");
+ syslog(LOG_ERR, "Exit after failed call to setsid().");
+ exit(EXIT_FAILURE);
+ }
+ fclose(stdin);
+ fclose(stdout);
+ fclose(stderr);
+}
+
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
/* Signal handler */
=20
@@ -345,7 +386,6 @@ sighandler(int sig)
static void init()
{=20
btd_pid =3D write_pidfile(PID_FILE);=20=20
- init_sighandler();
=20=20=20
if ((sdpsrv_pid =3D start_sdp_server()) < 0)
{
|
|
From: Anders J. <and...@us...> - 2003-10-23 19:36:11
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.26 1.27=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Changed to use daemon()
The diff of the modified file(s):
--- btinit.c 2003/10/21 09:15:56 1.26
+++ btinit.c 2003/10/23 11:27:20 1.27
@@ -144,8 +144,6 @@ static void init_sighandler(void);
static void btd_cleanup(void);
static void btd_killchilds(void);
static void sighandler(int sig);
-static void daemonize(void);
-
=20
void unreset_force_rts()
{
@@ -190,7 +188,7 @@ main(int argc, char **argv)
int opt;
int bt_disc =3D N_BT;
volatile int dtr_hard_reset =3D 0;
- int daemon =3D 1;
+ int godaemon =3D 1;
=20
syslog(LOG_INFO, "Bluetooth daemon starting");
=20
@@ -201,7 +199,7 @@ main(int argc, char **argv)
switch(opt)
{
case 'n':
- daemon =3D 0;
+ godaemon =3D 0;
break;
=20=20=20=20=20=20=20
case 'f':
@@ -301,9 +299,9 @@ main(int argc, char **argv)
init_hw(bt_cfd, phys_fd, speedstr);
=20=20=20
/* All initialized and ready to accept connections in other BT apps */
- if(daemon)
+ if(godaemon)
{
- daemonize();
+ daemon(0, 0);
}
=20
if (atexit(btd_cleanup) < 0)
@@ -316,36 +314,6 @@ main(int argc, char **argv)
while (1)
sleep(100);
} /* main */
-
-static void daemonize(void) /* go to background */
-{
- switch (fork())
- {
- case -1: /* fork failed */
- fprintf(stderr,"fork() failed!\n");
- syslog(LOG_ERR, "Exit after failure to fork. %m");
- exit(EXIT_FAILURE);
- case 0: /* child continues */
- if (chdir("/"))
- {
- syslog(LOG_ERR, "Failed changing working directory to '/': %m");
- exit(EXIT_FAILURE);
- }
- break;
- default: /* parent quits */
- exit(EXIT_SUCCESS);
- }
- if (setsid() =3D=3D -1)
- {
- fprintf(stderr,"setsid() failed!\n");
- syslog(LOG_ERR, "Exit after failed call to setsid().");
- exit(EXIT_FAILURE);
- }
- fclose(stdin);
- fclose(stdout);
- fclose(stderr);
-}
-
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
/* Signal handler */
=20
|