tux-droid-svn Mailing List for Tux Droid CE (Page 224)
Status: Beta
Brought to you by:
ks156
You can subscribe to this list here.
2007 |
Jan
|
Feb
(32) |
Mar
(108) |
Apr
(71) |
May
(38) |
Jun
(128) |
Jul
(1) |
Aug
(14) |
Sep
(77) |
Oct
(104) |
Nov
(90) |
Dec
(71) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(81) |
Feb
(18) |
Mar
(40) |
Apr
(102) |
May
(151) |
Jun
(74) |
Jul
(151) |
Aug
(257) |
Sep
(447) |
Oct
(379) |
Nov
(404) |
Dec
(430) |
2009 |
Jan
(173) |
Feb
(236) |
Mar
(519) |
Apr
(300) |
May
(112) |
Jun
(232) |
Jul
(314) |
Aug
(58) |
Sep
(203) |
Oct
(293) |
Nov
(26) |
Dec
(109) |
2010 |
Jan
(19) |
Feb
(25) |
Mar
(33) |
Apr
(1) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: neimad <c2m...@c2...> - 2007-06-24 12:25:52
|
Author: neimad Date: 2007-06-24 14:25:51 +0200 (Sun, 24 Jun 2007) New Revision: 431 Modified: daemon/trunk/main.c Log: * Added some doxygen comments on global variables. Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-24 12:01:39 UTC (rev 430) +++ daemon/trunk/main.c 2007-06-24 12:25:51 UTC (rev 431) @@ -53,12 +53,14 @@ .release_status = "", .revision = 0 }; -bool show_frames = false; -bool show_raw_status = false; -bool show_invalid_raw = false; -pid_t daemon_pid = 0; -unsigned char daemonized = 0; +bool show_frames = false; /**< Show USB frames structure */ +bool show_raw_status = false; /**< Show all raw statuses */ +bool show_invalid_raw = false; /**< Show only invalid statuses */ + +pid_t daemon_pid = 0; /**< PID of daemon */ +unsigned char daemonized = 0; /**< Daemonize ? (stay in foreground if not) */ + static uid_t user = (uid_t)-1; /**< Initial user id */ static gid_t group = (gid_t)-1; /**< Initial group id */ |
From: neimad <c2m...@c2...> - 2007-06-24 12:01:41
|
Author: neimad Date: 2007-06-24 14:01:39 +0200 (Sun, 24 Jun 2007) New Revision: 430 Modified: daemon/trunk/libs/USBDaemon_globals.h daemon/trunk/main.c Log: * show_xxx flags are now proper booleans (bool type). Modified: daemon/trunk/libs/USBDaemon_globals.h =================================================================== --- daemon/trunk/libs/USBDaemon_globals.h 2007-06-24 11:52:49 UTC (rev 429) +++ daemon/trunk/libs/USBDaemon_globals.h 2007-06-24 12:01:39 UTC (rev 430) @@ -25,6 +25,7 @@ #define __USBDAEMON_GLOBALS_H__ /*_____________________ I N C L U D E S____________________________________ */ +#include <stdbool.h> #include <unistd.h> #include <usb.h> @@ -46,10 +47,10 @@ #define NEWGID 65534 /*_____________________ G L O B A L S _ V A R I A B L E S _______________________*/ -extern unsigned char show_frames; -extern unsigned char show_raw_status; +extern bool show_frames; +extern bool show_raw_status; extern pid_t daemon_pid; -extern unsigned char show_invalid_raw; +extern bool show_invalid_raw; #define MATURITY_LEN 9 typedef char maturity_t[MATURITY_LEN + 1]; Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-24 11:52:49 UTC (rev 429) +++ daemon/trunk/main.c 2007-06-24 12:01:39 UTC (rev 430) @@ -23,6 +23,7 @@ /*_____________________ I N C L U D E S____________________________________ */ #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <string.h> #include <usb.h> #include <errno.h> @@ -52,9 +53,9 @@ .release_status = "", .revision = 0 }; -unsigned char show_frames = 0; -unsigned char show_raw_status = 0; -unsigned char show_invalid_raw = 0; +bool show_frames = false; +bool show_raw_status = false; +bool show_invalid_raw = false; pid_t daemon_pid = 0; unsigned char daemonized = 0; @@ -339,9 +340,9 @@ else if (!strcmp("-debug", argv[i])) log_level = LOG_LEVEL_DEBUG; else if (!strcmp("-st", argv[i])) - show_frames = 1; + show_frames = true; else if (!strcmp("-sr", argv[i])) - show_raw_status = 1; + show_raw_status = true; else if (!strcmp("-si", argv[i])) show_invalid_raw = 1; else if (!strcmp("-h", argv[i])) |
From: neimad <c2m...@c2...> - 2007-06-24 11:52:55
|
Author: neimad Date: 2007-06-24 13:52:49 +0200 (Sun, 24 Jun 2007) New Revision: 429 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_status_table.c Log: * usb_request_f is defined as a bool, so use true and false instead of 1 and 0. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-24 11:49:29 UTC (rev 428) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-24 11:52:49 UTC (rev 429) @@ -884,7 +884,7 @@ /* usb_request_f flag is reset when the id is received in * usb_get_status_TuxDroid() */ - connection_status.usb_request_f = 1; + connection_status.usb_request_f = true; while (connection_status.usb_request_f) { usleep(100000); @@ -928,7 +928,7 @@ /* usb_request_f flag is reset when the id is received in * usb_get_status_TuxDroid() */ - connection_status.usb_request_f = 1; + connection_status.usb_request_f = true; while (connection_status.usb_request_f) { usleep(100000); @@ -973,7 +973,7 @@ /* usb_request_f flag is reset when the id is received in * usb_get_status_TuxDroid() */ - connection_status.usb_request_f = 1; + connection_status.usb_request_f = true; while (connection_status.usb_request_f) { usleep(100000); Modified: daemon/trunk/libs/USBDaemon_status_table.c =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.c 2007-06-24 11:49:29 UTC (rev 428) +++ daemon/trunk/libs/USBDaemon_status_table.c 2007-06-24 11:52:49 UTC (rev 429) @@ -69,7 +69,7 @@ { case STATUS_ID_CMD: /* The answer from the usb_tux_connection command has been received */ - connection_status.usb_request_f = 0; + connection_status.usb_request_f = false; connection_status.tux_id = (new_status[1] << 8) + new_status[2]; log_debug("id retunred by tux: %i (0x%.2x%.2x)", connection_status.tux_id, new_status[1], new_status[2]); |
From: neimad <c2m...@c2...> - 2007-06-24 11:49:31
|
Author: neimad Date: 2007-06-24 13:49:29 +0200 (Sun, 24 Jun 2007) New Revision: 428 Modified: daemon/trunk/libs/USBDaemon_command_tux.c Log: * Simplified tux_req_status(). We should probably eventually use masks instead of bitfields, though. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-24 11:44:13 UTC (rev 427) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-24 11:49:29 UTC (rev 428) @@ -540,240 +540,80 @@ static void tux_req_status(unsigned char const data[], unsigned char result[]) { result[0] = data[0]; + switch (data[0]) { case DATA_STATUS_WINGS_MOTOR_BACKWARD: - if (portb.bits.PB0) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portb.bits.PB0; break; case DATA_STATUS_SPIN_MOTOR_BACKWARD: - if (portb.bits.PB1) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portb.bits.PB1; break; case DATA_STATUS_SPIN_MOTOR_FORWARD: - if (portb.bits.PB2) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portb.bits.PB2; break; case DATA_STATUS_MOUTH_OPEN_POSITION: - if (portb.bits.PB3) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portb.bits.PB3; break; case DATA_STATUS_MOUTH_CLOSED_POSITION: - if (portb.bits.PB4) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portb.bits.PB4; break; case DATA_STATUS_HEAD_PUSH_POSITION: - if (portb.bits.PB5) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portb.bits.PB5; break; case DATA_STATUS_CHARGER_INHIBIT_SIGNAL: result[0] = DATA_STATUS_CHARGER_INHIBIT_SIGNAL; - if (portb.bits.PB6) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portb.bits.PB6; break; case DATA_STATUS_WINGS_POSITION_SWITCH: - if (portc.bits.PB0) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portc.bits.PB0; break; case DATA_STATUS_MOTOR_FOR_WINGS: - if (portc.bits.PB1) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portc.bits.PB1; break; case DATA_STATUS_LEFT_BLUE_LED: - if (portc.bits.PB2) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portc.bits.PB2; break; case DATA_STATUS_HEAD_MOTOR_FOR_MOUTH: - if (portd.bits.PB1) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portd.bits.PB1; break; case DATA_STATUS_HEAD_MOTOR_FOR_EYES: result[0] = DATA_STATUS_HEAD_MOTOR_FOR_EYES; - if (portd.bits.PB0) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portd.bits.PB0; break; case DATA_STATUS_SPIN_POSITION_SWITCH: - if (portd.bits.PB3) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portd.bits.PB3; break; case DATA_STATUS_WINGS_MOTOR_FORWARD: result[0] = DATA_STATUS_WINGS_MOTOR_FORWARD; - if (portd.bits.PB4) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portd.bits.PB4; break; case DATA_STATUS_IR_LED: - if (portd.bits.PB5) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portd.bits.PB5; break; case DATA_STATUS_EYES_OPEN_POSITION_SWITCH: - if (portd.bits.PB6) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portd.bits.PB6; break; case DATA_STATUS_EYES_CLOSED_POSITION_SWITCH: - if (portd.bits.PB7) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = portd.bits.PB7; break; case DATA_STATUS_LEFT_WING_PUSH: - if (sensors1.bits.PB0) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = sensors1.bits.PB0; break; case DATA_STATUS_RIGHT_WING_PUSH: - if (sensors1.bits.PB1) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = sensors1.bits.PB1; break; case DATA_STATUS_POWER_PLUG_SWITCH: - if (sensors1.bits.PB2) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = sensors1.bits.PB2; break; case DATA_STATUS_HEAD_PUSH_SWITCH: - if (sensors1.bits.PB3) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = sensors1.bits.PB3; break; case DATA_STATUS_CHARGER_LED_STATUS: - if (sensors1.bits.PB4) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = sensors1.bits.PB4; break; case DATA_STATUS_MUTE_STATUS: - if (sensors1.bits.PB7) - { - result[1] = 1; - } - else - { - result[1] = 0; - } + result[1] = sensors1.bits.PB7; break; case DATA_STATUS_LIGHT_LEVEL: result[1] = sensors2.level_light_high.Byte; |
From: neimad <c2m...@c2...> - 2007-06-24 11:44:15
|
Author: neimad Date: 2007-06-24 13:44:13 +0200 (Sun, 24 Jun 2007) New Revision: 427 Modified: software/tuxgi/trunk/tuxgi.py Log: * Hide the shell's error message when it doesn't find ipython or one of the known terminals. * Print a warning on stderr if no known terminal is found. Todo: we should disable the "Tux Droid Shell" button in that case. Modified: software/tuxgi/trunk/tuxgi.py =================================================================== --- software/tuxgi/trunk/tuxgi.py 2007-06-23 19:55:50 UTC (rev 426) +++ software/tuxgi/trunk/tuxgi.py 2007-06-24 11:44:13 UTC (rev 427) @@ -69,16 +69,21 @@ voice_list = gtk.ListStore(gobject.TYPE_STRING) voice_dic = {} current_voice = "" -if not os.popen('type ipython').close(): +if not os.popen('type ipython 2>/dev/null').close(): py_cmd = 'ipython' else: py_cmd = 'python' for term in terminal_shells: - if not os.popen('type %s'%term[0]).close(): + if not os.popen('type %s 2>/dev/null' % term[0]).close(): xterm_cmd = '%s %s %s -i /opt/tuxdroid/api/python/tux.py' \ % (term[0], term[1], py_cmd) break + +if xterm_cmd is None: + sys.stderr.write("Warning: couldn't find any suitable terminal" + " to use as Tux Droid shell\n") + #============================================================================== # Main window class #============================================================================== |
From: neimad <c2m...@c2...> - 2007-06-23 19:56:07
|
Author: neimad Date: 2007-06-23 21:55:50 +0200 (Sat, 23 Jun 2007) New Revision: 426 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_command_tux.h Log: * Fixed prototype of commands_dispatcher() to use type tcp_frame_t for the source frame parameter, and made it const too. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 19:35:01 UTC (rev 425) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 19:55:50 UTC (rev 426) @@ -29,7 +29,6 @@ #include "USBDaemon_globals.h" #include "USBDaemon_log.h" #include "../tuxdefs/commands.h" -#include "USBDaemon_tcp_server.h" #include "USBDaemon_pidfile.h" /*_____________________ D E F I N I T I O N S ______________________________*/ @@ -73,7 +72,7 @@ /* COMMANDS FROM CLIENTS DISPATCHER */ /************************************************************************** */ void commands_dispatcher(unsigned char client_id, /* Client source */ - tcp_frame_t src_frame) /* Source frame */ + const tcp_frame_t src_frame) /* Source frame */ { unsigned char ACK_DP; /* daemon processing ack */ unsigned char data[12]; /* data part of source frame */ Modified: daemon/trunk/libs/USBDaemon_command_tux.h =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.h 2007-06-23 19:35:01 UTC (rev 425) +++ daemon/trunk/libs/USBDaemon_command_tux.h 2007-06-23 19:55:50 UTC (rev 426) @@ -27,6 +27,7 @@ /*_____________________ I N C L U D E S____________________________________ */ #include <stdint.h> #include "USBDaemon_usb.h" +#include "USBDaemon_tcp_server.h" /*_____________________ D E F I N E S ______________________________________*/ @@ -34,7 +35,7 @@ /* COMMANDS FROM CLIENTS DISPATCHER */ extern void commands_dispatcher(unsigned char client_id, - unsigned char src_frame[16]); + const tcp_frame_t src_frame); /* TUX PHYSICAL CHANGES */ extern unsigned char send_usb_dongle_cmd(usb_dongle_commands_t cmd, |
From: neimad <c2m...@c2...> - 2007-06-23 19:35:03
|
Author: neimad Date: 2007-06-23 21:35:01 +0200 (Sat, 23 Jun 2007) New Revision: 425 Modified: daemon/trunk/libs/USBDaemon_command_tux.c Log: * Fixed indentation of top file comment. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 19:34:07 UTC (rev 424) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 19:35:01 UTC (rev 425) @@ -1,22 +1,22 @@ /* -* Tux Droid - USB Daemon -* Copyright (C) 2007 C2ME Sa <rem...@c2...> -* -* 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, 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., 59 Temple Place - Suite 330, Boston, MA -* 02111-1307, USA. -*/ + * Tux Droid - USB Daemon + * Copyright (C) 2007 C2ME Sa <rem...@c2...> + * + * 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, 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ /* $Id$ */ |
From: neimad <c2m...@c2...> - 2007-06-23 19:34:10
|
Author: neimad Date: 2007-06-23 21:34:07 +0200 (Sat, 23 Jun 2007) New Revision: 424 Modified: daemon/trunk/main.c Log: * Updated comment of usage(). Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-23 19:33:21 UTC (rev 423) +++ daemon/trunk/main.c 2007-06-23 19:34:07 UTC (rev 424) @@ -293,7 +293,7 @@ } /** - * Display usage help. + * Display usage help and exit. * * \param[in] status Exit status */ |
From: neimad <c2m...@c2...> - 2007-06-23 19:33:53
|
Author: neimad Date: 2007-06-23 21:33:21 +0200 (Sat, 23 Jun 2007) New Revision: 423 Modified: daemon/trunk/main.c Log: * usage() is now given a status code and makes the daemon exit with this status code. Usage help is printed on stdout if the status is 0 (no error), and on stderr otherwise (error). Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-23 19:22:50 UTC (rev 422) +++ daemon/trunk/main.c 2007-06-23 19:33:21 UTC (rev 423) @@ -294,10 +294,13 @@ /** * Display usage help. + * + * \param[in] status Exit status */ -static void usage(void) +static void usage(int status) { - printf("usage : tuxd [options]\n" + fprintf(status ? stderr : stdout, + "usage : tuxd [options]\n" "options:\n" " -d start in daemon mode\n" " -lsys log to syslog\n" @@ -309,6 +312,7 @@ " -sr show all raw status\n" " -si show only invalid raw status\n" " -h show this usage list\n"); + exit(status); } int main(int argc, char *argv[]) @@ -341,15 +345,9 @@ else if (!strcmp("-si", argv[i])) show_invalid_raw = 1; else if (!strcmp("-h", argv[i])) - { - usage(); - exit(1); - } + usage(0); else - { - usage(); - exit(1); - } + usage(1); } /* Only one instance of the daemon is allowed */ |
From: neimad <c2m...@c2...> - 2007-06-23 19:22:52
|
Author: neimad Date: 2007-06-23 21:22:50 +0200 (Sat, 23 Jun 2007) New Revision: 422 Modified: daemon/trunk/main.c Log: * Fixed indentation of top file comment. Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-23 19:21:41 UTC (rev 421) +++ daemon/trunk/main.c 2007-06-23 19:22:50 UTC (rev 422) @@ -1,23 +1,22 @@ - /* -* Tux Droid - USB Daemon -* Copyright (C) 2007 C2ME Sa <rem...@c2...> -* -* 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, 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., 59 Temple Place - Suite 330, Boston, MA -* 02111-1307, USA. -*/ + * Tux Droid - USB Daemon + * Copyright (C) 2007 C2ME Sa <rem...@c2...> + * + * 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, 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ /* $Id$ */ |
From: neimad <c2m...@c2...> - 2007-06-23 19:21:43
|
Author: neimad Date: 2007-06-23 21:21:41 +0200 (Sat, 23 Jun 2007) New Revision: 421 Modified: daemon/trunk/libs/USBDaemon_usb.c daemon/trunk/libs/USBDaemon_usb.h Log: * Made Tux device, handle and connection status private to new file USBDaemon_usb.c. Modified: daemon/trunk/libs/USBDaemon_usb.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 19:18:23 UTC (rev 420) +++ daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 19:21:41 UTC (rev 421) @@ -29,9 +29,9 @@ #include "USBDaemon_status_table.h" #include "USBDaemon_tcp_server.h" -usb_dev_handle *tux_handle = NULL; -struct usb_device *tux_device = NULL; -usb_connection_status_t usb_connection_status = USB_DISCONNECTED; +static usb_dev_handle *tux_handle = NULL; +static struct usb_device *tux_device = NULL; +static usb_connection_status_t usb_connection_status = USB_DISCONNECTED; /** * Find a Tux droid. Modified: daemon/trunk/libs/USBDaemon_usb.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb.h 2007-06-23 19:18:23 UTC (rev 420) +++ daemon/trunk/libs/USBDaemon_usb.h 2007-06-23 19:21:41 UTC (rev 421) @@ -64,9 +64,6 @@ USB_TUX_CONNECTION_WIRELESS_CHANNEL = 7, } usb_tux_connection_t; -extern usb_dev_handle *tux_handle; -extern usb_connection_status_t usb_connection_status; - extern struct usb_device *usb_find_TuxDroid(void); extern int usb_capture_TuxDroid(void); extern void usb_release_TuxDroid(void); |
From: neimad <c2m...@c2...> - 2007-06-23 19:18:24
|
Author: neimad Date: 2007-06-23 21:18:23 +0200 (Sat, 23 Jun 2007) New Revision: 420 Modified: daemon/trunk/libs/USBDaemon_usb.c daemon/trunk/libs/USBDaemon_usb.h Log: * Added svn:keywords and svn:eol-style properties. Property changes on: daemon/trunk/libs/USBDaemon_usb.c ___________________________________________________________________ Name: svn:keywords + Id Name: svn:eol-style + native Property changes on: daemon/trunk/libs/USBDaemon_usb.h ___________________________________________________________________ Name: svn:keywords + Id Name: svn:eol-style + native |
From: neimad <c2m...@c2...> - 2007-06-23 19:13:42
|
Author: neimad Date: 2007-06-23 21:13:19 +0200 (Sat, 23 Jun 2007) New Revision: 419 Modified: daemon/trunk/libs/USBDaemon_usb.c Log: * All function comments now follow the doxygen style. Modified: daemon/trunk/libs/USBDaemon_usb.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 19:08:26 UTC (rev 418) +++ daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 19:13:19 UTC (rev 419) @@ -33,11 +33,14 @@ struct usb_device *tux_device = NULL; usb_connection_status_t usb_connection_status = USB_DISCONNECTED; -/************************************************************************ */ - -/* usb_find_TuxDroid() */ - -/************************************************************************ */ +/** + * Find a Tux droid. + * + * Searches all USB buses and returns the first device matching Tux + * vendor and product id. + * + * @return Device found or NULL if none + */ struct usb_device *usb_find_TuxDroid(void) { struct usb_bus *bus; @@ -56,11 +59,13 @@ return NULL; } -/************************************************************************ */ - -/* usb_open_TuxDroid() */ - -/************************************************************************ */ +/** + * Open the specified Tux device. + * + * @param tux_dev Tux device (as returned by usb_find_TuxDroid()) + * + * @return Handle on the device if successful, NULL otherwise + */ static struct usb_dev_handle *usb_open_TuxDroid(struct usb_device *tux_dev) { usb_dev_handle *tux_hdl; @@ -90,7 +95,6 @@ return tux_hdl; } - /** * Close a Tux droid previously opened with usb_open_TuxDroid(). */ @@ -108,7 +112,7 @@ /** * Capture a Tux droid. * - * \return 1 if successful, 0 otherwise + * @return 1 if successful, 0 otherwise */ int usb_capture_TuxDroid(void) { |
From: neimad <c2m...@c2...> - 2007-06-23 19:08:28
|
Author: neimad Date: 2007-06-23 21:08:26 +0200 (Sat, 23 Jun 2007) New Revision: 418 Modified: daemon/trunk/main.c Log: * All function comments now follow the doxygen style. Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-23 17:02:52 UTC (rev 417) +++ daemon/trunk/main.c 2007-06-23 19:08:26 UTC (rev 418) @@ -62,11 +62,9 @@ static uid_t user = (uid_t)-1; /**< Initial user id */ static gid_t group = (gid_t)-1; /**< Initial group id */ -/************************************************************************ */ - -/* Setup daemon info from version string */ - -/************************************************************************ */ +/** + * Extract daemon info from version string. + */ static void setup_daemon_info(void) { const char delimiters[] = " .-"; @@ -89,11 +87,9 @@ strncpy(version.release_status, token, sizeof(version.release_status)); } -/************************************************************************ */ - -/* Display daemon info on its standard output */ - -/************************************************************************ */ +/** + * Display daemon info on standard output. + */ static void print_daemon_info(void) { printf("-----------------------------------\n"); @@ -102,11 +98,9 @@ printf("-----------------------------------\n"); } -/************************************************************************ */ - -/* Clean closing of STD IN-OUT FILENO*/ - -/************************************************************************ */ +/** + * Clean closing of stdin and stdout. + */ static int fd_nullify(int desired_fd) { int fd; @@ -236,11 +230,12 @@ } } -/************************************************************************ */ - -/* Daemonizer */ - -/************************************************************************ */ +/** + * Daemonize. + * + * \param[in] log_target Where to log messages + * \param[in] log_level Initial log level + */ static void daemonize(log_target_t log_target, log_level_t log_level) { pid_t pid, sid; @@ -298,11 +293,9 @@ } } -/************************************************************************ */ - -/* Show usages of tux daemon */ - -/************************************************************************ */ +/** + * Display usage help. + */ static void usage(void) { printf("usage : tuxd [options]\n" @@ -319,11 +312,6 @@ " -h show this usage list\n"); } -/************************************************************************ */ - -/* USBDaemon main function */ - -/************************************************************************ */ int main(int argc, char *argv[]) { unsigned char i; |
From: neimad <c2m...@c2...> - 2007-06-23 17:02:56
|
Author: neimad Date: 2007-06-23 19:02:52 +0200 (Sat, 23 Jun 2007) New Revision: 417 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_usb.c daemon/trunk/libs/USBDaemon_usb.h Log: * Renamed old usb_write_TuxDroid() (which effectively sends and awaits an ack) to usb_send_TuxDroid(), and dropped the "bytes" in new functions usb_{read,write}bytes_TuxDroid(). Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 16:53:35 UTC (rev 416) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 17:02:52 UTC (rev 417) @@ -358,7 +358,7 @@ usb_send[0] = 0; for (i = 1; i < 5; i++) usb_send[i] = data[i - 1]; - result[0] = usb_write_TuxDroid(usb_send); + result[0] = usb_send_TuxDroid(usb_send); } /************************************************************************ */ @@ -936,7 +936,7 @@ usb_frame[2] = param1; usb_frame[3] = param2; usb_frame[4] = param3; - return usb_write_TuxDroid(usb_frame); + return usb_send_TuxDroid(usb_frame); } /************************************************************************ */ @@ -955,7 +955,7 @@ log_debug("USB PC->Dongle: %#x, %#x, %#x, %#x, %#x\n", data[0], data[1], data[2], data[3], data[4]); - return usb_writebytes_TuxDroid(data, TUX_SEND_LENGTH); + return usb_write_TuxDroid(data, TUX_SEND_LENGTH); } /** Modified: daemon/trunk/libs/USBDaemon_usb.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 16:53:35 UTC (rev 416) +++ daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 17:02:52 UTC (rev 417) @@ -175,7 +175,7 @@ * * \return number of bytes written if successful, < 0 otherwise */ -int usb_writebytes_TuxDroid(const void *buf, size_t size) +int usb_write_TuxDroid(const void *buf, size_t size) { return usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)buf, size, TUX_WRITE_TIMEOUT); @@ -187,7 +187,7 @@ * @param[out] buf Buffer to store data in * @param[in] size Size of buffer */ -int usb_readbytes_TuxDroid(void *buf, size_t size) +int usb_read_TuxDroid(void *buf, size_t size) { return usb_interrupt_read(tux_handle, TUX_READ_EP, (char *)buf, size, TUX_READ_TIMEOUT); @@ -211,11 +211,11 @@ if (usb_connection_status != USB_CONNECTED) return; - idx = usb_writebytes_TuxDroid(cmd_send, sizeof(cmd_send)); + idx = usb_write_TuxDroid(cmd_send, sizeof(cmd_send)); if (idx <= 0) return; - idx = usb_readbytes_TuxDroid(data, sizeof(data)); + idx = usb_read_TuxDroid(data, sizeof(data)); if (idx <= 0) return; @@ -250,7 +250,7 @@ * * @return Acknowledgement (ACK_xxx), may be success or error */ -unsigned char usb_write_TuxDroid(unsigned char data[TUX_SEND_LENGTH]) +unsigned char usb_send_TuxDroid(unsigned char data[TUX_SEND_LENGTH]) { unsigned char counter; unsigned char csf; @@ -260,7 +260,7 @@ /* Send data */ cmd_status_flag = 1; - usb_writebytes_TuxDroid(data, TUX_SEND_LENGTH); + usb_write_TuxDroid(data, TUX_SEND_LENGTH); counter = 0; csf = cmd_status_flag; Modified: daemon/trunk/libs/USBDaemon_usb.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb.h 2007-06-23 16:53:35 UTC (rev 416) +++ daemon/trunk/libs/USBDaemon_usb.h 2007-06-23 17:02:52 UTC (rev 417) @@ -71,10 +71,10 @@ extern int usb_capture_TuxDroid(void); extern void usb_release_TuxDroid(void); -extern int usb_writebytes_TuxDroid(const void *buf, size_t size); -extern int usb_readbytes_TuxDroid(void *buf, size_t size); +extern int usb_write_TuxDroid(const void *buf, size_t size); +extern int usb_read_TuxDroid(void *buf, size_t size); extern void usb_get_status_TuxDroid(void); -extern unsigned char usb_write_TuxDroid(unsigned char datas[]); +extern unsigned char usb_send_TuxDroid(unsigned char datas[]); #endif /* __USBDAEMON_USB_H__ */ |
From: neimad <c2m...@c2...> - 2007-06-23 16:53:37
|
Author: neimad Date: 2007-06-23 18:53:35 +0200 (Sat, 23 Jun 2007) New Revision: 416 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_usb.c daemon/trunk/libs/USBDaemon_usb.h Log: * Defined functions usb_{read,write}bytes_TuxDroid() for low-level access to the USB device. This hides the details of USB access from USBDaemon_command_tux.c. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 16:32:33 UTC (rev 415) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 16:53:35 UTC (rev 416) @@ -946,7 +946,6 @@ unsigned char param1, unsigned char param2, unsigned char param3) { unsigned char data[TUX_SEND_LENGTH]; - int ret; data[0] = USB_DONGLE_CMD; data[1] = cmd; @@ -955,9 +954,8 @@ data[4] = param3; log_debug("USB PC->Dongle: %#x, %#x, %#x, %#x, %#x\n", data[0], data[1], data[2], data[3], data[4]); - ret = usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)data, - TUX_SEND_LENGTH, TUX_WRITE_TIMEOUT); - return ret; + + return usb_writebytes_TuxDroid(data, TUX_SEND_LENGTH); } /** Modified: daemon/trunk/libs/USBDaemon_usb.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 16:32:33 UTC (rev 415) +++ daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 16:53:35 UTC (rev 416) @@ -168,6 +168,32 @@ } /** + * Write data on Tux droid's USB device. + * + * @param[in] buf Buffer to write + * @param[in] size Size of buffer + * + * \return number of bytes written if successful, < 0 otherwise + */ +int usb_writebytes_TuxDroid(const void *buf, size_t size) +{ + return usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)buf, size, + TUX_WRITE_TIMEOUT); +} + +/** + * Read data from Tux droid's USB device. + * + * @param[out] buf Buffer to store data in + * @param[in] size Size of buffer + */ +int usb_readbytes_TuxDroid(void *buf, size_t size) +{ + return usb_interrupt_read(tux_handle, TUX_READ_EP, (char *)buf, size, + TUX_READ_TIMEOUT); +} + +/** * Get Tux droid's status. * * FIXME: the status of *what* exactly ? @@ -185,13 +211,11 @@ if (usb_connection_status != USB_CONNECTED) return; - idx = usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)cmd_send, - sizeof(cmd_send), TUX_WRITE_TIMEOUT); + idx = usb_writebytes_TuxDroid(cmd_send, sizeof(cmd_send)); if (idx <= 0) return; - idx = usb_interrupt_read(tux_handle, TUX_READ_EP, (char *)data, - sizeof(data), TUX_READ_TIMEOUT); + idx = usb_readbytes_TuxDroid(data, sizeof(data)); if (idx <= 0) return; @@ -228,7 +252,6 @@ */ unsigned char usb_write_TuxDroid(unsigned char data[TUX_SEND_LENGTH]) { - int idx; unsigned char counter; unsigned char csf; @@ -237,8 +260,7 @@ /* Send data */ cmd_status_flag = 1; - idx = usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)data, - TUX_SEND_LENGTH, TUX_WRITE_TIMEOUT); + usb_writebytes_TuxDroid(data, TUX_SEND_LENGTH); counter = 0; csf = cmd_status_flag; Modified: daemon/trunk/libs/USBDaemon_usb.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb.h 2007-06-23 16:32:33 UTC (rev 415) +++ daemon/trunk/libs/USBDaemon_usb.h 2007-06-23 16:53:35 UTC (rev 416) @@ -71,6 +71,9 @@ extern int usb_capture_TuxDroid(void); extern void usb_release_TuxDroid(void); +extern int usb_writebytes_TuxDroid(const void *buf, size_t size); +extern int usb_readbytes_TuxDroid(void *buf, size_t size); + extern void usb_get_status_TuxDroid(void); extern unsigned char usb_write_TuxDroid(unsigned char datas[]); |
From: neimad <c2m...@c2...> - 2007-06-23 16:32:36
|
Author: neimad Date: 2007-06-23 18:32:33 +0200 (Sat, 23 Jun 2007) New Revision: 415 Removed: daemon/trunk/libs/USBDaemon_usb_enum.c daemon/trunk/libs/USBDaemon_usb_enum.h daemon/trunk/libs/USBDaemon_usb_readWrite.c daemon/trunk/libs/USBDaemon_usb_readWrite.h Log: * Forgot to remove old USB files in commit r413... Deleted: daemon/trunk/libs/USBDaemon_usb_enum.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-23 16:30:31 UTC (rev 414) +++ daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-23 16:32:33 UTC (rev 415) @@ -1,173 +0,0 @@ - -/* -* Tux Droid - USB Daemon -* Copyright (C) 2007 C2ME Sa <rem...@c2...> -* -* 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, 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., 59 Temple Place - Suite 330, Boston, MA -* 02111-1307, USA. -*/ - -/* $Id$ */ - -/*_____________________ I N C L U D E S____________________________________ */ -#include <stdio.h> -#include <errno.h> -#include "USBDaemon_usb_enum.h" -#include "USBDaemon_globals.h" -#include "USBDaemon_log.h" -#include "USBDaemon_status_table.h" -#include "USBDaemon_usb_readWrite.h" -#include "USBDaemon_tcp_server.h" - -/*_____________________ V A R I A B L E S __________________________________*/ -usb_dev_handle *tux_handle = NULL; -struct usb_device *tux_device = NULL; -usb_connection_status_t usb_connection_status = USB_DISCONNECTED; - -/*_____________________ F U N C T I O N S __________________________________*/ - -/************************************************************************ */ - -/* usb_find_TuxDroid() */ - -/************************************************************************ */ -struct usb_device *usb_find_TuxDroid(void) -{ - struct usb_bus *bus; - struct usb_device *tux_dev; - - usb_init(); - usb_find_busses(); - usb_find_devices(); - - for (bus = usb_busses; bus; bus = bus->next) - for (tux_dev = bus->devices; tux_dev; tux_dev = tux_dev->next) - if (tux_dev->descriptor.idVendor == TUX_VID - && tux_dev->descriptor.idProduct == TUX_PID) - return tux_dev; - - return NULL; -} - -/************************************************************************ */ - -/* usb_open_TuxDroid() */ - -/************************************************************************ */ -static struct usb_dev_handle *usb_open_TuxDroid(struct usb_device *tux_dev) -{ - usb_dev_handle *tux_hdl; - int error; - - /* Open usb device */ - tux_hdl = usb_open(tux_dev); - - if (!tux_hdl) - { - log_error("Can't open device: %s (%d)", strerror(errno), errno); - return NULL; - } - - /* Claim device interface */ - error = usb_claim_interface(tux_hdl, TUX_INTERFACE); - if (error != 0) - { - /*usb_detach_kernel_driver_np(tux_hdl, TUX_INTERFACE); */ - error = usb_claim_interface(tux_hdl, TUX_INTERFACE); - if (error != 0) - { - log_error("Can't claim interface: %s (%d)", strerror(errno), errno); - return NULL; - } - } - return tux_hdl; -} - - -/** - * Close a Tux droid previously opened with usb_open_TuxDroid(). - */ -static void usb_close_TuxDroid(usb_dev_handle *tux_hdl) -{ - if (usb_release_interface(tux_hdl, TUX_INTERFACE) < 0) - log_warning("failed releasing USB interface: %s (%d)", - strerror(errno), errno); - - if (usb_close(tux_hdl) < 0) - log_warning("failed closing USB device: %s (%d)", - strerror(errno), errno); -} - -/** - * Capture a Tux droid. - * - * \return 1 if successful, 0 otherwise - */ -int usb_capture_TuxDroid(void) -{ - log_debug("Capturing USB device"); - - /* Find Tux */ - do - { - tux_device = usb_find_TuxDroid(); - if (tux_device == NULL) - log_error("Tux dongle not found"); - - sleep(1); - } - while (!tux_device); - - /* Old firmware should be discarded here */ - if (tux_device->descriptor.bcdDevice < 0x100) - { - log_error("Your dongle firmware is too old.\n" - "This version is not compatible with this daemon, please \ - update\n" - "the firmware to version 1.00 or better.\n" - "Check http://www.tuxisalive.com/documentation/how-to/\ - updating-the-firmware\nfor details."); - return 0; - } - - log_debug("Fux found on the USB bus"); - - /* Get Device handle */ - tux_handle = usb_open_TuxDroid(tux_device); - if (tux_handle == NULL) - { - log_error("You must load the daemon in root mode"); - return 0; - } - log_debug("Fux USB device opened"); - - usb_connection_status = USB_CONNECTED; - - return 1; -} - -/** - * Release a Tux droid previously captured. - */ -void usb_release_TuxDroid(void) -{ - log_debug("Releasing USB device"); - - if (tux_handle != NULL) - usb_close_TuxDroid(tux_handle); - - tux_handle = NULL; - tux_device = NULL; -} Deleted: daemon/trunk/libs/USBDaemon_usb_enum.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.h 2007-06-23 16:30:31 UTC (rev 414) +++ daemon/trunk/libs/USBDaemon_usb_enum.h 2007-06-23 16:32:33 UTC (rev 415) @@ -1,81 +0,0 @@ - -/* -* Tux Droid - USB Daemon -* Copyright (C) 2007 C2ME Sa <rem...@c2...> -* -* 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, 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., 59 Temple Place - Suite 330, Boston, MA -* 02111-1307, USA. -*/ - -/* $Id$ */ - -#ifndef __USBDAEMON_USB_ENUM_H__ -#define __USBDAEMON_USB_ENUM_H__ - -/*_____________________ I N C L U D E S____________________________________ */ -#include <usb.h> - -/*_____________________ D E F I N E S ______________________________________*/ - -#define USB_FRAME_SIZE 5 -/*_____________________ E N U M S ______________________________________*/ -typedef enum -{ - USB_DISCONNECTED = 0, - USB_CONNECTED = 1 -} usb_connection_status_t; - -typedef enum -{ - USB_TUX_CMD = 0, - USB_DONGLE_CMD = 1, - USB_BOOTLOADER_CMD = 2, -} usb_command_header_t; - -typedef enum -{ - USB_TUX_CONNECTION_CMD = 0, - USB_STATUS_CMD = 1, - USB_AUDIO_CMD = 2, - USB_VERSION_CMD = 6, -} usb_dongle_commands_t; - -/* tux connection commands available on the usb dongle - * - * These are of the following type: - * USB_DONGLE_CMD, USB_TUX_CONNECTION_CMD - */ -typedef enum -{ - USB_TUX_CONNECTION_DISCONNECT = 1, - USB_TUX_CONNECTION_CONNECT = 2, - USB_TUX_CONNECTION_ID_REQUEST = 3, - USB_TUX_CONNECTION_ID_LOOKUP = 4, - USB_TUX_CONNECTION_CHANGE_ID = 5, - USB_TUX_CONNECTION_WAKEUP = 6, - USB_TUX_CONNECTION_WIRELESS_CHANNEL = 7, -} usb_tux_connection_t; - -/*_____________________ V A R I A B L E S __________________________________*/ -extern usb_dev_handle *tux_handle; -extern usb_connection_status_t usb_connection_status; - -/*_____________________ F U N C T I O N S __________________________________*/ - -extern struct usb_device *usb_find_TuxDroid(void); -extern int usb_capture_TuxDroid(void); -extern void usb_release_TuxDroid(void); - -#endif Deleted: daemon/trunk/libs/USBDaemon_usb_readWrite.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_readWrite.c 2007-06-23 16:30:31 UTC (rev 414) +++ daemon/trunk/libs/USBDaemon_usb_readWrite.c 2007-06-23 16:32:33 UTC (rev 415) @@ -1,126 +0,0 @@ - -/* -* Tux Droid - USB Daemon -* Copyright (C) 2007 C2ME Sa <rem...@c2...> -* -* 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, 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., 59 Temple Place - Suite 330, Boston, MA -* 02111-1307, USA. -*/ - -/* $Id$ */ - -#include <stdio.h> -#include "USBDaemon_usb_enum.h" -#include "USBDaemon_globals.h" -#include "USBDaemon_log.h" -#include "USBDaemon_status_table.h" -#include "USBDaemon_tcp_server.h" -#include "USBDaemon_usb_readWrite.h" - -/** - * Get Tux droid's status. - * - * FIXME: the status of *what* exactly ? - * FIXME: "getting" something and not actually returning anything - * is weird; "updating" would be more correct. - */ -void usb_get_status_TuxDroid(void) -{ - const unsigned char cmd_send[5] = { 0x01, 0x01, 0x00, 0x00, 0x00 }; - unsigned char data[64] = { [0 ... 63] = 0 }; - unsigned char *d; - int idx; - int num_frames, i; - - if (usb_connection_status != USB_CONNECTED) - return; - - idx = usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)cmd_send, - sizeof(cmd_send), TUX_WRITE_TIMEOUT); - if (idx <= 0) - return; - - idx = usb_interrupt_read(tux_handle, TUX_READ_EP, (char *)data, - sizeof(data), TUX_READ_TIMEOUT); - if (idx <= 0) - return; - - update_system_status_table(data); - - num_frames = data[3]; - - if (show_frames) - log_debug("RF_st: %.2x CMD_st: %.2x NB_frames : %d idx : %d", - RF_status, CMD_status, num_frames, idx); - - /* XXX Should assert in this case, I guess ? */ - if (num_frames >= 16) - return; - - d = data + 4; - for (i = 0; i < num_frames; i++) - { - if (show_raw_status) - log_debug("%.2x %.2x %.2x %.2x", d[0], d[1], d[2], d[3]); - - update_raw_status_table(d); - d += 4; - } -} - -/** - * Send data to Tux droid over usb. - * FIXME: the whole cmd_status_flag thing is clunky. - * - * @param[in] data Data to send - * - * @return Acknowledgement (ACK_xxx), may be success or error - */ -unsigned char usb_write_TuxDroid(unsigned char data[TUX_SEND_LENGTH]) -{ - int idx; - unsigned char counter; - unsigned char csf; - - if (usb_connection_status != USB_CONNECTED) - return ACK_CMD_DONGLE_NOT_PRESENT; - - /* Send data */ - cmd_status_flag = 1; - idx = usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)data, - TUX_SEND_LENGTH, TUX_WRITE_TIMEOUT); - counter = 0; - csf = cmd_status_flag; - - while (csf) - { - usb_get_status_TuxDroid(); - csf = cmd_status_flag; - - counter++; - usleep(10000); - if (counter == 15) - { - return ACK_CMD_TIMEOUT; - } - } - - if (CMD_status == ACK_CMD_OK) - return ACK_CMD_OK; - else if (CMD_status == ACK_CMD_KO) - return ACK_CMD_KO; - else - return ACK_CMD_ERROR; -} Deleted: daemon/trunk/libs/USBDaemon_usb_readWrite.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb_readWrite.h 2007-06-23 16:30:31 UTC (rev 414) +++ daemon/trunk/libs/USBDaemon_usb_readWrite.h 2007-06-23 16:32:33 UTC (rev 415) @@ -1,38 +0,0 @@ - -/* -* Tux Droid - USB Daemon -* Copyright (C) 2007 C2ME Sa <rem...@c2...> -* -* 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, 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., 59 Temple Place - Suite 330, Boston, MA -* 02111-1307, USA. -*/ - -/* $Id$ */ - -#ifndef __USBDAEMON_USB_READWRITE_H__ -#define __USBDAEMON_USB_READWRITE_H__ - -/*_____________________ I N C L U D E S____________________________________ */ -#include <usb.h> - -/*_____________________ D E F I N E S ______________________________________*/ - -/*_____________________ V A R I A B L E S __________________________________*/ - -/*_____________________ F U N C T I O N S __________________________________*/ -extern void usb_get_status_TuxDroid(void); -extern unsigned char usb_write_TuxDroid(unsigned char datas[]); - -#endif |
From: neimad <c2m...@c2...> - 2007-06-23 16:31:05
|
Author: neimad Date: 2007-06-23 18:30:31 +0200 (Sat, 23 Jun 2007) New Revision: 414 Added: daemon/trunk/libs/USBDaemon_usb.c daemon/trunk/libs/USBDaemon_usb.h Modified: daemon/trunk/Makefile daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_command_tux.h daemon/trunk/libs/USBDaemon_status_table.c daemon/trunk/libs/USBDaemon_tcp_server.c daemon/trunk/main.c Log: * Merged USBDaemon_usb_{enum,readWrite}.[ch] into USBDaemon_usb.[ch]. The naming scheme (both for the files and the functions) remains unchanged for the time being; this will happen in a future commit. Modified: daemon/trunk/Makefile =================================================================== --- daemon/trunk/Makefile 2007-06-23 15:27:46 UTC (rev 413) +++ daemon/trunk/Makefile 2007-06-23 16:30:31 UTC (rev 414) @@ -38,8 +38,7 @@ SRC_OBJS = \ $(OBJ_DIR)/main.o \ - $(OBJ_DIR)/USBDaemon_usb_enum.o \ - $(OBJ_DIR)/USBDaemon_usb_readWrite.o \ + $(OBJ_DIR)/USBDaemon_usb.o \ $(OBJ_DIR)/USBDaemon_status_table.o \ $(OBJ_DIR)/USBDaemon_pidfile.o \ $(OBJ_DIR)/USBDaemon_command_tux.o \ @@ -85,7 +84,7 @@ $(OBJ_DIR)/main.o: main.c \ libs/USBDaemon_globals.h \ -libs/USBDaemon_usb_enum.h \ +libs/USBDaemon_usb.h \ libs/USBDaemon_tcp_server.h \ libs/USBDaemon_status_table.h \ libs/USBDaemon_pidfile.h \ @@ -96,18 +95,12 @@ $(OBJ_DIR)/USBDaemon_log.o: libs/USBDaemon_log.c libs/USBDaemon_log.h $(compile_source) -$(OBJ_DIR)/USBDaemon_usb_enum.o: libs/USBDaemon_usb_enum.c \ -libs/USBDaemon_usb_enum.h \ +$(OBJ_DIR)/USBDaemon_usb.o: libs/USBDaemon_usb.c \ +libs/USBDaemon_usb.h \ libs/USBDaemon_globals.h \ -libs/USBDaemon_usb_readWrite.h \ libs/USBDaemon_pidfile.h \ -libs/USBDaemon_command_tux.h - $(compile_source) - -$(OBJ_DIR)/USBDaemon_usb_readWrite.o: libs/USBDaemon_usb_readWrite.c \ -libs/USBDaemon_usb_enum.h \ -libs/USBDaemon_globals.h \ libs/USBDaemon_status_table.h \ +libs/USBDaemon_command_tux.h \ tuxdefs/commands.h $(compile_source) @@ -125,9 +118,9 @@ $(OBJ_DIR)/USBDaemon_command_tux.o: libs/USBDaemon_command_tux.c \ libs/USBDaemon_status_table.h \ -tuxdefs/commands.h \ +tuxdefs/commands.h \ libs/USBDaemon_command_tux.h \ -libs/USBDaemon_usb_readWrite.h \ +libs/USBDaemon_usb.h \ libs/USBDaemon_globals.h \ libs/USBDaemon_pidfile.h \ libs/USBDaemon_tcp_server.h Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 15:27:46 UTC (rev 413) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 16:30:31 UTC (rev 414) @@ -24,9 +24,8 @@ #include <stdio.h> #include <usb.h> #include "USBDaemon_status_table.h" -#include "USBDaemon_usb_enum.h" +#include "USBDaemon_usb.h" #include "USBDaemon_command_tux.h" -#include "USBDaemon_usb_readWrite.h" #include "USBDaemon_globals.h" #include "USBDaemon_log.h" #include "../tuxdefs/commands.h" Modified: daemon/trunk/libs/USBDaemon_command_tux.h =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.h 2007-06-23 15:27:46 UTC (rev 413) +++ daemon/trunk/libs/USBDaemon_command_tux.h 2007-06-23 16:30:31 UTC (rev 414) @@ -26,7 +26,7 @@ /*_____________________ I N C L U D E S____________________________________ */ #include <stdint.h> -#include "USBDaemon_usb_enum.h" +#include "USBDaemon_usb.h" /*_____________________ D E F I N E S ______________________________________*/ Modified: daemon/trunk/libs/USBDaemon_status_table.c =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.c 2007-06-23 15:27:46 UTC (rev 413) +++ daemon/trunk/libs/USBDaemon_status_table.c 2007-06-23 16:30:31 UTC (rev 414) @@ -24,7 +24,7 @@ /*_____________________ I N C L U D E S____________________________________ */ #include <stdio.h> #include "USBDaemon_status_table.h" -#include "USBDaemon_usb_enum.h" +#include "USBDaemon_usb.h" #include "USBDaemon_globals.h" #include "USBDaemon_log.h" #include "USBDaemon_tcp_server.h" Modified: daemon/trunk/libs/USBDaemon_tcp_server.c =================================================================== --- daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-23 15:27:46 UTC (rev 413) +++ daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-23 16:30:31 UTC (rev 414) @@ -34,8 +34,7 @@ #include "USBDaemon_command_tux.h" #include "USBDaemon_status_table.h" #include "USBDaemon_tcp_server.h" -#include "USBDaemon_usb_enum.h" -#include "USBDaemon_usb_readWrite.h" +#include "USBDaemon_usb.h" #include "USBDaemon_pidfile.h" #include "USBDaemon_log.h" Added: daemon/trunk/libs/USBDaemon_usb.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb.c (rev 0) +++ daemon/trunk/libs/USBDaemon_usb.c 2007-06-23 16:30:31 UTC (rev 414) @@ -0,0 +1,264 @@ +/* + * Tux Droid - USB Daemon + * Copyright (C) 2007 C2ME Sa <rem...@c2...> + * + * 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, 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +/* $Id$ */ + +#include <stdio.h> +#include <errno.h> + +#include "USBDaemon_usb.h" +#include "USBDaemon_globals.h" +#include "USBDaemon_log.h" +#include "USBDaemon_status_table.h" +#include "USBDaemon_tcp_server.h" + +usb_dev_handle *tux_handle = NULL; +struct usb_device *tux_device = NULL; +usb_connection_status_t usb_connection_status = USB_DISCONNECTED; + +/************************************************************************ */ + +/* usb_find_TuxDroid() */ + +/************************************************************************ */ +struct usb_device *usb_find_TuxDroid(void) +{ + struct usb_bus *bus; + struct usb_device *tux_dev; + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + for (bus = usb_busses; bus; bus = bus->next) + for (tux_dev = bus->devices; tux_dev; tux_dev = tux_dev->next) + if (tux_dev->descriptor.idVendor == TUX_VID + && tux_dev->descriptor.idProduct == TUX_PID) + return tux_dev; + + return NULL; +} + +/************************************************************************ */ + +/* usb_open_TuxDroid() */ + +/************************************************************************ */ +static struct usb_dev_handle *usb_open_TuxDroid(struct usb_device *tux_dev) +{ + usb_dev_handle *tux_hdl; + int error; + + /* Open usb device */ + tux_hdl = usb_open(tux_dev); + + if (!tux_hdl) + { + log_error("Can't open device: %s (%d)", strerror(errno), errno); + return NULL; + } + + /* Claim device interface */ + error = usb_claim_interface(tux_hdl, TUX_INTERFACE); + if (error != 0) + { + /*usb_detach_kernel_driver_np(tux_hdl, TUX_INTERFACE); */ + error = usb_claim_interface(tux_hdl, TUX_INTERFACE); + if (error != 0) + { + log_error("Can't claim interface: %s (%d)", strerror(errno), errno); + return NULL; + } + } + return tux_hdl; +} + + +/** + * Close a Tux droid previously opened with usb_open_TuxDroid(). + */ +static void usb_close_TuxDroid(usb_dev_handle *tux_hdl) +{ + if (usb_release_interface(tux_hdl, TUX_INTERFACE) < 0) + log_warning("failed releasing USB interface: %s (%d)", + strerror(errno), errno); + + if (usb_close(tux_hdl) < 0) + log_warning("failed closing USB device: %s (%d)", + strerror(errno), errno); +} + +/** + * Capture a Tux droid. + * + * \return 1 if successful, 0 otherwise + */ +int usb_capture_TuxDroid(void) +{ + log_debug("Capturing USB device"); + + /* Find Tux */ + do + { + tux_device = usb_find_TuxDroid(); + if (tux_device == NULL) + log_error("Tux dongle not found"); + + sleep(1); + } + while (!tux_device); + + /* Old firmware should be discarded here */ + if (tux_device->descriptor.bcdDevice < 0x100) + { + log_error("Your dongle firmware is too old.\n" + "This version is not compatible with this daemon, please \ + update\n" + "the firmware to version 1.00 or better.\n" + "Check http://www.tuxisalive.com/documentation/how-to/\ + updating-the-firmware\nfor details."); + return 0; + } + + log_debug("Fux found on the USB bus"); + + /* Get Device handle */ + tux_handle = usb_open_TuxDroid(tux_device); + if (tux_handle == NULL) + { + log_error("You must load the daemon in root mode"); + return 0; + } + log_debug("Fux USB device opened"); + + usb_connection_status = USB_CONNECTED; + + return 1; +} + +/** + * Release a Tux droid previously captured. + */ +void usb_release_TuxDroid(void) +{ + log_debug("Releasing USB device"); + + if (tux_handle != NULL) + usb_close_TuxDroid(tux_handle); + + tux_handle = NULL; + tux_device = NULL; +} + +/** + * Get Tux droid's status. + * + * FIXME: the status of *what* exactly ? + * FIXME: "getting" something and not actually returning anything + * is weird; "updating" would be more correct. + */ +void usb_get_status_TuxDroid(void) +{ + const unsigned char cmd_send[5] = { 0x01, 0x01, 0x00, 0x00, 0x00 }; + unsigned char data[64] = { [0 ... 63] = 0 }; + unsigned char *d; + int idx; + int num_frames, i; + + if (usb_connection_status != USB_CONNECTED) + return; + + idx = usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)cmd_send, + sizeof(cmd_send), TUX_WRITE_TIMEOUT); + if (idx <= 0) + return; + + idx = usb_interrupt_read(tux_handle, TUX_READ_EP, (char *)data, + sizeof(data), TUX_READ_TIMEOUT); + if (idx <= 0) + return; + + update_system_status_table(data); + + num_frames = data[3]; + + if (show_frames) + log_debug("RF_st: %.2x CMD_st: %.2x NB_frames : %d idx : %d", + RF_status, CMD_status, num_frames, idx); + + /* XXX Should assert in this case, I guess ? */ + if (num_frames >= 16) + return; + + d = data + 4; + for (i = 0; i < num_frames; i++) + { + if (show_raw_status) + log_debug("%.2x %.2x %.2x %.2x", d[0], d[1], d[2], d[3]); + + update_raw_status_table(d); + d += 4; + } +} + +/** + * Send data to Tux droid over usb. + * FIXME: the whole cmd_status_flag thing is clunky. + * + * @param[in] data Data to send + * + * @return Acknowledgement (ACK_xxx), may be success or error + */ +unsigned char usb_write_TuxDroid(unsigned char data[TUX_SEND_LENGTH]) +{ + int idx; + unsigned char counter; + unsigned char csf; + + if (usb_connection_status != USB_CONNECTED) + return ACK_CMD_DONGLE_NOT_PRESENT; + + /* Send data */ + cmd_status_flag = 1; + idx = usb_interrupt_write(tux_handle, TUX_WRITE_EP, (char *)data, + TUX_SEND_LENGTH, TUX_WRITE_TIMEOUT); + counter = 0; + csf = cmd_status_flag; + + while (csf) + { + usb_get_status_TuxDroid(); + csf = cmd_status_flag; + + counter++; + usleep(10000); + if (counter == 15) + { + return ACK_CMD_TIMEOUT; + } + } + + if (CMD_status == ACK_CMD_OK) + return ACK_CMD_OK; + else if (CMD_status == ACK_CMD_KO) + return ACK_CMD_KO; + else + return ACK_CMD_ERROR; +} Added: daemon/trunk/libs/USBDaemon_usb.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb.h (rev 0) +++ daemon/trunk/libs/USBDaemon_usb.h 2007-06-23 16:30:31 UTC (rev 414) @@ -0,0 +1,77 @@ +/* + * Tux Droid - USB Daemon + * Copyright (C) 2007 C2ME Sa <rem...@c2...> + * + * 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, 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +/* $Id$ */ + +#ifndef __USBDAEMON_USB_H__ +#define __USBDAEMON_USB_H__ + +#include <usb.h> + +#define USB_FRAME_SIZE 5 + +typedef enum +{ + USB_DISCONNECTED = 0, + USB_CONNECTED = 1 +} usb_connection_status_t; + +typedef enum +{ + USB_TUX_CMD = 0, + USB_DONGLE_CMD = 1, + USB_BOOTLOADER_CMD = 2, +} usb_command_header_t; + +typedef enum +{ + USB_TUX_CONNECTION_CMD = 0, + USB_STATUS_CMD = 1, + USB_AUDIO_CMD = 2, + USB_VERSION_CMD = 6, +} usb_dongle_commands_t; + +/* tux connection commands available on the usb dongle + * + * These are of the following type: + * USB_DONGLE_CMD, USB_TUX_CONNECTION_CMD + */ +typedef enum +{ + USB_TUX_CONNECTION_DISCONNECT = 1, + USB_TUX_CONNECTION_CONNECT = 2, + USB_TUX_CONNECTION_ID_REQUEST = 3, + USB_TUX_CONNECTION_ID_LOOKUP = 4, + USB_TUX_CONNECTION_CHANGE_ID = 5, + USB_TUX_CONNECTION_WAKEUP = 6, + USB_TUX_CONNECTION_WIRELESS_CHANNEL = 7, +} usb_tux_connection_t; + +extern usb_dev_handle *tux_handle; +extern usb_connection_status_t usb_connection_status; + +extern struct usb_device *usb_find_TuxDroid(void); +extern int usb_capture_TuxDroid(void); +extern void usb_release_TuxDroid(void); + +extern void usb_get_status_TuxDroid(void); +extern unsigned char usb_write_TuxDroid(unsigned char datas[]); + +#endif /* __USBDAEMON_USB_H__ */ Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-23 15:27:46 UTC (rev 413) +++ daemon/trunk/main.c 2007-06-23 16:30:31 UTC (rev 414) @@ -37,7 +37,7 @@ #include "libs/USBDaemon_globals.h" #include "libs/USBDaemon_log.h" #include "libs/USBDaemon_pidfile.h" -#include "libs/USBDaemon_usb_enum.h" +#include "libs/USBDaemon_usb.h" #include "libs/USBDaemon_tcp_server.h" #include "libs/USBDaemon_status_table.h" #include "libs/USBDaemon_command_tux.h" |
From: neimad <c2m...@c2...> - 2007-06-23 15:28:25
|
Author: neimad Date: 2007-06-23 17:27:46 +0200 (Sat, 23 Jun 2007) New Revision: 413 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_command_tux.h daemon/trunk/libs/USBDaemon_usb_enum.c daemon/trunk/main.c Log: * Moved audio initialization out of usb_capture_TuxDroid() so as to avoid an inter-dependency between modules USBDaemon_usb_enum and USBDaemon_command_tux. Audio is now initialized directly by main(). Not very nice, but this is just a step towards a nicer separation between low-level usb module, commands and the future higher-level "droid" object. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-21 14:07:21 UTC (rev 412) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-23 15:27:46 UTC (rev 413) @@ -962,6 +962,17 @@ } /** + * Initialize audio. + */ +void tux_audio_init(void) +{ + /* Resets audio channel selection; there are 2 audio interfaces in the + * dongle, the second is dedicated to TTS. */ + send_usb_dongle_cmd(USB_AUDIO_CMD, 0, 0, 0); + current_audio_channel = 0; +} + +/** * Disconnect from tux * * The return value only tells whether the command has been sent successfully Modified: daemon/trunk/libs/USBDaemon_command_tux.h =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.h 2007-06-21 14:07:21 UTC (rev 412) +++ daemon/trunk/libs/USBDaemon_command_tux.h 2007-06-23 15:27:46 UTC (rev 413) @@ -41,6 +41,7 @@ unsigned char param1, unsigned char param2, unsigned char param3); +extern void tux_audio_init(void); extern unsigned char send_wave_wings(unsigned char count, unsigned char speed); extern unsigned char send_stop_wings(); extern unsigned char send_blink_eyes(unsigned char count); Modified: daemon/trunk/libs/USBDaemon_usb_enum.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-21 14:07:21 UTC (rev 412) +++ daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-23 15:27:46 UTC (rev 413) @@ -29,7 +29,6 @@ #include "USBDaemon_log.h" #include "USBDaemon_status_table.h" #include "USBDaemon_usb_readWrite.h" -#include "USBDaemon_command_tux.h" #include "USBDaemon_tcp_server.h" /*_____________________ V A R I A B L E S __________________________________*/ @@ -156,11 +155,6 @@ usb_connection_status = USB_CONNECTED; - /* Resets audio channel selection; there are 2 audio interfaces in the - * dongle, the second is dedicated to TTS. */ - send_usb_dongle_cmd(USB_AUDIO_CMD, 0, 0, 0); - current_audio_channel = 0; - return 1; } Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-21 14:07:21 UTC (rev 412) +++ daemon/trunk/main.c 2007-06-23 15:27:46 UTC (rev 413) @@ -40,6 +40,7 @@ #include "libs/USBDaemon_usb_enum.h" #include "libs/USBDaemon_tcp_server.h" #include "libs/USBDaemon_status_table.h" +#include "libs/USBDaemon_command_tux.h" #include "version.h" /*_____________________ F U N C T I O N S __________________________________*/ @@ -398,6 +399,8 @@ if (drop_privileges() < 0) exit(1); + tux_audio_init(); + if (tcp_server_init() < 0) exit(1); |
From: remi <c2m...@c2...> - 2007-06-21 14:07:48
|
Author: remi Date: 2007-06-21 16:07:21 +0200 (Thu, 21 Jun 2007) New Revision: 412 Modified: daemon/trunk/version.txt Log: New version started Modified: daemon/trunk/version.txt =================================================================== --- daemon/trunk/version.txt 2007-06-21 14:07:02 UTC (rev 411) +++ daemon/trunk/version.txt 2007-06-21 14:07:21 UTC (rev 412) @@ -1 +1 @@ -0.3.1 +0.3.2 (SVN/UNRELEASED) |
From: remi <c2m...@c2...> - 2007-06-21 14:07:36
|
Author: remi Date: 2007-06-21 16:07:01 +0200 (Thu, 21 Jun 2007) New Revision: 410 Modified: daemon/trunk/version.txt Log: Preparing for tag Modified: daemon/trunk/version.txt =================================================================== --- daemon/trunk/version.txt 2007-06-21 13:03:36 UTC (rev 409) +++ daemon/trunk/version.txt 2007-06-21 14:07:01 UTC (rev 410) @@ -1 +1 @@ -0.3.1 (SVN/UNRELEASED) +0.3.1 |
From: remi <c2m...@c2...> - 2007-06-21 14:07:03
|
Author: remi Date: 2007-06-21 16:07:02 +0200 (Thu, 21 Jun 2007) New Revision: 411 Added: daemon/tags/0.3.1/ Log: New tag Copied: daemon/tags/0.3.1 (from rev 410, daemon/trunk) |
From: remi <c2m...@c2...> - 2007-06-21 13:03:37
|
Author: remi Date: 2007-06-21 15:03:36 +0200 (Thu, 21 Jun 2007) New Revision: 409 Modified: api/python/trunk/tuxapi_class.py Log: New version started Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-21 13:02:25 UTC (rev 408) +++ api/python/trunk/tuxapi_class.py 2007-06-21 13:03:36 UTC (rev 409) @@ -36,7 +36,7 @@ # Constants #============================================================================== -api_version ="0.2.2" +api_version ="0.2.3 (SVN/UNRELEASED)" TCPIP_FRAME_LENGTH = 16 #============================================================================== |
From: remi <c2m...@c2...> - 2007-06-21 13:02:26
|
Author: remi Date: 2007-06-21 15:02:25 +0200 (Thu, 21 Jun 2007) New Revision: 408 Added: api/python/tags/0.2.2/ Log: New tag Copied: api/python/tags/0.2.2 (from rev 407, api/python/trunk) |
From: remi <c2m...@c2...> - 2007-06-21 12:49:41
|
Author: remi Date: 2007-06-21 14:49:07 +0200 (Thu, 21 Jun 2007) New Revision: 407 Modified: api/python/trunk/tuxapi_class.py Log: UPD Verification of tux daemon connection before getting a status. Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-19 16:43:49 UTC (rev 406) +++ api/python/trunk/tuxapi_class.py 2007-06-21 12:49:07 UTC (rev 407) @@ -315,8 +315,6 @@ # data type response if ord(data[2])==DATA_TP_RSP: if ord(data[3])==SUBDATA_TP_STATUS: - if self.event.on_status!=None: - self.event.on_status(data) #Head button if ord(data[4])==DATAS_STATUS_HEAD_PUSH_SWITCH: if ord(data[5])==1: @@ -443,6 +441,9 @@ if ord(data[5])==0: if self.event.on_spin_stop!=None: self.event.on_spin_stop() + #on status + if self.event.on_status!=None: + self.event.on_status(data) #-------------------------------------------------------------------------- @@ -2606,6 +2607,8 @@ """ Not a user function """ + if not self.parent.daemon.connected: + return 0 frame = self.get(DATA_STATUS) try: if len(frame) > 0: @@ -3079,6 +3082,8 @@ Example: >>> var = tux.status.light_level() """ + if not self.parent.daemon.connected: + return 0 frame = self.get(DATAS_STATUS_LIGHT_LEVEL) try: if len(frame) > 0: |