tux-droid-svn Mailing List for Tux Droid CE (Page 226)
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-17 09:31:20
|
Author: neimad Date: 2007-06-17 11:31:19 +0200 (Sun, 17 Jun 2007) New Revision: 381 Modified: firmware/tuxup/trunk/bootloader.c Log: * Made two variables static. Modified: firmware/tuxup/trunk/bootloader.c =================================================================== --- firmware/tuxup/trunk/bootloader.c 2007-06-17 09:24:58 UTC (rev 380) +++ firmware/tuxup/trunk/bootloader.c 2007-06-17 09:31:19 UTC (rev 381) @@ -56,14 +56,15 @@ #define BOOT_FILLPAGE 2 #define BOOT_EXIT 2 -const char *hexFile = NULL; +static const char *hexFile = NULL; typedef uint32_t FILE_Addr_t; typedef uint32_t FILE_SegmentLen_t; typedef unsigned FILE_LineNum_t; typedef uint8_t FILE_ParsedLen_t; -enum mem_type_t mem_type; +static enum mem_type_t mem_type; + typedef struct { FILE_LineNum_t lineNum; /* Line number of data record in ASCII file. */ |
From: neimad <c2m...@c2...> - 2007-06-17 09:25:02
|
Author: neimad Date: 2007-06-17 11:24:58 +0200 (Sun, 17 Jun 2007) New Revision: 380 Modified: firmware/tuxup/trunk/main.c Log: * Use NULL directly instead of casting 0. Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-17 09:23:22 UTC (rev 379) +++ firmware/tuxup/trunk/main.c 2007-06-17 09:24:58 UTC (rev 380) @@ -601,7 +601,7 @@ fux_disconnect(); /* Print time elapsed for programming. */ - end_time = time((time_t *) 0); + end_time = time(NULL); if (!pretend) printf("Time elapsed: %2.0f seconds.\n", difftime(end_time, start_time)); |
From: neimad <c2m...@c2...> - 2007-06-17 09:23:24
|
Author: neimad Date: 2007-06-17 11:23:22 +0200 (Sun, 17 Jun 2007) New Revision: 379 Modified: firmware/tuxup/trunk/main.c Log: * Moved declaration inside "switch" block to the only "case" block that uses the declared variable. Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-16 11:58:33 UTC (rev 378) +++ firmware/tuxup/trunk/main.c 2007-06-17 09:23:22 UTC (rev 379) @@ -571,12 +571,11 @@ /* Select which files to program */ switch (program_mode) { - int i; - case INPUTFILES: - for (i = optind; i < argc; ++i) { - program(argv[i], NULL); /* XXX returned values are not used yet */ + int i; + for (i = optind; i < argc; ++i) + program(argv[i], NULL); /* XXX returned values are not used yet */ } break; case MAIN: |
From: neimad <ror...@gm...> - 2007-06-16 12:22:45
|
Enum usb_tux_connection_t (USBDaemon_usb_enum.h) seems to duplicate most of enum tux_connection_t (USBDaemon_status_table.h): 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; typedef enum { TUX_CONNECTION_DISCONNECT = 1, TUX_CONNECTION_CONNECT = 2, TUX_CONNECTION_RANDOM = 3, TUX_CONNECTION_ID_REQUEST = 4, TUX_CONNECTION_ID_LOOKUP = 5, TUX_CONNECTION_CHANGE_ID = 6, TUX_CONNECTION_SLEEP = 7, TUX_CONNECTION_WAKEUP = 8, TUX_CONNECTION_WIRELESS_CHANNEL = 9, } tux_connection_t; They seem to represent the same thing, so I think we should get rid of one of them. Damien |
From: neimad <c2m...@c2...> - 2007-06-16 11:59:01
|
Author: neimad Date: 2007-06-16 13:58:33 +0200 (Sat, 16 Jun 2007) New Revision: 378 Modified: daemon/trunk/libs/USBDaemon_usb_readWrite.c Log: * "Fixed" function comments: merely repeating their name if of no use whatsoever. Not sure about some things, which explains the FIXMEs. * Deleted "I N C L U D E S" and "F U N C T I O N S" section comments. I think we can all see what is what, right ? ;-) Modified: daemon/trunk/libs/USBDaemon_usb_readWrite.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_readWrite.c 2007-06-16 11:38:26 UTC (rev 377) +++ daemon/trunk/libs/USBDaemon_usb_readWrite.c 2007-06-16 11:58:33 UTC (rev 378) @@ -21,7 +21,6 @@ /* $Id$ */ -/*_____________________ I N C L U D E S____________________________________ */ #include <stdio.h> #include "USBDaemon_usb_enum.h" #include "USBDaemon_globals.h" @@ -30,11 +29,13 @@ #include "USBDaemon_tcp_server.h" #include "USBDaemon_usb_readWrite.h" -/*_____________________ F U N C T I O N S __________________________________*/ - -/************************************************************************ */ -/* usb_get_status_TuxDroid() */ -/************************************************************************ */ +/** + * 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 }; @@ -79,9 +80,14 @@ } } -/************************************************************************ */ -/* usb_write_TuxDroid() */ -/************************************************************************ */ +/** + * 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; |
From: neimad <c2m...@c2...> - 2007-06-16 11:39:05
|
Author: neimad Date: 2007-06-16 13:38:26 +0200 (Sat, 16 Jun 2007) New Revision: 377 Modified: daemon/trunk/libs/USBDaemon_usb_enum.c Log: * Inclusion of pidfile header not necessary anymore (should have been removed in commit r352). Modified: daemon/trunk/libs/USBDaemon_usb_enum.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-14 22:02:34 UTC (rev 376) +++ daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-16 11:38:26 UTC (rev 377) @@ -31,7 +31,6 @@ #include "USBDaemon_usb_readWrite.h" #include "USBDaemon_command_tux.h" #include "USBDaemon_tcp_server.h" -#include "USBDaemon_pidfile.h" /*_____________________ V A R I A B L E S __________________________________*/ usb_dev_handle *tux_handle = NULL; |
From: jaguarondi <c2m...@c2...> - 2007-06-14 22:04:28
|
Author: jaguarondi Date: 2007-06-15 00:02:34 +0200 (Fri, 15 Jun 2007) New Revision: 376 Modified: api/python/trunk/tuxapi_class.py Log: * To follow our python coding style guidelines, lines have been wrapped at 80 characters maximum and the continued lines have been indented by 2 tabs. Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-14 20:58:04 UTC (rev 375) +++ api/python/trunk/tuxapi_class.py 2007-06-14 22:02:34 UTC (rev 376) @@ -242,7 +242,8 @@ #-------------------------------------------------------------------------- # SYSTEM function #-------------------------------------------------------------------------- - def _insert_lock_in_list(self,data_to_match_list,cond_lock_mutex,returned_data): + def _insert_lock_in_list(self,data_to_match_list,cond_lock_mutex, \ + returned_data): # lock[0] : list of the possible frames to match # lock[1] : condition mutex # lock[2] : data returned @@ -353,10 +354,12 @@ #Remote button if ord(data[4])==DATAS_STATUS_IR_CODE: if self.event.on_remote_bt[ord(data[5])]!=None: - thread.start_new_thread(self.event.on_remote_bt[ord(data[5])], ()) + thread.start_new_thread( \ + self.event.on_remote_bt[ord(data[5])], ()) #self.event.on_remote_bt[ord(data[5])]() if self.event.on_remote!=None: - thread.start_new_thread(self.event.on_remote, (ord(data[5]),)) + thread.start_new_thread( \ + self.event.on_remote, (ord(data[5]),)) #self.event.on_remote(ord(data[5])) #Mouth open if ord(data[4])==DATAS_STATUS_MOUTH_OPEN_POSITION: @@ -678,7 +681,8 @@ Example: >>> var=tux.sys.time() """ - return (time.localtime()[3]*3600)+(time.localtime()[4]*60)+time.localtime()[5] + return (time.localtime()[3]*3600)+(time.localtime()[4]*60)+ \ + time.localtime()[5] #-------------------------------------------------------------------------- # Wait a time in seconds @@ -745,7 +749,8 @@ Example: >>> tux.sys.add_time_event(CT_SHELL,'xmms',9999,99,99,8,5,0) """ - self.events_list.append([cmd_type,cmd,year,month,day,hour,minute,second]) + self.events_list.append([cmd_type,cmd,year,month,day,hour, \ + minute,second]) #-------------------------------------------------------------------------- # Clear the time events of the time event handler @@ -769,11 +774,11 @@ def event_due(event): now = time.localtime() return event[2] in [now[0], 9999]\ - and event[3] in [now[1], 99]\ - and event[4] in [now[2], 99]\ - and event[5] in [now[3], 99]\ - and event[6] in [now[4], 99]\ - and event[7] in [now[5], 99] + and event[3] in [now[1], 99]\ + and event[4] in [now[2], 99]\ + and event[5] in [now[3], 99]\ + and event[6] in [now[4], 99]\ + and event[7] in [now[5], 99] while self.parent.daemon.connected: for event in self.events_list: @@ -1109,14 +1114,14 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_STATUS,DATA_STATUS,DATA_VALUE,0,0,0,0,0,\ - 0,0,0,0,0) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,SUBDATA_TP_STATUS, + DATA_STATUS,DATA_VALUE,0,0,0,0,0,0,0,0,0,0) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, \ + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(time_out) @@ -1177,24 +1182,22 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_STATUS,DATAS_STATUS_HEAD_PUSH_SWITCH,1,0,0,0,0,0,\ - 0,0,0,0,0) + data_to_match = (SOURCE_TUX,SS_DEFAULT, DATA_TP_RSP, SUBDATA_TP_STATUS, + DATAS_STATUS_HEAD_PUSH_SWITCH,1,0,0,0,0,0,0,0,0,0,0) data_to_match_list.append(data_to_match) # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_STATUS,DATAS_STATUS_LEFT_WING_PUSH,1,0,0,0,0,0,\ - 0,0,0,0,0) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,SUBDATA_TP_STATUS, + DATAS_STATUS_LEFT_WING_PUSH,1,0,0,0,0,0,0,0,0,0,0) data_to_match_list.append(data_to_match) # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_STATUS,DATAS_STATUS_RIGHT_WING_PUSH,1,0,0,0,0,0,\ - 0,0,0,0,0) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,SUBDATA_TP_STATUS, + DATAS_STATUS_RIGHT_WING_PUSH,1,0,0,0,0,0,0,0,0,0,0) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, \ + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(time_out) @@ -1471,14 +1474,14 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_ACK_CMD,\ - 999,999,999,999,999,999,999,999,\ - 999,999,999,999,999) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_ACK_CMD, \ + 999,999,999,999,999,999,999,999,999,999,999,999,999) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, \ + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(2) @@ -1511,8 +1514,8 @@ """ if not self.parent.daemon.connected: return 2 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT\ - ,fct,cmd,param1,param2,param3,0,0,0,0,0,0,0) + data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT, \ + fct,cmd,param1,param2,param3,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) if self.no_ack: return 2 @@ -1539,8 +1542,8 @@ """ if not self.parent.daemon.connected: return 2 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_RAW,\ - cmd,param1,param2,param3,0,0,0,0,0,0,0,0) + data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_RAW, \ + cmd,param1,param2,param3,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) if self.no_ack: return 2 @@ -1562,8 +1565,10 @@ >>> tux.cmd.eyes_on() >>> tux.cmd.eyes_on(2) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_EYES,TUX_CMD_STRUCT_SUB_ON,count,0,0) - self.parent.event.wait_status(DATAS_STATUS_EYES_POSITION_COUNTER,0,(0.3*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_EYES, \ + TUX_CMD_STRUCT_SUB_ON,count,0,0) + self.parent.event.wait_status(DATAS_STATUS_EYES_POSITION_COUNTER, \ + 0,(0.3*count)) #-------------------------------------------------------------------------- # Send a command to tux for opening the eyes @@ -1621,7 +1626,8 @@ Example: >>> tux.cmd.eyes_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_EYES,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_EYES, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for moving the mouth @@ -1638,8 +1644,10 @@ >>> tux.cmd.mouth_on() >>> tux.cmd.mouth_on(2) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH,TUX_CMD_STRUCT_SUB_ON,count,0,0) - self.parent.event.wait_status(DATAS_STATUS_MOUTH_POSITION_COUNTER,0,(0.3*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH, \ + TUX_CMD_STRUCT_SUB_ON,count,0,0) + self.parent.event.wait_status(DATAS_STATUS_MOUTH_POSITION_COUNTER, \ + 0,(0.3*count)) #-------------------------------------------------------------------------- # Send a command to tux for moving the mouth in free mode @@ -1697,7 +1705,8 @@ Example: >>> tux.cmd.mouth_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for moving the wings @@ -1717,10 +1726,10 @@ >>> tux.cmd.wings_on(2) (2 movements) >>> tux.cmd.wings_on(2,5) (2 movements and speed=5) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS,\ - TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_WINGS_POSITION_COUNTER\ - ,0,(0.6*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS, \ + TUX_CMD_STRUCT_SUB_ON,count,speed,0) + self.parent.event.wait_status(DATAS_STATUS_WINGS_POSITION_COUNTER, \ + 0,(0.6*count)) #-------------------------------------------------------------------------- # Send a command to tux for moving the wings in free mode @@ -1755,7 +1764,8 @@ Example: >>> tux.cmd.wings_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux to spin to the left @@ -1775,9 +1785,10 @@ >>> tux.cmd.spinl_on(2) (count = 2) >>> tux.cmd.spinl_on(2,5) (count = 2 and speed = 5) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL,\ - TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER,0,(0.5*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL, \ + TUX_CMD_STRUCT_SUB_ON,count,speed,0) + self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER, \ + 0,(0.5*count)) #-------------------------------------------------------------------------- # Send a command to tux to spin to the left in free mode @@ -1812,7 +1823,8 @@ Example: >>> tux.cmd.spinl_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux to spin to the right @@ -1832,10 +1844,10 @@ >>> tux.cmd.spinr_on(2) (count = 2) >>> tux.cmd.spinr_on(2,5) (count = 2 and speed = 5) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR,\ - TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER,0\ - ,(0.5*count)) + self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR, \ + TUX_CMD_STRUCT_SUB_ON,count,speed,0) + self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER,0, \ + (0.5*count)) #-------------------------------------------------------------------------- # Send a command to tux to spin to the right in free mode @@ -1870,8 +1882,8 @@ Example: >>> tux.cmd.spinr_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR,TUX_CMD_STRUCT_SUB_OFF\ - ,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the IR on @@ -1895,8 +1907,8 @@ Example: >>> tux.cmd.ir_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_IR,TUX_CMD_STRUCT_SUB_OFF\ - ,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_IR, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for sending an IR code @@ -1912,8 +1924,8 @@ Example: >>> tux.cmd.ir_send(1,1) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_IR,\ - TUX_CMD_STRUCT_SUB_SEND,address,command,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_IR, \ + TUX_CMD_STRUCT_SUB_SEND,address,command,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the leds on @@ -1925,7 +1937,8 @@ Example: >>> tux.cmd.leds_on() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,TUX_CMD_STRUCT_SUB_ON,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS, \ + TUX_CMD_STRUCT_SUB_ON,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for blinking the leds @@ -1941,8 +1954,8 @@ Example: >>> tux.cmd.leds_blink(10,25) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,\ - TUX_CMD_STRUCT_SUB_BLINK,count,delay,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS, \ + TUX_CMD_STRUCT_SUB_BLINK,count,delay,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the leds off @@ -1954,8 +1967,8 @@ Example: >>> tux.cmd.leds_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,\ - TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the leds on during a specified time @@ -2004,7 +2017,8 @@ Example: >>> tux.cmd.ledl_on() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL,TUX_CMD_STRUCT_SUB_ON,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL, \ + TUX_CMD_STRUCT_SUB_ON,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the left led off @@ -2016,7 +2030,8 @@ Example: >>> tux.cmd.ledl_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the left led on during a specified time @@ -2066,7 +2081,8 @@ Example: >>> tux.cmd.ledr_on() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR,TUX_CMD_STRUCT_SUB_ON,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR, \ + TUX_CMD_STRUCT_SUB_ON,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the right led off @@ -2078,7 +2094,8 @@ Example: >>> tux.cmd.ledr_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the right led on during a specified @@ -2136,8 +2153,8 @@ >>> tux.cmd.sound_play(1) >>> tux.cmd.sound_play(1,0) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,\ - TUX_CMD_STRUCT_SUB_PLAY,index,volume,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND, \ + TUX_CMD_STRUCT_SUB_PLAY,index,volume,0) #-------------------------------------------------------------------------- # Send a command to tux for storing a sound collection in the memory flash @@ -2153,8 +2170,8 @@ Example: >>> tux.cmd.sound_storing(10) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,\ - TUX_CMD_STRUCT_SUB_STORING,number,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND, \ + TUX_CMD_STRUCT_SUB_STORING,number,0,0) #-------------------------------------------------------------------------- # Send a command to tux for indexing the sound @@ -2171,8 +2188,8 @@ Example: >>> tux.cmd.sound_store_index(0x00,0x04,0x00) """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,TUX_CMD_STRUCT_SUB_STORE_INDEX,\ - highAdd,middleAdd,lowAdd) + self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND, \ + TUX_CMD_STRUCT_SUB_STORE_INDEX,highAdd,middleAdd,lowAdd) #-------------------------------------------------------------------------- # Send a command to tux for testing the sound in tux @@ -2184,7 +2201,8 @@ Example: >>> tux.cmd.sound_test() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,TUX_CMD_STRUCT_SUB_TEST,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND, \ + TUX_CMD_STRUCT_SUB_TEST,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for the "ping-pong" test @@ -2213,7 +2231,8 @@ Example: >>> tux.cmd.sleep_on() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP,TUX_CMD_STRUCT_SUB_ON,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP, \ + TUX_CMD_STRUCT_SUB_ON,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for turning the sleep mode off @@ -2225,7 +2244,8 @@ Example: >>> tux.cmd.sleep_off() """ - self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP,TUX_CMD_STRUCT_SUB_OFF,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP, \ + TUX_CMD_STRUCT_SUB_OFF,0,0,0) #-------------------------------------------------------------------------- # Send a command to tux for selecting the "general" audio channel in @@ -2240,8 +2260,8 @@ >>> tux.cmd.audio_channel_general() """ self.no_ack=True - self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL,\ - TUX_CMD_STRUCT_SUB_CH_GENERAL,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL, \ + TUX_CMD_STRUCT_SUB_CH_GENERAL,0,0,0) self.no_ack=False #-------------------------------------------------------------------------- @@ -2256,8 +2276,8 @@ >>> tux.cmd.audio_channel_tts() """ self.no_ack=True - self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL,\ - TUX_CMD_STRUCT_SUB_CH_TTS,0,0,0) + self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL, \ + TUX_CMD_STRUCT_SUB_CH_TTS,0,0,0) self.no_ack=False #============================================================================== @@ -2430,8 +2450,8 @@ if status[4]==DATAS_STATUS_SOUND_COUNT: line=line+"Flash sounds count->" if status[4]==DATAS_STATUS_PONG: - line=line+"Pong-> Received : %d Remaining : %d Average : %.0f %s"\ - %(status[6],status[5],((status[6]*100)/(200-status[5])),'%') + line=line+"Pong-> Received : %d Remaining : %d Average : %.0f %s" \ + %(status[6],status[5],((status[6]*100)/(200-status[5])),'%') value_type=value_np #-- Write value if value_type==value_onoff: @@ -2458,14 +2478,14 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,\ - 999,DATA_STATUS,999,999,999,999,999,999,\ - 999,999,999,999,999) + data_to_match = (SOURCE_TUX,SS_DEFAULT,DATA_TP_RSP,999,DATA_STATUS, \ + 999,999,999,999,999,999,999,999,999,999,999) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(timeout) @@ -2495,8 +2515,8 @@ """ if not self.parent.daemon.connected: return 0 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_STATUS,DATA_STATUS,\ - 0,0,0,0,0,0,0,0,0,0,0) + data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_STATUS,DATA_STATUS, \ + 0,0,0,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) return self.rsp_status(DATA_STATUS) @@ -3313,14 +3333,14 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_SUB_DAEMON,SS_DEFAULT,DATA_TP_ACK_CMD,\ - 999,999,999,999,999,999,999,999,\ - 999,999,999,999,999) + data_to_match = (SOURCE_SUB_DAEMON,SS_DEFAULT,DATA_TP_ACK_CMD, \ + 999,999,999,999,999,999,999,999,999,999,999,999,999) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list, \ + cond_lock_mutex,returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(2) @@ -3343,14 +3363,15 @@ # create a list of frames to match data_to_match_list = [] # create and insert a frame to match - data_to_match = (SOURCE_SUB_DAEMON,SS_DEFAULT,DATA_TP_RSP,\ - SUBDATA_TP_INFO,DATA_INFO,999,999,999,999,999,999,\ - 999,999,999,999,999) + data_to_match = (SOURCE_SUB_DAEMON,SS_DEFAULT,DATA_TP_RSP, \ + SUBDATA_TP_INFO,DATA_INFO,999,999,999,999,999,999, \ + 999,999,999,999,999) data_to_match_list.append(data_to_match) # create empty frame returned returned_data = [] # insert theses settings in the lock list - self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) + self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex, + returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() cond_lock_mutex.wait(2) @@ -3380,8 +3401,8 @@ """ if not self.connected: return 2 - data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT,cmd,param1,\ - param2,param3,0,0,0,0,0,0,0,0) + data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT,cmd, + param1,param2,param3,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) return 0 @@ -3394,8 +3415,8 @@ """ if not self.connected: return 2 - data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_REQ,\ - SUBDATA_TP_INFO,req,param1,param2,param3,0,0,0,0,0,0,0,0) + data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_REQ, \ + SUBDATA_TP_INFO,req,param1,param2,param3,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) return self.rsp_info(req) @@ -3423,7 +3444,8 @@ Not a user function """ if not self.connected : return - self.last_ack=self.cmd_no_ack(SUB_D_CMD_STRUC_DISCONNECT_CLIENT_ME,0,0,0) + self.last_ack=self.cmd_no_ack(SUB_D_CMD_STRUC_DISCONNECT_CLIENT_ME, \ + 0,0,0) #-------------------------------------------------------------------------- # Kill tuxdaemon @@ -3460,10 +3482,11 @@ if name_length<11: add_name="".join( [' ' for i in range(11-name_length)] ) name=name+add_name - data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT,\ - SUB_D_CMD_STRUC_DEFINE_CLIENT_NAME,ord(name[0]),ord(name[1]),\ - ord(name[2]),ord(name[3]),ord(name[4]),ord(name[5]),ord(name[6]),\ - ord(name[7]),ord(name[8]),ord(name[9]),ord(name[10])) + data=(DEST_SUB_DAEMON,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT, \ + SUB_D_CMD_STRUC_DEFINE_CLIENT_NAME,ord(name[0]),ord(name[1]), \ + ord(name[2]),ord(name[3]),ord(name[4]),ord(name[5]), + ord(name[6]),ord(name[7]),ord(name[8]),ord(name[9]), + ord(name[10])) self.parent.sock.send("".join( [chr(x) for x in data] )) self.parent.my_name=name self.last_ack=self.cmd_ack() @@ -3615,8 +3638,8 @@ """ if not self.parent.daemon.connected: return (0,0,0,0,0) - data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_INFO,\ - TUX_REQ_INFO_VERSION,cpu_index,0,0,0,0,0,0,0,0,0,0) + data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_INFO, \ + TUX_REQ_INFO_VERSION,cpu_index,0,0,0,0,0,0,0,0,0,0) self.parent.sock.send("".join( [chr(x) for x in data] )) frame = self.parent.status.rsp_status(TUX_REQ_INFO_VERSION) if len(frame) > 0: @@ -3730,9 +3753,10 @@ tmp_tab=fp.read(9).split(':') current_tux_device[5]=int(tmp_tab[0],16) current_tux_device[6]=int(tmp_tab[1],16) - current_tux_device[0]="hw:%d,%d"%(current_tux_device[1],\ - current_tux_device[2]) - if ((current_tux_device[5]==0x03eb)and(current_tux_device[6]==0xff07)): + current_tux_device[0]="hw:%d,%d"%(current_tux_device[1], \ + current_tux_device[2]) + if ((current_tux_device[5]==0x03eb) and + (current_tux_device[6]==0xff07)): self.TUX_devices.append(current_tux_device) self.TUX_devices_count=self.TUX_devices_count+1 @@ -4109,8 +4133,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_SOUND_CONF,CMD_SOUNDCONF_REINIT,\ - usb_bus,usb_device,0,0) + self.send_command_to_tts(CMD_TYPE_SOUND_CONF,CMD_SOUNDCONF_REINIT, \ + usb_bus,usb_device,0,0) #-------------------------------------------------------------------------- # Stop alsa driver @@ -4119,7 +4143,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_SOUND_CONF,CMD_SOUNDCONF_STOP,0,0,0,0) + self.send_command_to_tts(CMD_TYPE_SOUND_CONF,CMD_SOUNDCONF_STOP, \ + 0,0,0,0) #-------------------------------------------------------------------------- # Select a speaker voice @@ -4265,9 +4290,9 @@ u = unicode(text,"utf-8") text_to_send = u.encode('latin-1','replace') text_length = len(text_to_send) - self.send_command_to_tts(CMD_TYPE_TTS, CMD_TTS_INSERT_PLAY_SPEECH,\ - (text_length & 0x0000FF00) >> 8, (text_length & 0x000000FF),\ - self.my_voice, self.my_pitch) + self.send_command_to_tts(CMD_TYPE_TTS, CMD_TTS_INSERT_PLAY_SPEECH, \ + (text_length & 0x0000FF00) >> 8, (text_length & 0x000000FF), \ + self.my_voice, self.my_pitch) self.parent.cmd.audio_channel_tts() self.sock.send(text_to_send) counter = 0 @@ -4363,7 +4388,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_DISCONNECT_CLIENT,0,0,0,0) + self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_DISCONNECT_CLIENT, \ + 0,0,0,0) #-------------------------------------------------------------------------- # Print the audio fifo state on tuxttsdaemon @@ -4372,7 +4398,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_PRINT_FIFO_STATE,0,0,0,0) + self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_PRINT_FIFO_STATE, \ + 0,0,0,0) #-------------------------------------------------------------------------- # Print informations of tux sound cards plugged @@ -4381,7 +4408,8 @@ """ Not a user function """ - self.send_command_to_tts(CMD_TYPE_DAEMON,CMD_DAEMON_PRINT_TUX_SOUND_CARDS,0,0,0,0) + self.send_command_to_tts(CMD_TYPE_DAEMON, \ + CMD_DAEMON_PRINT_TUX_SOUND_CARDS,0,0,0,0) #-------------------------------------------------------------------------- # Kill tuxttsdaemon @@ -4455,12 +4483,12 @@ c_header='' my_doc='' for i in range(80-len(indent)): c_header=c_header+'-' - my_doc='%s%s) Class : %s (%s)<br>'%(my_doc,class_num,\ - class_name,str(type(class_obj))[8:-2]) - self.header_doc=self.header_doc+indent+'<a href="#%s">'%(class_num)\ - +my_doc+'</a>' - my_doc=indent+'<a name=%s></a>'%(class_num)+self.h_class_b+\ - my_doc+self.h_class_e + my_doc='%s%s) Class : %s (%s)<br>'%(my_doc,class_num, \ + class_name,str(type(class_obj))[8:-2]) + self.header_doc=self.header_doc+indent+'<a href="#%s">'%(class_num) \ + +my_doc+'</a>' + my_doc=indent+'<a name=%s></a>'%(class_num)+self.h_class_b+ \ + my_doc+self.h_class_e for line in test: if line.find('Functions list')!=-1: break @@ -4477,8 +4505,9 @@ if funct_ok: line=line[line.rfind('.')+1:] i=i+1 - my_doc=my_doc+self.parse_function("%s.%d"%(class_num,i),class_name+'.'+line,\ - getattr(class_obj,line).__doc__,indent+' ') + my_doc=my_doc+self.parse_function("%s.%d"%(class_num,i), \ + class_name+'.'+line, getattr(class_obj,line).__doc__, \ + indent+' ') if line.find('Functionslist')!=-1: funct_ok=True # sub class @@ -4486,8 +4515,9 @@ if line.find('asclass')!=-1: line=line[1:line[1:].find('"')+1] i=i+1 - my_doc=my_doc+self.parse_class("%s.%d"%(class_num,i),getattr(class_obj,line),\ - class_name+'.'+line,getattr(class_obj,line).__doc__,indent+' ') + my_doc=my_doc+self.parse_class("%s.%d"%(class_num,i), \ + getattr(class_obj,line),class_name+'.'+line, \ + getattr(class_obj,line).__doc__,indent+' ') return my_doc #-------------------------------------------------------------------------- @@ -4502,10 +4532,10 @@ my_doc='' for i in range(80-len(indent)): c_header=c_header+'-' my_doc='%s%s)\tFunction : %s<br>'%(my_doc,funct_num,funct_name) - self.header_doc=self.header_doc+indent+'<a href="#%s">'%(funct_num)\ - +my_doc+'</a>' - my_doc=indent+'<a name=%s></a>'%(funct_num)+self.h_funct_b+\ - my_doc+self.h_funct_e + self.header_doc=self.header_doc+indent+'<a href="#%s">'%(funct_num) \ + +my_doc+'</a>' + my_doc=indent+'<a name=%s></a>'%(funct_num)+self.h_funct_b+ \ + my_doc+self.h_funct_e for line in test: my_doc=my_doc+indent+line[4:]+'<br>' return my_doc @@ -4535,12 +4565,15 @@ </HEAD>' documentation=documentation+'<body><pre>' documentation=documentation+self.h_titre_b+\ - 'DOCUMENTATION OF TUXDROID PYTHON API %s'%(api_version)+self.h_titre_e+'<br>' + 'DOCUMENTATION OF TUXDROID PYTHON API %s'%(api_version)+ \ + self.h_titre_e+'<br>' documentation=documentation+'\n' - self.header_doc='<br>'+self.h_class_b+'Table of content :'+self.h_class_e+'<br><br>' + self.header_doc='<br>'+self.h_class_b+'Table of content :'+ \ + self.h_class_e+'<br><br>' body_doc=self.parse_class('1',self.parent,'tux',main_class,'') self.header_doc=self.header_doc+'<br><br>' - documentation=documentation+self.header_doc+body_doc+'</pre></body></html>' + documentation=documentation+self.header_doc+body_doc+ \ + '</pre></body></html>' f=open(doc_path,'w') f.write(documentation) f.close() @@ -4572,9 +4605,10 @@ Example: >>> tux.misc.simulate_remote_key(K_OK) """ - tmp_tcp_data = (chr(SOURCE_TUX),chr(0),chr(DATA_TP_RSP),\ - chr(SUBDATA_TP_STATUS),chr(DATAS_STATUS_IR_CODE),chr(key),chr(0),\ - chr(0),chr(0),chr(0),chr(0),chr(0),chr(0),chr(0),chr(0),chr(0)) + tmp_tcp_data = (chr(SOURCE_TUX),chr(0),chr(DATA_TP_RSP), \ + chr(SUBDATA_TP_STATUS),chr(DATAS_STATUS_IR_CODE), \ + chr(key),chr(0),chr(0),chr(0),chr(0),chr(0),chr(0), \ + chr(0),chr(0),chr(0),chr(0)) self.parent.tcp_data_fifo_lock_mutex.acquire() self.parent.tcp_data_fifo_lock.append(tmp_tcp_data) |
From: jaguarondi <c2m...@c2...> - 2007-06-14 20:58:35
|
Author: jaguarondi Date: 2007-06-14 22:58:04 +0200 (Thu, 14 Jun 2007) New Revision: 375 Modified: daemon/trunk/libs/USBDaemon_command_tux.c Log: * Made all connection functions static. * Need to disconnect prior to connect or wakeup in case those commands are issued when the dongle is already handling an RF connection. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-14 13:16:01 UTC (rev 374) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-14 20:58:04 UTC (rev 375) @@ -43,15 +43,15 @@ /*_____________________ F U N C T I O N S __________________________________*/ -void tux_connection(unsigned char const data[], unsigned char result[]); -int disconnect_from_tux(void); -int connect_to_tux(uint16_t id); -int id_request(uint16_t *id); -int id_lookup(uint16_t *id); -int change_id(uint16_t id); -int wakeup_tux(const uint16_t id); -int avoid_wifi_channel(unsigned char wifi_channel); -int random_tux_connection(void); +static void tux_connection(unsigned char const data[], unsigned char result[]); +static int disconnect_from_tux(void); +static int connect_to_tux(uint16_t id); +static int id_request(uint16_t *id); +static int id_lookup(uint16_t *id); +static int change_id(uint16_t id); +static int wakeup_tux(const uint16_t id); +static int avoid_wifi_channel(unsigned char wifi_channel); +static int random_tux_connection(void); static void sub_daemon_cmd_struct(unsigned char const data[], unsigned char result[], @@ -806,7 +806,7 @@ /** * tux connection commands */ -void tux_connection(unsigned char const data[], unsigned char result[]) +static void tux_connection(unsigned char const data[], unsigned char result[]) { result[0] = data[0]; switch (data[0]) @@ -970,7 +970,7 @@ * * \return 0 if successful, -1 otherwise */ -int disconnect_from_tux(void) +static int disconnect_from_tux(void) { if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_DISCONNECT, 0, 0) == USB_FRAME_SIZE) @@ -988,8 +988,12 @@ * * \return 0 if successful, -1 otherwise */ -int connect_to_tux(const uint16_t id) +static int connect_to_tux(const uint16_t id) { + /* Disconnecting first is necessary in case tux is connected */ + if (disconnect_from_tux() < 0) + return -1; + if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_CONNECT, (uint8_t)(id>>8), (uint8_t)id) == USB_FRAME_SIZE) return 0; @@ -1004,7 +1008,7 @@ * * \return 0 if successful, -1 otherwise */ -int random_tux_connection(void) +static int random_tux_connection(void) { uint16_t id; if (id_lookup((uint16_t *)&id) < 0) @@ -1023,7 +1027,7 @@ * \return 0 if successful, -1 otherwise */ #define ID_REQUEST_TIMEOUT 5 /* 100ms time unit */ -int id_request(uint16_t *id) +static int id_request(uint16_t *id) { int timeout_cnt = 0; @@ -1063,7 +1067,7 @@ * \return 0 if successful, -1 otherwise */ #define ID_LOOKUP_TIMEOUT 50 /* 100ms time unit */ -int id_lookup(uint16_t *id) +static int id_lookup(uint16_t *id) { int timeout_cnt = 0; @@ -1107,7 +1111,7 @@ * \return 0 if successful, -1 otherwise */ #define CHANGE_ID_TIMEOUT 70 -int change_id(const uint16_t id) +static int change_id(const uint16_t id) { int timeout_cnt = 0; @@ -1153,8 +1157,12 @@ * * \return 0 if successful, -1 otherwise */ -int wakeup_tux(const uint16_t id) +static int wakeup_tux(const uint16_t id) { + /* Disconnecting first is necessary in case tux is connected */ + if (disconnect_from_tux() < 0) + return -1; + /* Send the wakeup command then a connection with the given id */ if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_WAKEUP, 0, 0) != USB_FRAME_SIZE) @@ -1179,7 +1187,7 @@ * * \return 0 if successful, -1 otherwise */ -int avoid_wifi_channel(unsigned char wifi_channel) +static int avoid_wifi_channel(unsigned char wifi_channel) { /* * Conversion of the lower and higher frequencies of a wifi channel into |
From: jaguarondi <c2m...@c2...> - 2007-06-14 13:16:07
|
Author: jaguarondi Date: 2007-06-14 15:16:01 +0200 (Thu, 14 Jun 2007) New Revision: 374 Modified: firmware/tuxcore/trunk/global.h firmware/tuxcore/trunk/motors.c Log: * Just updated a few comments in global.h & motors.c. Modified: firmware/tuxcore/trunk/global.h =================================================================== --- firmware/tuxcore/trunk/global.h 2007-06-13 19:55:44 UTC (rev 373) +++ firmware/tuxcore/trunk/global.h 2007-06-14 13:16:01 UTC (rev 374) @@ -146,10 +146,10 @@ #define MOT_IMOUTH_MK _BV(PD0) /* inverted mouth motor (backward) */ #define MOT_IMOUTH_PT PORTD #define MOT_IMOUTH_DDR DDRD -#define MOT_IEYES_MK _BV(PD1) /* eyes motor (forward) */ +#define MOT_IEYES_MK _BV(PD1) /* inverted eyes motor (backward) */ #define MOT_IEYES_PT PORTD #define MOT_IEYES_DDR DDRD -#define MOT_EYES_MK _BV(PD0) /* inverted eyes motor (backward) */ +#define MOT_EYES_MK _BV(PD0) /* eyes motor (forward) */ #define MOT_EYES_PT PORTD #define MOT_EYES_DDR DDRD #define MOT_SPIN_R_MK _BV(PB2) /* spin motor, turn on the right */ Modified: firmware/tuxcore/trunk/motors.c =================================================================== --- firmware/tuxcore/trunk/motors.c 2007-06-13 19:55:44 UTC (rev 373) +++ firmware/tuxcore/trunk/motors.c 2007-06-14 13:16:01 UTC (rev 374) @@ -129,7 +129,7 @@ /** \brief Mouth position interrupt - \ingroup moth + \ingroup mouth This interrupt stops the mouth when the desired number of movements have been executed. In order to stop the mouth quickly and block the motor, we need to @@ -148,11 +148,11 @@ { if (~PSW_MOUTH_PIN & PSW_MOUTH_MK) /* we only count when the switch is pushed, not released */ { - if (~PSW_MOUTH_PIN & PSW_MOUTH_O_MK) /* we only count when the switch is pushed, not released */ - if (mouth_pos == CLOSE) + if (~PSW_MOUTH_PIN & PSW_MOUTH_O_MK) + if (mouth_pos == CLOSE) /* XXX can we delete this line? */ mouth_pos = OPEN; - if (~PSW_MOUTH_PIN & PSW_MOUTH_C_MK) /* we only count when the switch is pushed, not released */ - if (mouth_pos == OPEN) + if (~PSW_MOUTH_PIN & PSW_MOUTH_C_MK) + if (mouth_pos == OPEN) /* XXX can we delete this line? */ mouth_pos = CLOSE; if (mouthPosCnt) { |
From: neimad <c2m...@c2...> - 2007-06-13 19:56:12
|
Author: neimad Date: 2007-06-13 21:55:44 +0200 (Wed, 13 Jun 2007) New Revision: 373 Modified: daemon/trunk/libs/USBDaemon_usb_enum.c Log: * Ahem, should have re-read before committing: usb_close_TuxDroid() was unnecessarily complicated (leftover from previous version). Modified: daemon/trunk/libs/USBDaemon_usb_enum.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-13 19:47:05 UTC (rev 372) +++ daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-13 19:55:44 UTC (rev 373) @@ -103,16 +103,12 @@ */ static void usb_close_TuxDroid(usb_dev_handle *tux_hdl) { - int err1, err2; - - err1 = usb_release_interface(tux_hdl, TUX_INTERFACE); - if (err1) + if (usb_release_interface(tux_hdl, TUX_INTERFACE) < 0) log_warning("failed releasing USB interface: %s (%d)", strerror(errno), errno); - err2 = usb_close(tux_hdl); - if (err1) - log_warning("failed closing USB device: %s (%d)", + if (usb_close(tux_hdl) < 0) + log_warning("failed closing USB device: %s (%d)", strerror(errno), errno); } |
From: neimad <c2m...@c2...> - 2007-06-13 19:47:43
|
Author: neimad Date: 2007-06-13 21:47:05 +0200 (Wed, 13 Jun 2007) New Revision: 372 Modified: daemon/trunk/libs/USBDaemon_usb_enum.c daemon/trunk/libs/USBDaemon_usb_enum.h daemon/trunk/main.c Log: * Added missing release and closing of USB device/interface: this is done in usb_release_TuxDroid(). * Since I found that the name usb_release_TuxDroid() didn't match too well usb_init_TuxDroid(), I used the metaphor of capturing and releasing a wild animal and renamed the latter usb_capture_TuxDroid() ;-) Modified: daemon/trunk/libs/USBDaemon_usb_enum.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-12 05:21:55 UTC (rev 371) +++ daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-13 19:47:05 UTC (rev 372) @@ -34,8 +34,8 @@ #include "USBDaemon_pidfile.h" /*_____________________ V A R I A B L E S __________________________________*/ -usb_dev_handle *tux_handle; -struct usb_device *tux_device; +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 __________________________________*/ @@ -97,13 +97,34 @@ return tux_hdl; } -/************************************************************************ */ -/* usb_init_TuxDroid() */ +/** + * Close a Tux droid previously opened with usb_open_TuxDroid(). + */ +static void usb_close_TuxDroid(usb_dev_handle *tux_hdl) +{ + int err1, err2; -/************************************************************************ */ -int usb_init_TuxDroid(void) + err1 = usb_release_interface(tux_hdl, TUX_INTERFACE); + if (err1) + log_warning("failed releasing USB interface: %s (%d)", + strerror(errno), errno); + + err2 = usb_close(tux_hdl); + if (err1) + 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 { @@ -147,3 +168,17 @@ 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; +} Modified: daemon/trunk/libs/USBDaemon_usb_enum.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.h 2007-06-12 05:21:55 UTC (rev 371) +++ daemon/trunk/libs/USBDaemon_usb_enum.h 2007-06-13 19:47:05 UTC (rev 372) @@ -75,6 +75,7 @@ /*_____________________ F U N C T I O N S __________________________________*/ extern struct usb_device *usb_find_TuxDroid(void); -extern int usb_init_TuxDroid(void); +extern int usb_capture_TuxDroid(void); +extern void usb_release_TuxDroid(void); #endif Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-12 05:21:55 UTC (rev 371) +++ daemon/trunk/main.c 2007-06-13 19:47:05 UTC (rev 372) @@ -183,6 +183,8 @@ raise_privileges(); + usb_release_TuxDroid(); + if (daemonized && remove_pid()) log_error("Could not delete PID file"); @@ -390,8 +392,7 @@ usb_init(); #endif - /* open USB handler and setuid nobody */ - if (!usb_init_TuxDroid()) + if (!usb_capture_TuxDroid()) exit(1); if (drop_privileges() < 0) |
From: neimad <c2m...@c2...> - 2007-06-12 05:21:58
|
Author: neimad Date: 2007-06-12 07:21:55 +0200 (Tue, 12 Jun 2007) New Revision: 371 Modified: daemon/trunk/libs/USBDaemon_tcp_server.c daemon/trunk/libs/USBDaemon_tcp_server.h daemon/trunk/main.c Log: * Split initialization and event loop of daemon. Modified: daemon/trunk/libs/USBDaemon_tcp_server.c =================================================================== --- daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-12 04:56:15 UTC (rev 370) +++ daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-12 05:21:55 UTC (rev 371) @@ -71,18 +71,19 @@ } /** - * Server's event loop + * Server initialization. + * Opens and binds the TCP socket. + * + * \return 0 if successful, -1 otherwise */ -void tcp_server_loop(void) +int tcp_server_init(void) { -#define TIMEOUT ((struct timeval){ .tv_sec = 0, .tv_usec = 50000 }) - tcp_frame_t datas_recv; int val; if ((tcp_server_handle = socket(AF_INET, SOCK_STREAM, 0)) < 0) { log_error("TCP socket: socket creation failed: %m"); - return; + return -1; } val = 1; @@ -90,28 +91,41 @@ &val, sizeof(val)) < 0) { /* Don't need to quit on this one. */ - log_error("TCP socket: setsockopt failed: %m"); + log_warning("TCP socket: setsockopt failed: %m"); } memset(&tcp_server_sockaddr, 0, sizeof(tcp_server_sockaddr)); tcp_server_sockaddr.sin_family = AF_INET; tcp_server_sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); tcp_server_sockaddr.sin_port = htons(TUX_SERVER_PORT); + if (bind (tcp_server_handle, (struct sockaddr *)&tcp_server_sockaddr, sizeof(tcp_server_sockaddr)) < 0) { log_error("TCP socket: bind failed: %m"); - exit(2); + return -1; } + if (listen(tcp_server_handle, 5) < 0) { log_error("TCP socket: listen failed: %m"); - return; + return -1; } log_info("TCP socket: opened"); tux_tcp_status = TUX_TCP_STATUS_UP; + return 0; +} + +/** + * Server's event loop + */ +void tcp_server_loop(void) +{ +#define TIMEOUT ((struct timeval){ .tv_sec = 0, .tv_usec = 50000 }) + tcp_frame_t datas_recv; + while (tcp_server_handle >= 0) { struct timeval timeout = TIMEOUT; Modified: daemon/trunk/libs/USBDaemon_tcp_server.h =================================================================== --- daemon/trunk/libs/USBDaemon_tcp_server.h 2007-06-12 04:56:15 UTC (rev 370) +++ daemon/trunk/libs/USBDaemon_tcp_server.h 2007-06-12 05:21:55 UTC (rev 371) @@ -59,6 +59,7 @@ extern client_name_t tcp_clients_name[]; /*_____________________ F U N C T I O N S __________________________________*/ +extern int tcp_server_init(void); extern void tcp_server_loop(void); extern void tcp_server_send_raw(const tcp_frame_t data); extern void tcp_server_send_raw_to_client(int client_index, Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-12 04:56:15 UTC (rev 370) +++ daemon/trunk/main.c 2007-06-12 05:21:55 UTC (rev 371) @@ -397,7 +397,9 @@ if (drop_privileges() < 0) exit(1); - /* Main loop */ + if (tcp_server_init() < 0) + exit(1); + tcp_server_loop(); exit(0); |
From: neimad <c2m...@c2...> - 2007-06-12 04:57:07
|
Author: neimad Date: 2007-06-12 06:56:15 +0200 (Tue, 12 Jun 2007) New Revision: 370 Modified: daemon/trunk/main.c Log: * Handle SIGTERM to exit cleanly on shutdown (gentle signal sent by init scripts before the violent SIGKILL). Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-12 04:46:12 UTC (rev 369) +++ daemon/trunk/main.c 2007-06-12 04:56:15 UTC (rev 370) @@ -328,6 +328,7 @@ log_level_t log_level = LOG_LEVEL_INFO; /* On exiting */ + signal(SIGTERM, quit_handler); signal(SIGINT, quit_handler); /* Program arguments */ |
From: neimad <c2m...@c2...> - 2007-06-12 04:46:17
|
Author: neimad Date: 2007-06-12 06:46:12 +0200 (Tue, 12 Jun 2007) New Revision: 369 Modified: daemon/trunk/main.c Log: * Nicer usage() function. Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-11 16:27:12 UTC (rev 368) +++ daemon/trunk/main.c 2007-06-12 04:46:12 UTC (rev 369) @@ -302,18 +302,18 @@ /************************************************************************ */ static void usage(void) { - printf("usage : tuxdaemon [options]\n"); - printf("options:\n"); - printf(" -d start in daemon mode\n"); - printf(" -lsys log to syslog\n"); - printf(" -ltux log to /var/log/tuxdaemon\n"); - printf(" -lstd log to stdout & stderr\n"); - printf(" -v view in shell (deprecated, use -lstd instead)\n"); - printf(" -debug start in debug mode\n"); - printf(" -st show the structure of the usb frames\n"); - printf(" -sr show all raw status\n"); - printf(" -si show only invalid raw status\n"); - printf(" -h show this usage list\n"); + printf("usage : tuxdaemon [options]\n" + "options:\n" + " -d start in daemon mode\n" + " -lsys log to syslog\n" + " -ltux log to /var/log/tuxdaemon\n" + " -lstd log to stdout & stderr\n" + " -v view in shell (deprecated, use -lstd instead)\n" + " -debug start in debug mode\n" + " -st show the structure of the usb frames\n" + " -sr show all raw status\n" + " -si show only invalid raw status\n" + " -h show this usage list\n"); } /************************************************************************ */ |
From: jaguarondi <c2m...@c2...> - 2007-06-11 16:27:18
|
Author: jaguarondi Date: 2007-06-11 18:27:12 +0200 (Mon, 11 Jun 2007) New Revision: 368 Modified: api/python/trunk/tuxapi_class.py api/python/trunk/tuxapi_const.py Log: * Added all connection commands in the python api. There's still some firmware * issues that should be fixed before we can test them thoroughly. Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-11 16:07:01 UTC (rev 367) +++ api/python/trunk/tuxapi_class.py 2007-06-11 16:27:12 UTC (rev 368) @@ -37,6 +37,7 @@ #============================================================================== api_version ="0.2.2" +TCPIP_FRAME_LENGTH = 16 #============================================================================== # TUXTCPCommunicator class @@ -54,6 +55,7 @@ functions "status" as class : Class which manages the request of a status + "connect" as class : Class which manages connection functions "sys" as class : Class which manages the system functions "tts" as class : Class which manages the text to speech @@ -93,6 +95,7 @@ self.tcp_data_fifo_event_mutex = threading.Lock() self.event=TUXevent(self) self.cmd=TUXcmd(self) + self.connect=TUXconnect(self) self.sys=TUXsys(self) self.daemon=TUXdaemon(self) self.sdaemon=self.daemon @@ -458,7 +461,180 @@ """ self.daemon.disconnect() +#============================================================================== +# TUXTCPCommunicator - connect - class +#============================================================================== +class TUXconnect(object): + """Class which manages connection functions + """ + #-------------------------------------------------------------------------- + # Constructor of the class + #-------------------------------------------------------------------------- + def __init__(self,parent): + """ + Constructor of the class + """ + self.parent=parent + + #-------------------------------------------------------------------------- + # Send a connection command and wait for the result + #-------------------------------------------------------------------------- + def tux_connection(self, connection_command, connection_args=[]): + """ + """ + if not self.parent.daemon.connected: + return 0 + data=[DEST_TUX, SD_DEFAULT, USB_CONNECTION_CMD, 0, connection_command] + data.extend(connection_args) + if len(data) > TCPIP_FRAME_LENGTH: + return False + # Fill up the end of the frame with 0 + data.extend([0] * (TCPIP_FRAME_LENGTH - len(data))) + self.parent.sock.send("".join( [chr(x) for x in data] )) + return self.parent.status.rsp_status(connection_command, timeout=5) + + #-------------------------------------------------------------------------- + # Disconnect from tux + #-------------------------------------------------------------------------- + def disconnect_from_tux(self): + """Disconnect from tux + """ + ack_frame = self.tux_connection(TUX_CONNECTION_DISCONNECT) + if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: + return False + + return True + + #-------------------------------------------------------------------------- + # Connect to a tux by its ID + #-------------------------------------------------------------------------- + def connect_to_tux(self, id): + """Connect to a tux by its ID + """ + # 0 is an invalid id and 0xFFFF is reserved + assert 0 < id < 0xFFFF + id_msb = id >> 8 + id_lsb = id & 0xFF + ack_frame = self.tux_connection(TUX_CONNECTION_CONNECT, + [id_msb, id_lsb]) + if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: + return False + + return True + + #-------------------------------------------------------------------------- + # Connect to the first tux discovered + #-------------------------------------------------------------------------- + def random_connect_to_tux(self): + """Connect to the first tux discovered + + Catch any disconnected tux, request it's ID and connect to it. + + """ + ack_frame = self.tux_connection(TUX_CONNECTION_RANDOM) + if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: + return False + + return True + + #-------------------------------------------------------------------------- + # Get the ID of the first disconnected tux which is discoverred + #-------------------------------------------------------------------------- + def id_request(self): + """Get the ID of tux currently connected + """ + ack_frame = self.tux_connection(TUX_CONNECTION_ID_REQUEST) + if ack_frame and ord(ack_frame[5]) == TUX_CONNECTION_ACK: + return (ord(ack_frame[6])*256) + ord(ack_frame[7]) + + return False + + #-------------------------------------------------------------------------- + # Get the ID of the first disconnected tux which is discoverred + #-------------------------------------------------------------------------- + def id_lookup(self): + """Get the ID of the first disconnected tux which is discoverred + + The first disconnected tux that will detect this command will reply + with it's ID and disconnect immediately. You can then connect to + that tux with the ID you just got. + + In order to get the ID's of more than one disconnected tux, you have + to issue this command multiple times until you don't get any new ID. + """ + ack_frame = self.tux_connection(TUX_CONNECTION_ID_LOOKUP) + if ack_frame and ord(ack_frame[5]) == TUX_CONNECTION_ACK: + return (ord(ack_frame[6])*256) + ord(ack_frame[7]) + + return False + + #-------------------------------------------------------------------------- + # Changes the ID of a disconnected tux + #-------------------------------------------------------------------------- + def change_id(self, id): + """Changes the ID of a disconnected tux + + You have to push on the head button of tux for XXX seconds while + sending this command in order to validate the ID change request, this + in order to avoid stealing a tux too easily. + """ + assert 0 < id < 0xFFFF + id_msb = id >> 8 + id_lsb = id % 256 + ack_frame = self.tux_connection(TUX_CONNECTION_CHANGE_ID, + [id_msb, id_lsb]) + if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: + return False + + return True + + #-------------------------------------------------------------------------- + # Set tux in sleep mode + #-------------------------------------------------------------------------- + def sleep(self): + """Set tux in sleep mode + """ + ack_frame = self.tux_connection(TUX_CONNECTION_SLEEP) + if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: + return False + + return True + + #-------------------------------------------------------------------------- + # Wake-up a tux if it's in sleep mode. + #-------------------------------------------------------------------------- + def wakeup(self, id): + """Wake-up a tux if it's in sleep mode. + """ + assert 0 < id < 0xFFFF + id_msb = id >> 8 + id_lsb = id % 256 + ack_frame = self.tux_connection(TUX_CONNECTION_WAKEUP, + [id_msb, id_lsb]) + if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: + return False + + return True + + #-------------------------------------------------------------------------- + # Configure the RF module to avoid a given wifi channel + #-------------------------------------------------------------------------- + def avoid_wifi(self, channel): + """Configure the RF module to avoid a given wifi channel + + Channels from 1 to 14 are valid wifi channels. Set the wifi channel to + 0 to disable channel avoidance and use the complete range of + frequencies. + """ + ack_frame = self.tux_connection(TUX_CONNECTION_WIRELESS_CHANNEL, + [channel]) + if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: + return False + + return True + + #============================================================================== # TUXTCPCommunicator - sys - class #============================================================================== @@ -2273,7 +2449,7 @@ #-------------------------------------------------------------------------- # wait a specified response status #-------------------------------------------------------------------------- - def rsp_status(self,DATA_STATUS): + def rsp_status(self, DATA_STATUS, timeout=2): """ Not a user function """ @@ -2292,7 +2468,7 @@ self.parent._insert_lock_in_list(data_to_match_list,cond_lock_mutex,returned_data) # wait the lock has unblocked. With a time-out cond_lock_mutex.acquire() - cond_lock_mutex.wait(2) + cond_lock_mutex.wait(timeout) cond_lock_mutex.release() # returns if len(returned_data) == 0: Modified: api/python/trunk/tuxapi_const.py =================================================================== --- api/python/trunk/tuxapi_const.py 2007-06-11 16:07:01 UTC (rev 367) +++ api/python/trunk/tuxapi_const.py 2007-06-11 16:27:12 UTC (rev 368) @@ -157,6 +157,22 @@ DATAS_STATUS_SOUND_COUNT = 0x23 DATAS_STATUS_PONG = 0x24 +# Tux connection commands +TUX_CONNECTION_DISCONNECT = 1 +TUX_CONNECTION_CONNECT = 2 +TUX_CONNECTION_RANDOM = 3 +TUX_CONNECTION_ID_REQUEST = 4 +TUX_CONNECTION_ID_LOOKUP = 5 +TUX_CONNECTION_CHANGE_ID = 6 +TUX_CONNECTION_SLEEP = 7 +TUX_CONNECTION_WAKEUP = 8 +TUX_CONNECTION_WIRELESS_CHANNEL = 9 + +# Tux connection command ack +TUX_CONNECTION_NACK = 0 +TUX_CONNECTION_ACK = 1 +TUX_CONNECTION_NOTFOUND = 2 + # Datas TuxDroid DATAS_STATUS_DONGLE = 0x00 DATAS_STATUS_RF = 0x01 @@ -189,6 +205,7 @@ DATA_TP_RSP = 0x03 DATA_TP_ACK_CMD = 0x04 DATA_TP_ACK_DP = 0x05 +USB_CONNECTION_CMD = 0x06 # Sub data types SUBDATA_TP_RAW = 0x01 SUBDATA_TP_STRUCT = 0x02 |
From: jaguarondi <c2m...@c2...> - 2007-06-11 16:07:35
|
Author: jaguarondi Date: 2007-06-11 18:07:01 +0200 (Mon, 11 Jun 2007) New Revision: 367 Modified: daemon/trunk/libs/USBDaemon_command_tux.c Log: * Fixed indentation of the blocks within the switch statement * Added the correct body of the wakeup function Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-10 08:55:44 UTC (rev 366) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-11 16:07:01 UTC (rev 367) @@ -49,7 +49,7 @@ int id_request(uint16_t *id); int id_lookup(uint16_t *id); int change_id(uint16_t id); -int wakeup_tux(void); +int wakeup_tux(const uint16_t id); int avoid_wifi_channel(unsigned char wifi_channel); int random_tux_connection(void); @@ -818,54 +818,53 @@ result[1] = TUX_CONNECTION_NACK; break; case TUX_CONNECTION_CONNECT: - { - union_uint16_t id; - id.b[1] = data[1]; - id.b[0] = data[2]; - printf("coucou\n"); - if (connect_to_tux(id.w) >= 0) - result[1] = TUX_CONNECTION_ACK; - else - result[1] = TUX_CONNECTION_NACK; + { + union_uint16_t id; + id.b[1] = data[1]; + id.b[0] = data[2]; + if (connect_to_tux(id.w) >= 0) + result[1] = TUX_CONNECTION_ACK; + else + result[1] = TUX_CONNECTION_NACK; + } break; - } case TUX_CONNECTION_ID_REQUEST: - { - union_uint16_t id; - if (id_request((uint16_t *)&id) >= 0) { - result[1] = TUX_CONNECTION_ACK; - result[2] = id.b[1]; /* MSB */ - result[3] = id.b[0]; /* LSB */ + union_uint16_t id; + if (id_request((uint16_t *)&id) >= 0) + { + result[1] = TUX_CONNECTION_ACK; + result[2] = id.b[1]; /* MSB */ + result[3] = id.b[0]; /* LSB */ + } + else + result[1] = TUX_CONNECTION_NACK; } - else - result[1] = TUX_CONNECTION_NACK; break; - } case TUX_CONNECTION_ID_LOOKUP: - { - union_uint16_t id; - if (id_lookup((uint16_t *)&id) >= 0) { - result[1] = TUX_CONNECTION_ACK; - result[2] = id.b[1]; /* MSB */ - result[3] = id.b[0]; /* LSB */ + union_uint16_t id; + if (id_lookup((uint16_t *)&id) >= 0) + { + result[1] = TUX_CONNECTION_ACK; + result[2] = id.b[1]; /* MSB */ + result[3] = id.b[0]; /* LSB */ + } + else + result[1] = TUX_CONNECTION_NACK; } - else - result[1] = TUX_CONNECTION_NACK; break; - } case TUX_CONNECTION_CHANGE_ID: - { - union_uint16_t id; - id.b[0] = data[2]; /* LSB */ - id.b[1] = data[1]; /* MSB */ - if (change_id(id.w) >= 0) - result[1] = TUX_CONNECTION_ACK; - else - result[1] = TUX_CONNECTION_NACK; + { + union_uint16_t id; + id.b[0] = data[2]; /* LSB */ + id.b[1] = data[1]; /* MSB */ + if (change_id(id.w) >= 0) + result[1] = TUX_CONNECTION_ACK; + else + result[1] = TUX_CONNECTION_NACK; + } break; - } case TUX_CONNECTION_SLEEP: if (send_usb_tux_cmd(SLEEP_CMD, 0, SLEEP_MODE, 0) == ACK_CMD_OK) result[1] = TUX_CONNECTION_ACK; @@ -873,10 +872,15 @@ result[1] = TUX_CONNECTION_NACK; break; case TUX_CONNECTION_WAKEUP: - if (wakeup_tux() >= 0) - result[1] = TUX_CONNECTION_ACK; - else - result[1] = TUX_CONNECTION_NACK; + { + union_uint16_t id; + id.b[0] = data[2]; /* LSB */ + id.b[1] = data[1]; /* MSB */ + if (wakeup_tux(id.w) >= 0) + result[1] = TUX_CONNECTION_ACK; + else + result[1] = TUX_CONNECTION_NACK; + } break; case TUX_CONNECTION_RANDOM: if (random_tux_connection() >= 0) @@ -1103,7 +1107,7 @@ * \return 0 if successful, -1 otherwise */ #define CHANGE_ID_TIMEOUT 70 -int change_id(uint16_t id) +int change_id(const uint16_t id) { int timeout_cnt = 0; @@ -1149,10 +1153,14 @@ * * \return 0 if successful, -1 otherwise */ -int wakeup_tux(void) +int wakeup_tux(const uint16_t id) { - if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, - USB_TUX_CONNECTION_ID_LOOKUP, 0, 0) == USB_FRAME_SIZE) + /* Send the wakeup command then a connection with the given id */ + if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_WAKEUP, + 0, 0) != USB_FRAME_SIZE) + return -1; + if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, USB_TUX_CONNECTION_CONNECT, + (uint8_t)(id>>8), (uint8_t)id) == USB_FRAME_SIZE) return 0; else return -1; |
From: neimad <c2m...@c2...> - 2007-06-10 08:55:50
|
Author: neimad Date: 2007-06-10 10:55:44 +0200 (Sun, 10 Jun 2007) New Revision: 366 Modified: daemon/trunk/libs/USBDaemon_globals.h daemon/trunk/main.c Log: * Fixed type of daemon_pid: pid_t instead of unsigned short. Also use the pid returned by write_pid() instead of calling getpid() again. The two-byte masking trick performed in sub_daemon_req_info() was left unchanged. Modified: daemon/trunk/libs/USBDaemon_globals.h =================================================================== --- daemon/trunk/libs/USBDaemon_globals.h 2007-06-10 08:32:03 UTC (rev 365) +++ daemon/trunk/libs/USBDaemon_globals.h 2007-06-10 08:55:44 UTC (rev 366) @@ -25,6 +25,7 @@ #define __USBDAEMON_GLOBALS_H__ /*_____________________ I N C L U D E S____________________________________ */ +#include <unistd.h> #include <usb.h> /*_____________________ D E F I N E S ______________________________________*/ @@ -47,7 +48,7 @@ /*_____________________ 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 unsigned short daemon_pid; +extern pid_t daemon_pid; extern unsigned char show_invalid_raw; #define MATURITY_LEN 9 Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-10 08:32:03 UTC (rev 365) +++ daemon/trunk/main.c 2007-06-10 08:55:44 UTC (rev 366) @@ -55,7 +55,7 @@ unsigned char show_frames = 0; unsigned char show_raw_status = 0; unsigned char show_invalid_raw = 0; -unsigned short daemon_pid = 0; +pid_t daemon_pid = 0; unsigned char daemonized = 0; static uid_t user = (uid_t)-1; /**< Initial user id */ @@ -280,11 +280,12 @@ exit(1); } - daemon_pid = (unsigned short)getpid(); - log_info("Tux USB Daemon started: pid = %d", (int)getpid()); - if (!write_pid()) + daemon_pid = write_pid(); + if (daemon_pid == 0) exit(1); + log_info("Tux daemon started: pid = %d", daemon_pid); + /* No shell */ if (log_target != LOG_TARGET_SHELL) { |
From: neimad <c2m...@c2...> - 2007-06-10 08:32:36
|
Author: neimad Date: 2007-06-10 10:32:03 +0200 (Sun, 10 Jun 2007) New Revision: 365 Modified: daemon/trunk/main.c Log: * Oh my... What a horrible mixup. I used pid_t instead of uid_t ! /me blushes Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-10 06:53:27 UTC (rev 364) +++ daemon/trunk/main.c 2007-06-10 08:32:03 UTC (rev 365) @@ -58,7 +58,7 @@ unsigned short daemon_pid = 0; unsigned char daemonized = 0; -static pid_t user = (pid_t)-1; /**< Initial user id */ +static uid_t user = (uid_t)-1; /**< Initial user id */ static gid_t group = (gid_t)-1; /**< Initial group id */ /************************************************************************ */ @@ -157,7 +157,7 @@ */ static int raise_privileges(void) { - if (user == (pid_t)-1 || group == (pid_t)-1) + if (user == (uid_t)-1 || group == (gid_t)-1) return 0; log_debug("Raising privileges"); |
From: neimad <c2m...@c2...> - 2007-06-10 06:53:28
|
Author: neimad Date: 2007-06-10 08:53:27 +0200 (Sun, 10 Jun 2007) New Revision: 364 Modified: daemon/trunk/libs/USBDaemon_log.h Log: * Fixed log_error() logging at level "warning" (doh). Modified: daemon/trunk/libs/USBDaemon_log.h =================================================================== --- daemon/trunk/libs/USBDaemon_log.h 2007-06-10 06:11:09 UTC (rev 363) +++ daemon/trunk/libs/USBDaemon_log.h 2007-06-10 06:53:27 UTC (rev 364) @@ -31,6 +31,6 @@ #define log_debug(fmt, ...) log_text(LOG_LEVEL_DEBUG, (fmt), ## __VA_ARGS__) #define log_info(fmt, ...) log_text(LOG_LEVEL_INFO, (fmt), ## __VA_ARGS__) #define log_warning(fmt, ...) log_text(LOG_LEVEL_WARNING, (fmt), ## __VA_ARGS__) -#define log_error(fmt, ...) log_text(LOG_LEVEL_WARNING, (fmt), ## __VA_ARGS__) +#define log_error(fmt, ...) log_text(LOG_LEVEL_ERROR, (fmt), ## __VA_ARGS__) #endif |
From: neimad <c2m...@c2...> - 2007-06-10 06:11:30
|
Author: neimad Date: 2007-06-10 08:11:09 +0200 (Sun, 10 Jun 2007) New Revision: 363 Modified: daemon/trunk/libs/USBDaemon_usb_enum.c daemon/trunk/libs/USBDaemon_usb_enum.h Log: * Made usb_find_TuxDroid() ANSI-compliant... Modified: daemon/trunk/libs/USBDaemon_usb_enum.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-10 06:04:49 UTC (rev 362) +++ daemon/trunk/libs/USBDaemon_usb_enum.c 2007-06-10 06:11:09 UTC (rev 363) @@ -45,7 +45,7 @@ /* usb_find_TuxDroid() */ /************************************************************************ */ -struct usb_device *usb_find_TuxDroid() +struct usb_device *usb_find_TuxDroid(void) { struct usb_bus *bus; struct usb_device *tux_dev; Modified: daemon/trunk/libs/USBDaemon_usb_enum.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb_enum.h 2007-06-10 06:04:49 UTC (rev 362) +++ daemon/trunk/libs/USBDaemon_usb_enum.h 2007-06-10 06:11:09 UTC (rev 363) @@ -74,7 +74,7 @@ /*_____________________ F U N C T I O N S __________________________________*/ -extern struct usb_device *usb_find_TuxDroid(); +extern struct usb_device *usb_find_TuxDroid(void); extern int usb_init_TuxDroid(void); #endif |
From: neimad <c2m...@c2...> - 2007-06-10 06:05:32
|
Author: neimad Date: 2007-06-10 08:04:49 +0200 (Sun, 10 Jun 2007) New Revision: 362 Modified: daemon/trunk/libs/USBDaemon_tcp_server.c Log: * Removed unnecessary variable (which was shadowing another one in the same loop). Modified: daemon/trunk/libs/USBDaemon_tcp_server.c =================================================================== --- daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-09 17:50:17 UTC (rev 361) +++ daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-10 06:04:49 UTC (rev 362) @@ -184,8 +184,6 @@ /* Receive messages from clients */ for (i = 0; i < TUX_MAX_TCP_CLIENTS; i++) { - int r; - if (tcp_clients_handle[i] < 0 || !FD_ISSET(tcp_clients_handle[i], &rset)) continue; |
From: neimad <c2m...@c2...> - 2007-06-09 17:50:52
|
Author: neimad Date: 2007-06-09 19:50:17 +0200 (Sat, 09 Jun 2007) New Revision: 361 Modified: daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_command_tux.h Log: * Made a bunch of functions static, as they are only used where they're defined. The functions here should be reordered so that the added prototypes can be removed. Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-09 16:33:58 UTC (rev 360) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-06-09 17:50:17 UTC (rev 361) @@ -53,6 +53,23 @@ int avoid_wifi_channel(unsigned char wifi_channel); int random_tux_connection(void); +static void sub_daemon_cmd_struct(unsigned char const data[], + unsigned char result[], + int const id_client); + +static void sub_daemon_req_info(unsigned char const data[], + unsigned char result[], + int const id_client); + +static void tux_cmd_raw(unsigned char const data[], unsigned char result[]); +static void tux_cmd_struct(unsigned char const data[], unsigned char result[]); +static void tux_req_status(unsigned char const data[], unsigned char result[]); +static void tux_req_info(unsigned char const data[], unsigned char result[]); + +static unsigned char send_usb_tux_cmd(unsigned char cmd, unsigned char param1, + unsigned char param2, + unsigned char param3); + /************************************************************************** */ /* COMMANDS FROM CLIENTS DISPATCHER */ /************************************************************************** */ @@ -254,8 +271,8 @@ /******************************************************************** */ /* sub_daemon_cmd_struct() */ /******************************************************************** */ -void sub_daemon_cmd_struct(unsigned char const data[], unsigned char result[], - int const id_client) +static void sub_daemon_cmd_struct(unsigned char const data[], + unsigned char result[], int const id_client) { switch (data[0]) { @@ -297,8 +314,8 @@ /************************************************************************ */ /* sub_daemon_req_info() */ /************************************************************************ */ -void sub_daemon_req_info(unsigned char const data[], unsigned char result[], - int const id_client) +static void sub_daemon_req_info(unsigned char const data[], + unsigned char result[], int const id_client) { unsigned char i; @@ -334,7 +351,7 @@ /************************************************************************ */ /* tux_cmd_raw() */ /************************************************************************ */ -void tux_cmd_raw(unsigned char const data[], unsigned char result[]) +static void tux_cmd_raw(unsigned char const data[], unsigned char result[]) { unsigned char usb_send[5]; unsigned char i; @@ -348,7 +365,7 @@ /************************************************************************ */ /* tux_cmd_struct() */ /************************************************************************ */ -void tux_cmd_struct(unsigned char const data[], unsigned char result[]) +static void tux_cmd_struct(unsigned char const data[], unsigned char result[]) { unsigned char ACK; @@ -522,7 +539,7 @@ /************************************************************************ */ /* tux_req_status() */ /************************************************************************ */ -void tux_req_status(unsigned char const data[], unsigned char result[]) +static void tux_req_status(unsigned char const data[], unsigned char result[]) { result[0] = data[0]; switch (data[0]) @@ -879,7 +896,7 @@ /************************************************************************ */ /* tux_req_info() */ /************************************************************************ */ -void tux_req_info(unsigned char const data[], unsigned char result[]) +static void tux_req_info(unsigned char const data[], unsigned char result[]) { result[0] = data[0]; @@ -960,7 +977,7 @@ /** * Connect to a tux by its ID - * + * * The return value only tells whether the command has been sent successfully * to the dongle. That does by no means tell anything about the actual RF * connection with tux. Check RF_status for this. @@ -1167,7 +1184,7 @@ {2, 26, 32, 38, 43, 49, 55, 61, 67, 72, 78, 84, 90, 92, 92}; if (send_usb_dongle_cmd(USB_TUX_CONNECTION_CMD, - USB_TUX_CONNECTION_CHANGE_ID, lower_ATR_channel[wifi_channel], + USB_TUX_CONNECTION_CHANGE_ID, lower_ATR_channel[wifi_channel], higher_ATR_channel[wifi_channel]) == USB_FRAME_SIZE) return 0; else Modified: daemon/trunk/libs/USBDaemon_command_tux.h =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.h 2007-06-09 16:33:58 UTC (rev 360) +++ daemon/trunk/libs/USBDaemon_command_tux.h 2007-06-09 17:50:17 UTC (rev 361) @@ -35,19 +35,8 @@ /* COMMANDS FROM CLIENTS DISPATCHER */ extern void commands_dispatcher(unsigned char client_id, unsigned char src_frame[16]); -extern void sub_daemon_cmd_struct(unsigned char const data[], - unsigned char result[], int const id_client); -extern void sub_daemon_req_info(unsigned char const data[], - unsigned char result[], int const id_client); -extern void tux_cmd_raw(unsigned char const data[], unsigned char result[]); -extern void tux_cmd_struct(unsigned char const data[], unsigned char result[]); -extern void tux_req_status(unsigned char const data[], unsigned char result[]); -extern void tux_req_info(unsigned char const data[], unsigned char result[]); /* TUX PHYSICAL CHANGES */ -extern unsigned char send_usb_tux_cmd(unsigned char cmd, unsigned char param1, - unsigned char param2, - unsigned char param3); extern unsigned char send_usb_dongle_cmd(usb_dongle_commands_t cmd, unsigned char param1, unsigned char param2, |
From: neimad <c2m...@c2...> - 2007-06-09 16:34:29
|
Author: neimad Date: 2007-06-09 18:33:58 +0200 (Sat, 09 Jun 2007) New Revision: 360 Modified: daemon/trunk/libs/USBDaemon_tcp_server.c daemon/trunk/libs/USBDaemon_tcp_server.h Log: * tcp_server_loop returns void, not void * (return value unused). Modified: daemon/trunk/libs/USBDaemon_tcp_server.c =================================================================== --- daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-09 05:21:40 UTC (rev 359) +++ daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-09 16:33:58 UTC (rev 360) @@ -70,12 +70,10 @@ return 1; } -/************************************************************************ */ - -/* tcp_server_start_task() */ - -/************************************************************************ */ -void *tcp_server_loop(void) +/** + * Server's event loop + */ +void tcp_server_loop(void) { #define TIMEOUT ((struct timeval){ .tv_sec = 0, .tv_usec = 50000 }) tcp_frame_t datas_recv; @@ -84,7 +82,7 @@ if ((tcp_server_handle = socket(AF_INET, SOCK_STREAM, 0)) < 0) { log_error("TCP socket: socket creation failed: %m"); - return NULL; + return; } val = 1; @@ -108,7 +106,7 @@ if (listen(tcp_server_handle, 5) < 0) { log_error("TCP socket: listen failed: %m"); - return NULL; + return; } log_info("TCP socket: opened"); @@ -199,8 +197,6 @@ commands_dispatcher((unsigned char)i, datas_recv); } } - - return NULL; } /************************************************************************ */ Modified: daemon/trunk/libs/USBDaemon_tcp_server.h =================================================================== --- daemon/trunk/libs/USBDaemon_tcp_server.h 2007-06-09 05:21:40 UTC (rev 359) +++ daemon/trunk/libs/USBDaemon_tcp_server.h 2007-06-09 16:33:58 UTC (rev 360) @@ -59,7 +59,7 @@ extern client_name_t tcp_clients_name[]; /*_____________________ F U N C T I O N S __________________________________*/ -extern void *tcp_server_loop(void); +extern void tcp_server_loop(void); extern void tcp_server_send_raw(const tcp_frame_t data); extern void tcp_server_send_raw_to_client(int client_index, const tcp_frame_t data); |
From: neimad <c2m...@c2...> - 2007-06-09 05:21:43
|
Author: neimad Date: 2007-06-09 07:21:40 +0200 (Sat, 09 Jun 2007) New Revision: 359 Modified: daemon/trunk/libs/USBDaemon_tcp_server.c daemon/trunk/libs/USBDaemon_tcp_server.h Log: * Made send_daemon_disconnected() ANSI-conformant. Modified: daemon/trunk/libs/USBDaemon_tcp_server.c =================================================================== --- daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-08 13:51:14 UTC (rev 358) +++ daemon/trunk/libs/USBDaemon_tcp_server.c 2007-06-09 05:21:40 UTC (rev 359) @@ -248,7 +248,7 @@ /* send_daemon_disconnected */ /************************************************************************ */ -void send_daemon_disconnected() +void send_daemon_disconnected(void) { tcp_frame_t data; Modified: daemon/trunk/libs/USBDaemon_tcp_server.h =================================================================== --- daemon/trunk/libs/USBDaemon_tcp_server.h 2007-06-08 13:51:14 UTC (rev 358) +++ daemon/trunk/libs/USBDaemon_tcp_server.h 2007-06-09 05:21:40 UTC (rev 359) @@ -63,7 +63,7 @@ extern void tcp_server_send_raw(const tcp_frame_t data); extern void tcp_server_send_raw_to_client(int client_index, const tcp_frame_t data); -extern void send_daemon_disconnected(); +extern void send_daemon_disconnected(void); extern void tcp_remove_client(int id_client); #endif |
From: jaguarondi <c2m...@c2...> - 2007-06-08 13:51:46
|
Author: jaguarondi Date: 2007-06-08 15:51:14 +0200 (Fri, 08 Jun 2007) New Revision: 358 Modified: daemon/trunk/libs/USBDaemon_globals.h daemon/trunk/libs/USBDaemon_usb_readWrite.c daemon/trunk/libs/USBDaemon_usb_readWrite.h Log: * Removed usb_read_TuxDroid() which is not used anymore to access the current firmware. Modified: daemon/trunk/libs/USBDaemon_globals.h =================================================================== --- daemon/trunk/libs/USBDaemon_globals.h 2007-06-08 13:45:59 UTC (rev 357) +++ daemon/trunk/libs/USBDaemon_globals.h 2007-06-08 13:51:14 UTC (rev 358) @@ -35,7 +35,6 @@ #define TUX_PID 0xFF07 #define TUX_VID 0x03EB #define TUX_INTERFACE 0x03 -#define TUX_RECV_LENGTH 0x04 #define TUX_SEND_LENGTH 0x05 #define TUX_WRITE_EP 0x05 #define TUX_READ_EP 0x84 Modified: daemon/trunk/libs/USBDaemon_usb_readWrite.c =================================================================== --- daemon/trunk/libs/USBDaemon_usb_readWrite.c 2007-06-08 13:45:59 UTC (rev 357) +++ daemon/trunk/libs/USBDaemon_usb_readWrite.c 2007-06-08 13:51:14 UTC (rev 358) @@ -33,36 +33,7 @@ /*_____________________ F U N C T I O N S __________________________________*/ /************************************************************************ */ - -/* usb_read_TuxDroid() */ - -/************************************************************************ */ -void usb_read_TuxDroid(void) -{ - unsigned char data[TUX_RECV_LENGTH]; - int idx; - int i; - - if (usb_connection_status != USB_CONNECTED) - return; - - for (i = 0; i < 5; i++) - { - idx = - usb_interrupt_read(tux_handle, TUX_READ_EP, (char *)data, - TUX_RECV_LENGTH, TUX_READ_TIMEOUT); - - if (idx != TUX_RECV_LENGTH) - i = 0; - else - update_raw_status_table(data); - } -} - -/************************************************************************ */ - /* usb_get_status_TuxDroid() */ - /************************************************************************ */ void usb_get_status_TuxDroid(void) { @@ -109,9 +80,7 @@ } /************************************************************************ */ - /* usb_write_TuxDroid() */ - /************************************************************************ */ unsigned char usb_write_TuxDroid(unsigned char data[TUX_SEND_LENGTH]) { Modified: daemon/trunk/libs/USBDaemon_usb_readWrite.h =================================================================== --- daemon/trunk/libs/USBDaemon_usb_readWrite.h 2007-06-08 13:45:59 UTC (rev 357) +++ daemon/trunk/libs/USBDaemon_usb_readWrite.h 2007-06-08 13:51:14 UTC (rev 358) @@ -32,7 +32,6 @@ /*_____________________ V A R I A B L E S __________________________________*/ /*_____________________ F U N C T I O N S __________________________________*/ -extern void usb_read_TuxDroid(void); extern void usb_get_status_TuxDroid(void); extern unsigned char usb_write_TuxDroid(unsigned char datas[]); |