tux-droid-svn Mailing List for Tux Droid CE (Page 225)
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: jaguarondi <c2m...@c2...> - 2007-06-19 16:43:50
|
Author: jaguarondi Date: 2007-06-19 18:43:49 +0200 (Tue, 19 Jun 2007) New Revision: 406 Modified: firmware/tuxaudio/trunk/Makefile Log: * Added some programming directives in the Makefile. * Fixed the bootloader target name. Modified: firmware/tuxaudio/trunk/Makefile =================================================================== --- firmware/tuxaudio/trunk/Makefile 2007-06-19 16:41:46 UTC (rev 405) +++ firmware/tuxaudio/trunk/Makefile 2007-06-19 16:43:49 UTC (rev 406) @@ -8,7 +8,7 @@ MCU = atmega88 FORMAT = ihex TARGET = tuxaudio.elf -BOOTLOADER = tuxaudio_.elf +BOOTLOADER = tuxaudio_bl.elf OPT = s CC = avr-gcc @@ -163,8 +163,14 @@ prog: $(PROJECT).hex tuxup $(PROJECT).hex $(PROJECT).eep -progisp: $(PROJECT).hex - AVRDUDE -p $(MCU) -c jtag2isp -P usb -B 10 -e -U flash:w:$(PROJECT).hex +progisp: $(PROJECT).hex $(PROJECT).eep + $(AVRDUDE) -p $(MCU) -c jtag2isp -P usb -B 10 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep -progstk: $(PROJECT).hex - AVRDUDE -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex +progisp_bl: $(PROJECT).hex $(PROJECT).eep $(PROJECT)_bl.hex + $(AVRDUDE) -p $(MCU) -c jtag2isp -P usb -B 10 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep -D -U flash:w:$(PROJECT)_bl.hex + +progstk: $(PROJECT).hex $(PROJECT).eep + $(AVRDUDE) -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep + +progstk_bl: $(PROJECT).hex $(PROJECT).eep $(PROJECT)_bl.hex + $(AVRDUDE) -p $(MCU) -c stk500v2 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep -D -U flash:w:$(PROJECT)_bl.hex |
From: jaguarondi <c2m...@c2...> - 2007-06-19 16:41:51
|
Author: jaguarondi Date: 2007-06-19 18:41:46 +0200 (Tue, 19 Jun 2007) New Revision: 405 Modified: firmware/tuxaudio/trunk/communication.c firmware/tuxaudio/trunk/communication.h firmware/tuxaudio/trunk/main.c Log: * Added the sleep functions. The CPU now loads a low power configuration, goes to sleep and exits the sleep function from the head button interrupt. There's a delay around 1sec before the CPU enters sleep. This way it's possible to get some last commands from tuxcore. This should be changed in the future so that the sleep command is forwarded from tuxcore to tuxaudio only when the pre sleep sequence is finished, that makes more sense. * BUG: if a sound is already playing, we now wait until it's finished before starting the next one. Modified: firmware/tuxaudio/trunk/communication.c =================================================================== --- firmware/tuxaudio/trunk/communication.c 2007-06-19 16:27:52 UTC (rev 404) +++ firmware/tuxaudio/trunk/communication.c 2007-06-19 16:41:46 UTC (rev 405) @@ -80,6 +80,15 @@ , *statusFifo = &_statusBuf; /* + * Initializes (clear) the communication buffers + */ +void initCommunicationBuffers(void) +{ + resetFifo(commandFifo); + audioBufIdx = 0; +} + +/* * I2C communication initalisation * * Start the twi interface in the mode defined in i2c.h, set the receiver function and Modified: firmware/tuxaudio/trunk/communication.h =================================================================== --- firmware/tuxaudio/trunk/communication.h 2007-06-19 16:27:52 UTC (rev 404) +++ firmware/tuxaudio/trunk/communication.h 2007-06-19 16:41:46 UTC (rev 405) @@ -37,6 +37,7 @@ extern fifo_t *statusFifo; /* incomingBuf is used for commands received from the i2c and should be sent over the RF link */ void i2cCommunicationInit(void); +void initCommunicationBuffers(void); /* From RF to i2c */ void sendCommands(void); Modified: firmware/tuxaudio/trunk/main.c =================================================================== --- firmware/tuxaudio/trunk/main.c 2007-06-19 16:27:52 UTC (rev 404) +++ firmware/tuxaudio/trunk/main.c 2007-06-19 16:41:46 UTC (rev 405) @@ -23,6 +23,7 @@ #include <avr/interrupt.h> #include <avr/pgmspace.h> #include <util/delay.h> +#include <avr/sleep.h> #include "init.h" #include "varis.h" @@ -38,7 +39,7 @@ * Version number */ -#define CPU_NUMBER TUXAUDIO_CPU_NUM /* audio CPU */ +#define CPU_NUMBER TUXAUDIO_CPU_NUM /* audio CPU */ const author_t author __attribute__ ((section("version.3"))) = { AUTHOR_CMD, AUTHOR_ID, 0}; @@ -48,8 +49,8 @@ const version_t tag_version __attribute__ ((section("version.1"))) = { VERSION_CMD, CPU_VER_JOIN(CPU_NUMBER, VER_MAJOR), VER_MINOR, VER_UPDATE}; -uint8_t info_flg = 0; /* indicates if version information should be sent */ -uint8_t sleep_flg = 0; /* set when sleep should be entered */ +static uint8_t info_flg = 0; /* indicates if version information should be sent */ +static uint8_t pre_sleep_delay = 0; /* set when sleep should be entered */ void send_info(void) { @@ -73,13 +74,47 @@ info_flg = 0; } +ISR(SIG_PIN_CHANGE1) +{ + /* Nothing to do here, it's just an interrupt set on the head button to + * wake-up from sleep */ + /* XXX This ISR is declared as I think any interrupt which doesn't have an + * interrupt vector initialized will do a reset or infinite loop, this + * needs to be checked */ +} + void sleep(void) { - if (isFifoEmpty(statusFifo)) /* waits for all status to be sent before going to sleep */ - { - sleep_flg = 0; - playingAudio(1); /* XXX debug */ - } + uint8_t PRR_bak; + + pre_sleep_delay = 0; + /* Set power savings configuration. */ + cli(); + PORTB = 0x80; + PORTC = 0; + PORTD = 0; + + PRR_bak = PRR; + PRR = _BV(PRTWI) | _BV(PRTIM2) | _BV(PRTIM0) | _BV(PRTIM1) | _BV(PRADC); + + /* Sleep. */ + /* Set pin change interrupt on head button */ + PCMSK1 = 0x08; + PCIFR = _BV(PCIE1); + PCICR |= _BV(PCIE1); + + set_sleep_mode(SLEEP_MODE_PWR_DOWN); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); + + /* Re-configure in normal mode. */ + PCMSK1 = 0x00; + PRR = PRR_bak; + init_avr(); + initCommunicationBuffers(); + i2cCommunicationInit(); } /* @@ -120,8 +155,12 @@ /* param: audioBuf[1] : sound number */ /* audioBuf[2] : mic sound intensity */ { + /* postpone the command if a sound is already playing */ + if (flashPlay) + return; audioLevel = audioBuf[2]; - playingAudio(audioBuf[1]); // Play sound + //if (audioBuf[1] == 1) PORTC &= ~0x02; + playingAudio(audioBuf[1]); /* start playing the sound */ } else if (audioBuf[0] == MUTE_CMD) { @@ -132,15 +171,16 @@ } else if (audioBuf[0] == TEST_MODE_CMD) { - test_mode = audioBuf[2]; /* audio test mode is the second parameter */ + test_mode = audioBuf[2]; /* audio test mode is the second parameter */ } else if (audioBuf[0] == SLEEP_CMD) { - sleep_flg = 1; /* handle sleep in its own function */ + pre_sleep_delay = 30; /* handle sleep in its own function */ /* Forwards the command to the rf CPU */ + cli(); audioBuf[0] = SLEEP_ACK_CMD; /* go to sleep mode and acknowledge it */ - audioBuf[2] |= SLEEP_ACK_MK; - cli(); + audioBuf[3] = audioBuf[2]; /* move the sleep type to the last byte */ + audioBuf[2] = SLEEP_ACK_MK; i2cSlaveReceiveService(4, audioBuf); sei(); } @@ -295,7 +335,19 @@ if (sendSensorsFlag) { sendSensorsFlag = 0; - sendSensors(); + if (pre_sleep_delay > 1) + /* There's a delay before sleep is actually called otherwise + * some commands can't be executed */ + pre_sleep_delay--; + else + /* stop sending sensor status in sleep as the i2C should be + * stopped at this time */ + sendSensors(); + /* wait for all status to be sent before going to sleep */ + if (isFifoEmpty(statusFifo)) + /* wait for audio commands to be processed */ + if (!audioBufIdx && !flashPlay) + if (power_on_reset_delay) /* XXX to move to a proper loop or timer after or before main() */ { uint8_t tmp; @@ -398,13 +450,15 @@ // battery_level = PIND; sendSensors(); PORTD &= ~_BV(PD0); /* set the IR power low */ - test_mode = AT_AUDIOLINK; /* go to audio link mode */ + test_mode = AT_AUDIOLINK; /* go to audio link mode */ } if (info_flg) - send_info(); /* send information to the computer */ - if (sleep_flg) - sleep(); /* send information to the computer */ + send_info(); /* send information to the computer */ + + /* Sleep mode */ + if (pre_sleep_delay == 1) + sleep(); } } @@ -434,7 +488,7 @@ else { #ifndef MIC_GAIN -#define MIC_GAIN 0 /* default value if not declared in the makefile */ +#define MIC_GAIN 0 /* default value if not declared in the makefile */ #endif #if (MIC_GAIN == 6) /* MEDIUM GAIN MODE */ |
From: jaguarondi <c2m...@c2...> - 2007-06-19 16:27:57
|
Author: jaguarondi Date: 2007-06-19 18:27:52 +0200 (Tue, 19 Jun 2007) New Revision: 404 Modified: firmware/tuxcore/trunk/Makefile firmware/tuxcore/trunk/main.c firmware/tuxcore/trunk/standalone.c firmware/tuxdefs/commands.h firmware/tuxdefs/config.h Log: * Added the AVR sleep functions so that it now really enters sleep mode. The head button interrupt is used to exit from sleep. The status of the leds is saved and restored but it doesn't work all the time probably because of bug #9. I'll check this later on. * Added config.h dependency for the .eep taget in the Makefile. * The CLOSE_EYES_CMD was missing from commands.h. * Added the standalone sequences for the pre and post sleep events. Modified: firmware/tuxcore/trunk/Makefile =================================================================== --- firmware/tuxcore/trunk/Makefile 2007-06-19 11:48:44 UTC (rev 403) +++ firmware/tuxcore/trunk/Makefile 2007-06-19 16:27:52 UTC (rev 404) @@ -125,7 +125,7 @@ %.hex: %.elf avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ -%.eep: %.elf +%.eep: %.elf common/config.h avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ %.lss: %.elf Modified: firmware/tuxcore/trunk/main.c =================================================================== --- firmware/tuxcore/trunk/main.c 2007-06-19 11:48:44 UTC (rev 403) +++ firmware/tuxcore/trunk/main.c 2007-06-19 16:27:52 UTC (rev 404) @@ -22,6 +22,7 @@ #include <avr/interrupt.h> #include <avr/io.h> #include <avr/pgmspace.h> +#include <avr/sleep.h> #include "global.h" #include "sensors.h" @@ -313,6 +314,7 @@ /* set external I/O as pull-up */ EXIO_PT |= EXIO_MK; + PCIFR = _BV(PCIE0) | _BV(PCIE1) | _BV(PCIE2); /* clear pending interrupts */ sei(); /* enable global interrupts */ } @@ -324,11 +326,12 @@ void closeIO(void) { PCICR = 0; - EICRA = 0; + EIMSK = 0; ADCSRA = 0; turnLedsOff(); turnIrOff(); } + /* * timer 2 intitialisation * @@ -414,6 +417,7 @@ uint8_t PRR_bak; /* Set power savings configuration. */ + cli(); led_bak = readLeds(); closeIO(); closePosSwitches(); @@ -421,14 +425,20 @@ stopMouth(); stopWings(); PRR_bak = PRR; - PRR = _BV(PRTTWI) | _BV(PRTIM2) | _BV(PRTIM0) | _BV(PRTIM1) | _BV(PRADC); + PRR = _BV(PRTWI) | _BV(PRTIM2) | _BV(PRTIM0) | _BV(PRTIM1) | _BV(PRADC); /* Sleep. */ - while(SW_HD_PIN & SW_HD_MK) /* exit sleep if head is pushed */ - { - /* XXX Enter sleep mode here, either wakeup regularly to check the head button or better configure an interrupt on the head button to wake-up the CPU */ - } + /* Set pin change interrupt on head button */ + PCMSK0 = SW_HD_MK; + PCIFR = _BV(PCIE0); + PCICR |= _BV(PCIE0); + set_sleep_mode(SLEEP_MODE_PWR_DOWN); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); + /* Re-configure in normal mode. */ PRR = PRR_bak; setLeds(led_bak); /* restore leds status */ @@ -438,5 +448,7 @@ /* Trigger the post-sleep event */ cond_flags.sleep = COND_POST_SLEEP; - event_timer = 2; /* wait 200ms for the pull-up to rise before next standalone behavior otherwise position switches signals are wrong */ + /* Wait 200ms for the pull-up to rise before next standalone behavior + * otherwise position switches signals are wrong */ + event_timer = 2; } Modified: firmware/tuxcore/trunk/standalone.c =================================================================== --- firmware/tuxcore/trunk/standalone.c 2007-06-19 11:48:44 UTC (rev 403) +++ firmware/tuxcore/trunk/standalone.c 2007-06-19 16:27:52 UTC (rev 404) @@ -128,7 +128,7 @@ launchActions((const uint8_t *)&unplug_e); } - /* Entering sleep mode. */ + /* Before entering sleep mode. */ else if (cond_flags.sleep == COND_PRE_SLEEP) { cond_flags.sleep = COND_SLEEP; Modified: firmware/tuxdefs/commands.h =================================================================== --- firmware/tuxdefs/commands.h 2007-06-19 11:48:44 UTC (rev 403) +++ firmware/tuxdefs/commands.h 2007-06-19 16:27:52 UTC (rev 404) @@ -152,16 +152,20 @@ /* 1st parameter: number of movements before the eyes will stop */ #define STOP_EYES_CMD 0x32 /* stop the eyes motor */ #define OPEN_EYES_CMD 0x33 /* open the eyes if they are closed */ +#define CLOSE_EYES_CMD 0x38 /* open the eyes if they are closed */ + #define MOVE_MOUTH_CMD 0x41 /* move the mouth */ /* 1st parameter: number of movements before the mouth will stop */ #define OPEN_MOUTH_CMD 0x34 /* open the mouth if it is closed */ #define CLOSE_MOUTH_CMD 0x35 /* close the mouth if it is open */ #define STOP_MOUTH_CMD 0x36 /* stop the mouth motor */ + #define WAVE_WINGS_CMD 0x80 /* move the wings up and down */ /* 1st parameter: number of movements before the wings will stop */ /* 2nd parameter: pwm value between 1 (slow) and 5 (fast) */ #define STOP_WINGS_CMD 0x30 /* stop the wings motor */ #define RESET_WINGS_CMD 0x31 /* reset the wings in the low position */ + #define SPIN_LEFT_CMD 0x82 /* spin left of a given angle */ /* 1st parameter: angle to turn, the unit is approximately 1/8th of a turn */ /* 2nd parameter: pwm value between 1 (slow) and 5 (fast) */ Modified: firmware/tuxdefs/config.h =================================================================== --- firmware/tuxdefs/config.h 2007-06-19 11:48:44 UTC (rev 403) +++ firmware/tuxdefs/config.h 2007-06-19 16:27:52 UTC (rev 404) @@ -18,8 +18,9 @@ * Standalone events */ -#define SHORT_EVENT 16 -#define LONG_EVENT 31 +#define TINY_EVENT 6 +#define SHORT_EVENT 16 +#define LONG_EVENT 31 #define END_OF_ACTIONS 0xFF /* action time that indicates the end of commands */ /* Startup event */ @@ -65,6 +66,20 @@ END_OF_ACTIONS\ } +/* Entering sleep event */ +#define SLEEP_ENTER_E_SEQ {\ + 10, CLOSE_EYES_CMD, PLAY_SOUND_CMD, 1, 0, /* */\ + /* the delay (first byte) is necessary for the movement to complete before + * sleep is entered */\ + END_OF_ACTIONS\ +} + +/* Exiting sleep event */ +#define SLEEP_EXIT_E_SEQ {\ + 0, OPEN_EYES_CMD, PLAY_SOUND_CMD, 5, 0, /* */\ + END_OF_ACTIONS\ +} + /* RF connection event */ #define RF_CONN_E_SEQ {\ 0, LED_ON_CMD, 0, 0, 0, /* tun on the leds */\ |
From: remi <c2m...@c2...> - 2007-06-19 11:48:45
|
Author: remi Date: 2007-06-19 13:48:44 +0200 (Tue, 19 Jun 2007) New Revision: 403 Modified: software/tuxgi/trunk/version.py Log: New version started Modified: software/tuxgi/trunk/version.py =================================================================== --- software/tuxgi/trunk/version.py 2007-06-19 11:40:18 UTC (rev 402) +++ software/tuxgi/trunk/version.py 2007-06-19 11:48:44 UTC (rev 403) @@ -1 +1 @@ -app_version="0.2.2" +app_version="0.2.3 (SVN/UNRELEASED)" |
From: remi <c2m...@c2...> - 2007-06-19 11:40:56
|
Author: remi Date: 2007-06-19 13:40:18 +0200 (Tue, 19 Jun 2007) New Revision: 402 Added: software/tuxgi/tags/0.2.2/ Log: Tag to 0.2.2 Copied: software/tuxgi/tags/0.2.2 (from rev 401, software/tuxgi/trunk) |
From: remi <c2m...@c2...> - 2007-06-19 11:39:57
|
Author: remi Date: 2007-06-19 13:39:53 +0200 (Tue, 19 Jun 2007) New Revision: 401 Modified: software/tuxgi/trunk/version.py Log: Preparing for tag Modified: software/tuxgi/trunk/version.py =================================================================== --- software/tuxgi/trunk/version.py 2007-06-19 11:34:34 UTC (rev 400) +++ software/tuxgi/trunk/version.py 2007-06-19 11:39:53 UTC (rev 401) @@ -1 +1 @@ -app_version="0.2.2" \ No newline at end of file +app_version="0.2.2" |
From: remi <c2m...@c2...> - 2007-06-19 11:34:41
|
Author: remi Date: 2007-06-19 13:34:34 +0200 (Tue, 19 Jun 2007) New Revision: 400 Modified: software/tuxgi/trunk/version.py Log: Preparing for tag Modified: software/tuxgi/trunk/version.py =================================================================== --- software/tuxgi/trunk/version.py 2007-06-19 09:08:24 UTC (rev 399) +++ software/tuxgi/trunk/version.py 2007-06-19 11:34:34 UTC (rev 400) @@ -1 +1 @@ -app_version="0.2.1" +app_version="0.2.2" \ No newline at end of file |
From: jaguarondi <c2m...@c2...> - 2007-06-19 09:08:25
|
Author: jaguarondi Date: 2007-06-19 11:08:24 +0200 (Tue, 19 Jun 2007) New Revision: 399 Modified: api/python/trunk/tuxapi_class.py Log: * Udated the docstrings of the connection class. Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-19 09:01:20 UTC (rev 398) +++ api/python/trunk/tuxapi_class.py 2007-06-19 09:08:24 UTC (rev 399) @@ -470,9 +470,21 @@ # TUXTCPCommunicator - connect - class #============================================================================== class TUXconnect(object): - """Class which manages connection functions """ + Class which manages connection functions + Functions list for the users: + tux.connect.disconnect_from_tux + tux.connect.connect_to_tux + tux.connect.random_connect_to_tux + tux.connect.id_request + tux.connect.id_lookup + tux.connect.change_id + tux.connect.sleep + tux.connect.wakeup + tux.connect.avoid_wifi + """ + #-------------------------------------------------------------------------- # Constructor of the class #-------------------------------------------------------------------------- @@ -487,6 +499,7 @@ #-------------------------------------------------------------------------- def tux_connection(self, connection_command, connection_args=[]): """ + Not a user function """ if not self.parent.daemon.connected: return 0 @@ -503,8 +516,15 @@ # Disconnect from tux #-------------------------------------------------------------------------- def disconnect_from_tux(self): - """Disconnect from tux """ + Disconnect from tux + + Parameters: + "seconds" as float : Time to wait in seconds + + Example: + >>> tux.sys.wait(2.4) + """ ack_frame = self.tux_connection(TUX_CONNECTION_DISCONNECT) if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: return False @@ -515,8 +535,20 @@ # Connect to a tux by its ID #-------------------------------------------------------------------------- def connect_to_tux(self, id): - """Connect to a tux by its ID """ + Connect to a tux by its ID + + Parameters: + "id" as uint16 : ID of the tux you want to connect to + 0 and 0xFFFF (65536) are not valid ID's + + Returns: + "True" if the command has been sent successfully, + "False" otherwise. + + Example: + >>> tux.connect.connect_to_tux(300) + """ # 0 is an invalid id and 0xFFFF is reserved assert 0 < id < 0xFFFF id_msb = id >> 8 @@ -532,10 +564,15 @@ # Connect to the first tux discovered #-------------------------------------------------------------------------- def random_connect_to_tux(self): - """Connect to the first tux discovered + """ + Connect to the first tux discovered Catch any disconnected tux, request it's ID and connect to it. + Returns: + "True" if the command has been sent successfully, + "False" otherwise. + """ ack_frame = self.tux_connection(TUX_CONNECTION_RANDOM) if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: @@ -547,8 +584,14 @@ # Get the ID of the first disconnected tux which is discoverred #-------------------------------------------------------------------------- def id_request(self): - """Get the ID of tux currently connected """ + Get the ID of tux currently connected + + Returns: + "id" as uint16 (0 < id < 65536) if the command has been sent + successfully, + "False" otherwise. + """ 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]) @@ -559,14 +602,20 @@ # 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 + """ + 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. + 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. + 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. + + Returns: + "id" as uint16 (0 < id < 65536) if the command has been sent + successfully, + "False" otherwise. """ ack_frame = self.tux_connection(TUX_CONNECTION_ID_LOOKUP) if ack_frame and ord(ack_frame[5]) == TUX_CONNECTION_ACK: @@ -578,11 +627,20 @@ # Changes the ID of a disconnected tux #-------------------------------------------------------------------------- def change_id(self, id): - """Changes the ID of a disconnected tux + """ + 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. + 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. + + Parameters: + "id" as uint16 : new ID you want to set to your tux + 0 and 0xFFFF (65536) are not valid ID's + + Returns: + "True" if the command has been sent successfully, + "False" otherwise. """ assert 0 < id < 0xFFFF id_msb = id >> 8 @@ -598,8 +656,13 @@ # Set tux in sleep mode #-------------------------------------------------------------------------- def sleep(self): - """Set tux in sleep mode """ + Set tux in sleep mode + + Returns: + "True" if the command has been sent successfully, + "False" otherwise. + """ ack_frame = self.tux_connection(TUX_CONNECTION_SLEEP) if not ack_frame or ord(ack_frame[5]) != TUX_CONNECTION_ACK: return False @@ -610,8 +673,17 @@ # Wake-up a tux if it's in sleep mode. #-------------------------------------------------------------------------- def wakeup(self, id): - """Wake-up a tux if it's in sleep mode. """ + Wake-up a tux if it's in sleep mode. + + Parameters: + "id" as uint16 : ID of the tux you want to wake-up + 0 and 0xFFFF (65536) are not valid ID's + + Returns: + "True" if the command has been sent successfully, + "False" otherwise. + """ assert 0 < id < 0xFFFF id_msb = id >> 8 id_lsb = id % 256 @@ -626,11 +698,19 @@ # 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 + """ + 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. + + Parameters: + "channel" : wifi channel number that tux should avoid using + 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. + + Returns: + "True" if the command has been sent successfully, + "False" otherwise. """ ack_frame = self.tux_connection(TUX_CONNECTION_WIRELESS_CHANNEL, [channel]) |
From: remi <c2m...@c2...> - 2007-06-19 09:01:21
|
Author: remi Date: 2007-06-19 11:01:20 +0200 (Tue, 19 Jun 2007) New Revision: 398 Modified: api/python/trunk/tuxapi_class.py Log: UPD Docstring update Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-19 07:55:42 UTC (rev 397) +++ api/python/trunk/tuxapi_class.py 2007-06-19 09:01:20 UTC (rev 398) @@ -68,6 +68,8 @@ Call the destroying function at the end of your script for closing the api correctly. >>> tux.destroy() + + "tts" class is compatible with "tuxttsd" v 0.3.0 or more recent """ #-------------------------------------------------------------------------- # Constructor of class @@ -646,13 +648,10 @@ Class which manages the system functions Functions list for the users: - tux.sys.add_notification tux.sys.add_time_event - tux.sys.clear_notification tux.sys.clear_time_events tux.sys.delayed_function tux.sys.looped_function - tux.sys.remove_notification tux.sys.shell tux.sys.shell_free tux.sys.time @@ -4447,6 +4446,7 @@ tux.misc.doc tux.misc.build_documentation tux.misc.print_api_version + tux.misc.simulate_remote_key """ #-------------------------------------------------------------------------- # Constructor of class |
From: remi <c2m...@c2...> - 2007-06-19 07:56:11
|
Author: remi Date: 2007-06-19 09:55:42 +0200 (Tue, 19 Jun 2007) New Revision: 397 Modified: api/python/trunk/tuxapi_class.py Log: UPD API wait a voice loaded ACK in "tts.speak" methode Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-18 16:04:29 UTC (rev 396) +++ api/python/trunk/tuxapi_class.py 2007-06-19 07:55:42 UTC (rev 397) @@ -3892,6 +3892,7 @@ self.ac_port=5500 self.ac_address='localhost' self.authorized_voices_list = [] + self.voice_loaded = False #-------------------------------------------------------------------------- # Allow to connect the api to tuxttsd automatically @@ -4111,6 +4112,9 @@ self.authorized_voices_list.append(ord(voice_id)-1) if self.on_voice_list != None: self.on_voice_list() + # A voice has been loaded + if ord(data[1])==CMD_INFO_VOICE_OK: + self.voice_loaded = True #-------------------------------------------------------------------------- # Send command to tuxttsd @@ -4293,9 +4297,18 @@ 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.voice_loaded = False self.sock.send(text_to_send) counter = 0 + while ((self.voice_loaded == False) and (counter < 300)): + counter = counter + 1 + self.parent.sys.wait(0.1) + if counter == 300: + self.stop() + print "TTS Speak : Voice not loaded" + return False + self.parent.cmd.audio_channel_tts() + counter = 0 while ((self.sound_on == False) and (counter < 100)): counter = counter + 1 self.parent.sys.wait(0.1) |
From: jaguarondi <c2m...@c2...> - 2007-06-18 16:04:31
|
Author: jaguarondi Date: 2007-06-18 18:04:29 +0200 (Mon, 18 Jun 2007) New Revision: 396 Modified: daemon/trunk/Makefile daemon/trunk/README daemon/trunk/libs/USBDaemon_globals.h daemon/trunk/main.c Log: * Renamed tuxdaemon into tuxd. Modified: daemon/trunk/Makefile =================================================================== --- daemon/trunk/Makefile 2007-06-18 16:02:36 UTC (rev 395) +++ daemon/trunk/Makefile 2007-06-18 16:04:29 UTC (rev 396) @@ -15,7 +15,7 @@ ifeq ($(CFG),Debug) OBJ_DIR = Debug OUTPUT_DIR = . - TARGET = tuxdaemon + TARGET = tuxd C_INCLUDE_DIRS = -I"/usr/include/glib-2.0" -I"/usr/lib/glib-2.0/include" -I"/usr/local/include" C_PREPROC = CFLAGS = -pipe -Wall -Werror -g2 -O0 -DUSB_DEBUG Modified: daemon/trunk/README =================================================================== --- daemon/trunk/README 2007-06-18 16:02:36 UTC (rev 395) +++ daemon/trunk/README 2007-06-18 16:04:29 UTC (rev 396) @@ -2,14 +2,18 @@ TUX Daemon is a daemon to control the tuxdroid robot. -usage : tuxdaemon [options] -options: - -d start in daemon mode - -v view in shell ( for daemon mode ) - -st show the structure of the usb frames - -sr show all raw status - -si show only invalid raw status - -h show this usage list +usage : tuxd [options] + options: + -d start in daemon mode + -lsys log to syslog + -ltux log to /var/log/tuxd + -lstd log to stdout & stderr + -v view in shell (deprecated, use -lstd instead) + -debug start in debug mode + -st show the structure of the usb frames + -sr show all raw status + -si show only invalid raw status + -h show this usage list For all information about tuxdroid, please visit: Modified: daemon/trunk/libs/USBDaemon_globals.h =================================================================== --- daemon/trunk/libs/USBDaemon_globals.h 2007-06-18 16:02:36 UTC (rev 395) +++ daemon/trunk/libs/USBDaemon_globals.h 2007-06-18 16:04:29 UTC (rev 396) @@ -31,7 +31,7 @@ /*_____________________ D E F I N E S ______________________________________*/ /** Name of the daemon */ -#define TUX_DAEMON_NAME "tuxdaemon" +#define TUX_DAEMON_NAME "tuxd" #define TUX_PID 0xFF07 #define TUX_VID 0x03EB Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-18 16:02:36 UTC (rev 395) +++ daemon/trunk/main.c 2007-06-18 16:04:29 UTC (rev 396) @@ -188,7 +188,7 @@ if (daemonized && remove_pid()) log_error("Could not delete PID file"); - log_info("tuxdaemon stopped"); + log_info("tuxd stopped"); log_close(); } @@ -304,11 +304,11 @@ /************************************************************************ */ static void usage(void) { - printf("usage : tuxdaemon [options]\n" + printf("usage : tuxd [options]\n" "options:\n" " -d start in daemon mode\n" " -lsys log to syslog\n" - " -ltux log to /var/log/tuxdaemon\n" + " -ltux log to /var/log/tuxd\n" " -lstd log to stdout & stderr\n" " -v view in shell (deprecated, use -lstd instead)\n" " -debug start in debug mode\n" @@ -367,7 +367,7 @@ /* Only one instance of the daemon is allowed */ if (check_pid()) { - printf("tuxdaemon is already running!\n"); + printf("tuxd is already running!\n"); exit(0); } |
From: jaguarondi <c2m...@c2...> - 2007-06-18 16:03:09
|
Author: jaguarondi Date: 2007-06-18 18:02:36 +0200 (Mon, 18 Jun 2007) New Revision: 395 Modified: api/python/trunk/tuxapi_class.py Log: * Renamed tuxdaemon and tuxttsdaemon into tuxd and tuxttsd. Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-18 12:30:39 UTC (rev 394) +++ api/python/trunk/tuxapi_class.py 2007-06-18 16:02:36 UTC (rev 395) @@ -871,8 +871,8 @@ param 1 : Key as integer "on_light_level" as pof : On light level event param 1 : light value as integer - "on_connected" as pof : On api connected to tuxdaemon - "on_disconnected" as pof : On api disconnect from tuxdaemon + "on_connected" as pof : On api connected to tuxd + "on_disconnected" as pof : On api disconnect from tuxd "on_mouth_open" as pof : On mouth open event "on_mouth_close" as pof : On mouth close event "on_power_plugged" as pof : On power plugged event @@ -1400,7 +1400,7 @@ "last_ack" as integer : ACK value of the last command (ACK_CMD_DONGLE_NOT_PRESENT|ACK_CMD_TIMEOUT| ACK_CMD_OK|ACK_CMD_KO|ACK_CMD_ERROR) - "no_ack" as boolean : Allow to wait a ACK from tuxdaemon + "no_ack" as boolean : Allow to wait a ACK from tuxd Functions list for the users: tux.cmd.audio_channel_general @@ -3131,7 +3131,7 @@ Class which manages the daemon commands Global variables of this class: - "connected" as boolean : State of the connection to tuxdaemon + "connected" as boolean : State of the connection to tuxd Functions list for users: tux.daemon.auto_connect @@ -3163,11 +3163,11 @@ self.ac_port=5000 #-------------------------------------------------------------------------- - # Allow to connect the api to tuxdaemon automatically + # Allow to connect the api to tuxd automatically #-------------------------------------------------------------------------- def auto_connect(self,value,address='ndef',port=0): """ - Allow to connect the api to tuxdaemon automatically + Allow to connect the api to tuxd automatically Parameters: "value" as boolean : turn on/off the auto_connect mode @@ -3220,12 +3220,12 @@ if self.connected: self.parent.hw.alsa_devices_select(0) if self.parent.print_warnings: - print "CONNECTED to tuxdaemon" + print "CONNECTED to tuxd" if self.parent.event.on_connected!=None: self.parent.event.on_connected() else: if self.parent.print_warnings: - print "DISCONNECTED from tuxdaemon" + print "DISCONNECTED from tuxd" self.parent.status.rf_connected = False if self.parent.event.on_disconnected!=None: self.parent.event.on_disconnected() @@ -3234,11 +3234,11 @@ self.parent.sys.wait(0.1) #-------------------------------------------------------------------------- - # Connect object to tuxdaemon + # Connect object to tuxd #-------------------------------------------------------------------------- def connect(self,address='localhost',port=5000): """ - Connect tux object to tuxdaemon + Connect tux object to tuxd Parameters: "port" as integer : Tcp/IP Port number @@ -3293,11 +3293,11 @@ return True #-------------------------------------------------------------------------- - # Disconnect object from tuxdaemon + # Disconnect object from tuxd #-------------------------------------------------------------------------- def disconnect(self): """ - Disconnect tux object from tuxdaemon + Disconnect tux object from tuxd Example: >>> tux.daemon.disconnect() @@ -3312,7 +3312,7 @@ if free_thread.isAlive(): free_thread.join() self.free_thread_list=[] - # To inform the system and tuxdaemon that the connection + # To inform the system and tuxd that the connection # is closed self.disconnect_me() self.connected=False @@ -3383,7 +3383,7 @@ return returned_data[0] #-------------------------------------------------------------------------- - # Send a command to tuxdaemon + # Send a command to tuxd #-------------------------------------------------------------------------- def cmd(self,cmd,param1,param2,param3): """ @@ -3393,7 +3393,7 @@ return self.cmd_ack() #-------------------------------------------------------------------------- - # Send a command to tuxdaemon + # Send a command to tuxd #-------------------------------------------------------------------------- def cmd_no_ack(self,cmd,param1,param2,param3): """ @@ -3407,7 +3407,7 @@ return 0 #-------------------------------------------------------------------------- - # Send a request to tuxdaemon + # Send a request to tuxd #-------------------------------------------------------------------------- def request(self,req,param1,param2,param3): """ @@ -3421,11 +3421,11 @@ return self.rsp_info(req) #-------------------------------------------------------------------------- - # Disconnect a client from tuxdaemon + # Disconnect a client from tuxd #-------------------------------------------------------------------------- def disconnect_client(self,id_client): """ - Disconnect a client from tuxdaemon + Disconnect a client from tuxd Parameters: "id_client" as integer : id of the client to disconnect @@ -3448,11 +3448,11 @@ 0,0,0) #-------------------------------------------------------------------------- - # Kill tuxdaemon + # Kill tuxd #-------------------------------------------------------------------------- def kill(self): """ - Kill tuxdaemon + Kill tuxd Example: >>> tux.daemon.kill() @@ -3461,11 +3461,11 @@ self.last_ack=self.cmd(SUB_D_CMD_STRUC_KILL_DAEMON,0,0,0) #-------------------------------------------------------------------------- - # Set my client name on tuxdaemon + # Set my client name on tuxd #-------------------------------------------------------------------------- def set_my_client_name(self,name): """ - Set my client name on tuxdaemon + Set my client name on tuxd Parameters: "name" as string : name of this client (max 11 char) @@ -3492,11 +3492,11 @@ self.last_ack=self.cmd_ack() #-------------------------------------------------------------------------- - # Get the version of tuxdaemon + # Get the version of tuxd #-------------------------------------------------------------------------- def get_version(self): """ - Get the version of tuxdaemon + Get the version of tuxd Return a string @@ -3513,11 +3513,11 @@ return "%d.%d.%d"%(result[0],result[1],result[2]) #-------------------------------------------------------------------------- - # Get the number of clients connected to tuxdaemon + # Get the number of clients connected to tuxd #-------------------------------------------------------------------------- def get_client_count(self): """ - Get the number of clients connected to tuxdaemon + Get the number of clients connected to tuxd Return an integer @@ -3532,11 +3532,11 @@ return 0 #-------------------------------------------------------------------------- - # Get the name of a client of tuxdaemon + # Get the name of a client of tuxd #-------------------------------------------------------------------------- def get_client_name(self,id_client): """ - Get the name of a client of tuxdaemon + Get the name of a client of tuxd Return a string @@ -3552,11 +3552,11 @@ return '' #-------------------------------------------------------------------------- - # Print the name of all the clients connected to tuxdaemon + # Print the name of all the clients connected to tuxd #-------------------------------------------------------------------------- def print_clients_name(self): """ - Print the name of all the clients connected to tuxdaemon + Print the name of all the clients connected to tuxd Example: >>> tux.daemon.print_clients_name() @@ -3566,11 +3566,11 @@ print "Client %.3d : %s"%(i,self.get_client_name(i)) #-------------------------------------------------------------------------- - # Get the client id of my connection to tuxdaemon + # Get the client id of my connection to tuxd #-------------------------------------------------------------------------- def get_my_client_id(self): """ - Get the client id of my connection to tuxdaemon + Get the client id of my connection to tuxd Return an integer @@ -3829,11 +3829,11 @@ Class which manages the text to speech Global variables of this class: - "connected" as boolean : State of the connection to tuxttsdaemon + "connected" as boolean : State of the connection to tuxttsd "print_status" as boolean : Allow to print the raw statuses - "sound_on" as boolean : Speaking state of the tuxttsdaemon - "on_connected" as pof : Event on tuxttsdaemon connected - "on_disconnected" as pof : Event on tuxttsdaemon disconnected + "sound_on" as boolean : Speaking state of the tuxttsd + "on_connected" as pof : Event on tuxttsd connected + "on_disconnected" as pof : Event on tuxttsd disconnected "on_sound_on" as pof : Event on tts speaking on "on_sound_off" as pof : Event on tts speaking off "on_voice_list" as pof : Event on new authorized voices list @@ -3892,14 +3892,13 @@ self.ac_port=5500 self.ac_address='localhost' self.authorized_voices_list = [] - self.voice_loaded = False #-------------------------------------------------------------------------- - # Allow to connect the api to tuxttsdaemon automatically + # Allow to connect the api to tuxttsd automatically #-------------------------------------------------------------------------- def auto_connect(self,value,address='ndef',port=0): """ - Allow to connect the api to tuxttsdaemon automatically + Allow to connect the api to tuxttsd automatically Parameters: "value" as boolean : turn on/off the auto_connect mode @@ -3950,12 +3949,12 @@ if self.connected!=last_connect_status: if self.connected: if self.parent.print_warnings: - print "CONNECTED to tuxttsdaemon" + print "CONNECTED to tuxttsd" if self.on_connected!=None: self.on_connected() else: if self.parent.print_warnings: - print "DISCONNECTED from tuxttsdaemon" + print "DISCONNECTED from tuxttsd" if self.on_disconnected!=None: self.on_disconnected() self._tcp_threads_join() @@ -3963,7 +3962,7 @@ self.parent.sys.wait(0.1) #-------------------------------------------------------------------------- - # Connect object to tuxttsdaemon + # Connect object to tuxttsd #-------------------------------------------------------------------------- def connect_to_daemon(self): """ @@ -3972,7 +3971,7 @@ return self.connect() def connect(self,address='localhost',port=5500): """ - Connect tts object to tuxttsdaemon + Connect tts object to tuxttsd Parameters: "port" as integer : Tcp/IP Port number @@ -4010,7 +4009,7 @@ return True #-------------------------------------------------------------------------- - # Disconnect tts object from tuxttsdaemon + # Disconnect tts object from tuxttsd #-------------------------------------------------------------------------- def disconnect_from_daemon(self): """ @@ -4019,7 +4018,7 @@ self.disconnect() def disconnect(self): """ - Disconnect tts object from tuxttsdaemon + Disconnect tts object from tuxttsd Example: >>> tux.tts.disconnect() @@ -4112,12 +4111,9 @@ self.authorized_voices_list.append(ord(voice_id)-1) if self.on_voice_list != None: self.on_voice_list() - # A voice has been loaded - if ord(data[1])==CMD_INFO_VOICE_OK: - self.voice_loaded = True #-------------------------------------------------------------------------- - # Send command to tuxttsdaemon + # Send command to tuxttsd #-------------------------------------------------------------------------- def send_command_to_tts(self,cmd_type,cmd,param1,param2,param3,param4): """ @@ -4297,19 +4293,9 @@ 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.voice_loaded == True + self.parent.cmd.audio_channel_tts() self.sock.send(text_to_send) counter = 0 - while ((self.voice_loaded == False) and (counter < 300)): - counter = counter + 1 - self.parent.sys.wait(0.1) - if counter == 300: - self.stop() - print "TTS Speak : Voice not loaded" - return False - print "Voice Loaded." - self.parent.cmd.audio_channel_tts() - counter = 0 while ((self.sound_on == False) and (counter < 100)): counter = counter + 1 self.parent.sys.wait(0.1) @@ -4383,11 +4369,11 @@ self.parent.sys.wait(0.1) #-------------------------------------------------------------------------- - # Send a command to tuxttsdaemon for getting the state of the sound + # Send a command to tuxttsd for getting the state of the sound #-------------------------------------------------------------------------- def get_sound_state(self): """ - Send a command to tuxttsdaemon for getting the state of + Send a command to tuxttsd for getting the state of the sound Example: @@ -4396,7 +4382,7 @@ self.send_command_to_tts(CMD_TYPE_INFO,CMD_INFO_SOUND_STATE,0,0,0,0) #-------------------------------------------------------------------------- - # Disconnect from tuxttsdaemon + # Disconnect from tuxttsd #-------------------------------------------------------------------------- def send_disconnect(self): """ @@ -4406,7 +4392,7 @@ 0,0,0,0) #-------------------------------------------------------------------------- - # Print the audio fifo state on tuxttsdaemon + # Print the audio fifo state on tuxttsd #-------------------------------------------------------------------------- def print_audio_fifo_state(self): """ @@ -4426,11 +4412,11 @@ CMD_DAEMON_PRINT_TUX_SOUND_CARDS,0,0,0,0) #-------------------------------------------------------------------------- - # Kill tuxttsdaemon + # Kill tuxttsd #-------------------------------------------------------------------------- def kill_daemon(self): """ - Kill the tuxttsdaemon + Kill the tuxttsd Example: >>> tux.tts.kill_daemon() |
From: remi <c2m...@c2...> - 2007-06-18 12:30:45
|
Author: remi Date: 2007-06-18 14:30:39 +0200 (Mon, 18 Jun 2007) New Revision: 394 Modified: api/python/trunk/tuxapi_class.py api/python/trunk/tuxapi_const.py Log: UPD API wait a voice loaded ACK in "tts.speak" methode Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-18 10:08:18 UTC (rev 393) +++ api/python/trunk/tuxapi_class.py 2007-06-18 12:30:39 UTC (rev 394) @@ -3892,6 +3892,7 @@ self.ac_port=5500 self.ac_address='localhost' self.authorized_voices_list = [] + self.voice_loaded = False #-------------------------------------------------------------------------- # Allow to connect the api to tuxttsdaemon automatically @@ -4111,6 +4112,9 @@ self.authorized_voices_list.append(ord(voice_id)-1) if self.on_voice_list != None: self.on_voice_list() + # A voice has been loaded + if ord(data[1])==CMD_INFO_VOICE_OK: + self.voice_loaded = True #-------------------------------------------------------------------------- # Send command to tuxttsdaemon @@ -4293,9 +4297,19 @@ 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.voice_loaded == True self.sock.send(text_to_send) counter = 0 + while ((self.voice_loaded == False) and (counter < 300)): + counter = counter + 1 + self.parent.sys.wait(0.1) + if counter == 300: + self.stop() + print "TTS Speak : Voice not loaded" + return False + print "Voice Loaded." + self.parent.cmd.audio_channel_tts() + counter = 0 while ((self.sound_on == False) and (counter < 100)): counter = counter + 1 self.parent.sys.wait(0.1) Modified: api/python/trunk/tuxapi_const.py =================================================================== --- api/python/trunk/tuxapi_const.py 2007-06-18 10:08:18 UTC (rev 393) +++ api/python/trunk/tuxapi_const.py 2007-06-18 12:30:39 UTC (rev 394) @@ -375,6 +375,7 @@ CMD_INFO_TTS_PLAYER_STATE = 0x01 CMD_INFO_SOUND_STATE = 0x02 CMD_INFO_VOICE_LIST = 0x03 +CMD_INFO_VOICE_OK = 0x04 # TTS INFO return TTS_SOUND_ON = 0x01 TTS_SOUND_OFF = 0x02 |
From: jaguarondi <c2m...@c2...> - 2007-06-18 10:08:49
|
Author: jaguarondi Date: 2007-06-18 12:08:18 +0200 (Mon, 18 Jun 2007) New Revision: 393 Modified: firmware/tuxup/trunk/tux-api.h firmware/tuxup/trunk/version.h Log: * Removed unused EXTERNAL_FLASH, we're not going to support that option within tuxup. * Bumped to version 0.1.2 (SVN/UNRELEASED). Modified: firmware/tuxup/trunk/tux-api.h =================================================================== --- firmware/tuxup/trunk/tux-api.h 2007-06-17 11:46:14 UTC (rev 392) +++ firmware/tuxup/trunk/tux-api.h 2007-06-18 10:08:18 UTC (rev 393) @@ -30,6 +30,6 @@ #define LIBUSB_I2C_HEADER 2 enum mem_type_t -{ FLASH, EEPROM, EXTERNAL_FLASH }; +{ FLASH, EEPROM }; #endif /* TUX_API_H */ Modified: firmware/tuxup/trunk/version.h =================================================================== --- firmware/tuxup/trunk/version.h 2007-06-17 11:46:14 UTC (rev 392) +++ firmware/tuxup/trunk/version.h 2007-06-18 10:08:18 UTC (rev 393) @@ -22,6 +22,6 @@ #ifndef version_h #define version_h -#define VERSION "0.1.1" +#define VERSION "0.1.2 (SVN/UNRELEASED)" #endif |
From: neimad <c2m...@c2...> - 2007-06-17 11:46:42
|
Author: neimad Date: 2007-06-17 13:46:14 +0200 (Sun, 17 Jun 2007) New Revision: 392 Modified: firmware/tuxup/trunk/main.c Log: * Beautified usage help a bit. Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-17 11:36:07 UTC (rev 391) +++ firmware/tuxup/trunk/main.c 2007-06-17 11:46:14 UTC (rev 392) @@ -79,22 +79,24 @@ fprintf(stream, "%s %s\n", program_name, program_version); fprintf(stream, "Usage: %s options [path|file ...]\n", program_name); fprintf(stream, - " -m --main Reprogram tuxcore and tuxaudio (flash and eeprom) with hex files located in path.\n" - " -a --all Reprogram all cpu's with hex files located in path.\n" - " -p --pretend Don't do the programming, just simulates.\n" - " -h --help Display this usage information.\n" - " -v --verbose Print verbose messages.\n" - " -V --version Print the version number.\n" "\n" + " -m --main Reprogram tuxcore and tuxaudio (flash and eeprom)\n" + " with hex files located in path.\n" + " -a --all Reprogram all cpu's with hex files located in path.\n" + " -p --pretend Don't do the programming, just simulate.\n" + " -h --help Display this usage information.\n" + " -v --verbose Print verbose messages.\n" + " -V --version Print the version number.\n" "\n" "Connection: connect the dongle alone, then press on tux's head\n" - " button while switching it on, finally connect the white cable\n" - " between tux and the dongle\n" "\n" - "Notes: '-a' and -'m' options can't be used simultaneously.\n" - " Inputfiles can be specified only if the -a or -m options are\n" - " not selected.\n" - " Any .hex or .eep files compiled for Tux Droid can be used.\n" - " The eeprom file names should contain 'tuxcore' or 'tuxaudio'\n" - " in order to be identified, the usb hex file should contain\n" - " 'fuxusb'.\n"); + " button while switching it on. Finally, connect the white cable\n" + " between tux and the dongle.\n" "\n" + "Notes:\n" + " * Options '-a' and -'m' can't be used simultaneously.\n" + " * Inputfiles can be specified only if the -a and -m options are\n" + " not selected.\n" + " * Any .hex or .eep files compiled for Tux Droid can be used.\n" + " * The eeprom file names should contain 'tuxcore' or 'tuxaudio'\n" + " in order to be identified. The usb hex file should contain\n" + " 'fuxusb'.\n"); exit(exit_code); } |
From: neimad <c2m...@c2...> - 2007-06-17 11:36:11
|
Author: neimad Date: 2007-06-17 13:36:07 +0200 (Sun, 17 Jun 2007) New Revision: 391 Modified: firmware/tuxup/trunk/main.c Log: * Simplified the Tux detection loop. Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-17 11:26:12 UTC (rev 390) +++ firmware/tuxup/trunk/main.c 2007-06-17 11:36:07 UTC (rev 391) @@ -109,33 +109,31 @@ for (;;) { device = usb_find_tux(); - if (device == NULL) - { - if (!wait) - { - fprintf(stderr, "The dongle was not found, now exiting.\n"); - exit(1); - } - } - else - { - if (verbose) - printf("The dongle was found.\n"); - /* Check if we have the old firmware that requires entering - * bootloader mode manually, exits with a message that exlains what - * to do in such a case. */ - if (device->descriptor.bcdDevice < 0x100) - { - fprintf(stderr, msg_old_firmware); - exit(1); - } + if (device != NULL || wait == 0) break; - } sleep(1); wait--; } + if (device == NULL) + { + fprintf(stderr, "The dongle was not found, now exiting.\n"); + exit(1); + } + + if (verbose) + printf("The dongle was found.\n"); + + /* Check if we have the old firmware that requires entering + * bootloader mode manually, exits with a message that exlains what + * to do in such a case. */ + if (device->descriptor.bcdDevice < 0x100) + { + fprintf(stderr, msg_old_firmware); + exit(1); + } + /* open USB device */ if ((dev_h = usb_open_tux(device)) == NULL) { |
From: neimad <c2m...@c2...> - 2007-06-17 11:26:14
|
Author: neimad Date: 2007-06-17 13:26:12 +0200 (Sun, 17 Jun 2007) New Revision: 390 Modified: firmware/tuxup/trunk/main.c Log: * Show the user what syntax error he made. Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-17 11:21:18 UTC (rev 389) +++ firmware/tuxup/trunk/main.c 2007-06-17 11:26:12 UTC (rev 390) @@ -564,11 +564,17 @@ if (argc == optind + 1) strcpy(path, argv[optind]); else + { + fprintf(stderr, "too many files or paths specified.\n\n"); usage(stderr, 1); + } } } - else /* No arguments given. */ + else + { + fprintf(stderr, "no file nor path specified.\n\n"); usage(stderr, 1); + } /* Select which files to program */ switch (program_mode) |
From: neimad <c2m...@c2...> - 2007-06-17 11:21:19
|
Author: neimad Date: 2007-06-17 13:21:18 +0200 (Sun, 17 Jun 2007) New Revision: 389 Modified: firmware/tuxup/trunk/main.c Log: * Heh, of course I should have known that searching for ")0" wouldn't show other (time_t *)0 casts. So much for consistency... Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-17 10:52:07 UTC (rev 388) +++ firmware/tuxup/trunk/main.c 2007-06-17 11:21:18 UTC (rev 389) @@ -492,7 +492,7 @@ /*program_name = argv[0]; */ /* Save the start time to measure the programming time */ - start_time = time((time_t *) 0); + start_time = time(NULL); do { |
From: neimad <c2m...@c2...> - 2007-06-17 10:52:14
|
Author: neimad Date: 2007-06-17 12:52:07 +0200 (Sun, 17 Jun 2007) New Revision: 388 Modified: firmware/tuxup/trunk/main.c Log: * Yet another indentation fix. Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-17 10:48:31 UTC (rev 387) +++ firmware/tuxup/trunk/main.c 2007-06-17 10:52:07 UTC (rev 388) @@ -324,9 +324,8 @@ ret = system("dfu-programmer at89c5130 get bootloader-version"); } else - ret = - system - ("dfu-programmer at89c5130 get bootloader-version 2> /dev/null"); + ret = system("dfu-programmer at89c5130 get bootloader-version" + " 2> /dev/null"); /* If dfu-programmer didn't detect the dongle, we try to set it in bootloader mode with the specific command */ |
From: neimad <c2m...@c2...> - 2007-06-17 10:48:35
|
Author: neimad Date: 2007-06-17 12:48:31 +0200 (Sun, 17 Jun 2007) New Revision: 387 Modified: firmware/tuxup/trunk/main.c Log: * Aligned entries of long options array for better readability. Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-17 10:44:45 UTC (rev 386) +++ firmware/tuxup/trunk/main.c 2007-06-17 10:48:31 UTC (rev 387) @@ -479,13 +479,13 @@ /* An array describing valid long options. */ const struct option long_options[] = { - {"main", 0, NULL, 'm'}, - {"all", 0, NULL, 'a'}, + {"main", 0, NULL, 'm'}, + {"all", 0, NULL, 'a'}, {"pretend", 0, NULL, 'p'}, - {"help", 0, NULL, 'h'}, + {"help", 0, NULL, 'h'}, {"verbose", 0, NULL, 'v'}, {"version", 0, NULL, 'V'}, - {NULL, 0, NULL, 0} /* Required at end of array. */ + {NULL, 0, NULL, 0} /* Required at end of array. */ }; /* Remember the name of the program, to incorporate in messages. |
From: neimad <c2m...@c2...> - 2007-06-17 10:44:48
|
Author: neimad Date: 2007-06-17 12:44:45 +0200 (Sun, 17 Jun 2007) New Revision: 386 Modified: firmware/tuxup/trunk/main.c Log: * Made all functions static and several global variables and parameters const. * Fixed several lines longer than 80 columns, yet again... Modified: firmware/tuxup/trunk/main.c =================================================================== --- firmware/tuxup/trunk/main.c 2007-06-17 10:31:07 UTC (rev 385) +++ firmware/tuxup/trunk/main.c 2007-06-17 10:44:45 UTC (rev 386) @@ -32,7 +32,7 @@ #include "common/commands.h" /* Messages. */ -const char *msg_old_firmware = +static const char *msg_old_firmware = "\nERROR: Your dongle firmware is too old to support switching to bootloader" "\nmode automatically.\n" "\n To enter bootloading mode manually, you need to unplug the dongle, press" @@ -46,39 +46,35 @@ "\nCheck http://www.tuxisalive.com/documentation/how-to/updating-the-firmware" "\nfor more details.\n"; -const char *msg_dfu_programmer_not_installed = +static const char *msg_dfu_programmer_not_installed = "\nERROR: dfu-programmer is not installed or is not in your path, tuxup uses" "\nit to reprogram the USB cpu so installing dfu-programmer is mandatory.\n"; /* Programming modes. */ -enum program_modes_t -{ NONE, ALL, MAIN, INPUTFILES }; +enum program_modes_t { NONE, ALL, MAIN, INPUTFILES }; /* The name of this program. */ -const char *program_name = "tuxup"; +static const char *program_name = "tuxup"; /* The version defined in version.h */ -const char *program_version = VERSION; +static const char *program_version = VERSION; -/* Pointer o the input hex file */ -FILE *hex_file; - /* Whether to display verbose messages. */ int verbose = 0; /* Pretend option. */ -int pretend = 0; +static int pretend = 0; /* USB handle */ -struct usb_device *device; -struct usb_dev_handle *dev_h; -int usb_connected = 0; /* Flag for usb connection status */ +static struct usb_device *device; +static struct usb_dev_handle *dev_h; +static int usb_connected = 0; /* Flag for usb connection status */ /* * Prints usage information for this program to STREAM (typically * stdout or stderr), and exit the program with EXIT_CODE. Does not return. */ -void usage(FILE * stream, int exit_code) +static void usage(FILE *stream, int exit_code) { fprintf(stream, "%s %s\n", program_name, program_version); fprintf(stream, "Usage: %s options [path|file ...]\n", program_name); @@ -102,7 +98,7 @@ exit(exit_code); } -void fux_connect(void) +static void fux_connect(void) { int wait = 5; @@ -151,7 +147,7 @@ usb_connected = 1; } -void fux_disconnect(void) +static void fux_disconnect(void) { if (!usb_connected) return; @@ -164,7 +160,7 @@ usb_connected = 0; } -int hex_to_i(char *hex_nr) +static int hex_to_i(char *hex_nr) { int nr; @@ -178,7 +174,7 @@ * from the hex file and returns 0 if the hex file has a cpu and version * numbers, 1 otherwise. */ -int check_hex_file(char *filename, version_bf_t * version) +static int check_hex_file(const char *filename, version_bf_t * version) { FILE *fs = NULL; char word[80]; @@ -211,7 +207,7 @@ return 1; } -int prog_flash(char *filename) +static int prog_flash(const char *filename) { version_bf_t version; uint8_t cpu_i2c_addr; @@ -222,9 +218,8 @@ if (check_hex_file(filename, &version)) { - printf - ("[FAIL] Programming of '%s' failed, this file is not a correct hex file for that CPU\n\n", - filename); + printf("[FAIL] Programming of '%s' failed, this file is not a correct" + " hex file for that CPU\n\n", filename); return 1; } printf("Programming %s in the ", filename); @@ -250,9 +245,8 @@ } else { - printf - ("Unrecognized CPU number, %s doesn't appear to be compiled for a CPU of tuxdroid.\n", - filename); + printf("Unrecognized CPU number, %s doesn't appear to be compiled" + " for a CPU of tuxdroid.\n", filename); return 1; } printf("Version %d.%d.%d\n", version.ver_major, version.ver_minor, @@ -271,7 +265,7 @@ return 1; } -int prog_eeprom(uint8_t cpu_nbr, char *filename) +static int prog_eeprom(uint8_t cpu_nbr, const char *filename) { uint8_t cpu_i2c_addr; @@ -309,9 +303,10 @@ return 1; } -int prog_usb(char *filename) +static int prog_usb(const char *filename) { - uint8_t send_data[5] = { 0x01, 0x01, 0x00, 0x00, 0xFF }; /* XXX include those as defines in commands.h */ + /* XXX include those as defines in commands.h */ + uint8_t send_data[5] = { 0x01, 0x01, 0x00, 0x00, 0xFF }; char tmp_string[90]; int ret; @@ -333,11 +328,13 @@ system ("dfu-programmer at89c5130 get bootloader-version 2> /dev/null"); - /* If dfu-programmer didn't detect the dongle, we try to set it in bootloader mode with the specific command */ + /* If dfu-programmer didn't detect the dongle, we try to set it in + bootloader mode with the specific command */ if (ret) { /* Check if dfu-programmer is installed */ - if (ret == 32512) /* XXX a better way to code that error, a define? */ + /* XXX a better way to code that error, a define? */ + if (ret == 32512) { fprintf(stdout, msg_dfu_programmer_not_installed); exit(1); @@ -392,8 +389,12 @@ return 0; } -/* Programming function. Depending on the name, the flash or eeprom programming will be selected. In case of eeprom, the correct CPU will be choosen from the filename. */ -int program(char *filename, char *path) +/* + * Programming function. Depending on the name, the flash or eeprom + * programming will be selected. In case of eeprom, the correct CPU + * will be choosen from the filename. + */ +static int program(char *filename, char *path) { int ret = -1; size_t len; @@ -403,8 +404,9 @@ { /* Checking path */ len = strlen(path); + /* Append '/' at the end if not specified. */ if (path[len - 1] != '/') - strcat(path, "/"); /* Append '/' at the end if not specified. */ + strcat(path, "/"); strcpy(filenamepath, path); strcat(filenamepath, filename); filename = filenamepath; @@ -413,7 +415,8 @@ printf("Processing: %s\n", filename); extension = strrchr(filename, '.'); - if (extension) /* check that an extension has been given */ + /* check that an extension has been given */ + if (extension) { /* Check which program function to start. */ if (!strcmp(extension, ".hex")) |
From: neimad <c2m...@c2...> - 2007-06-17 10:31:10
|
Author: neimad Date: 2007-06-17 12:31:07 +0200 (Sun, 17 Jun 2007) New Revision: 385 Modified: firmware/tuxup/trunk/usb-connection.c Log: * Fixed indentation broken by automated re-indentation. * Comply with 80 columns limit. * Removed unnecessary curly braces and parentheses. Modified: firmware/tuxup/trunk/usb-connection.c =================================================================== --- firmware/tuxup/trunk/usb-connection.c 2007-06-17 10:17:31 UTC (rev 384) +++ firmware/tuxup/trunk/usb-connection.c 2007-06-17 10:31:07 UTC (rev 385) @@ -53,16 +53,11 @@ usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) - { for (device = bus->devices; device; device = device->next) - { - if ((device->descriptor.idVendor == TUX_VENDOR_ID) - && (device->descriptor.idProduct == TUX_PRODUCT_ID)) - { + if (device->descriptor.idVendor == TUX_VENDOR_ID + && device->descriptor.idProduct == TUX_PRODUCT_ID) return device; - } - } - } + return NULL; } @@ -77,10 +72,9 @@ usb_dev_handle *dev_h; if (!(dev_h = usb_open(dev))) - { return NULL; - } - else if (verbose) + + if (verbose) printf("Device opened\n"); err = usb_claim_interface(dev_h, USB_COMMAND); @@ -95,8 +89,10 @@ return NULL; } } + if (verbose) printf("USB interface claimed successfully \n"); + return dev_h; } @@ -114,31 +110,34 @@ /** * \brief Send commands to Tux's dongle + * * \param dev_h USB device handle * \return USB communication status * - * \todo Need to define the format of the data array to send and pass it as parameter + * \todo Need to define the format of the data array to send and pass + * it as parameter * \todo Need to add some doc or links about what this status is really */ int usb_send_commands(usb_dev_handle * dev_h, uint8_t * send_data, int size) { int status; - if ((status = - usb_interrupt_write(dev_h, USB_W_ENDPOINT, (char *)send_data, size, - USB_W_TIMEOUT)) < 0) + status = usb_interrupt_write(dev_h, USB_W_ENDPOINT, (char *)send_data, size, + USB_W_TIMEOUT); + if (status < 0) + { /* error on usb_interrupt_write() */ - { fprintf(stderr, "usb_interrupt_write error: status = %d :: %s \n", status, usb_strerror()); } - else /* success */ + else { + /* success */ #if (PRINT_DATA) - printf - ("usb_interrupt_write: status =%d -> TX Buffer[%d]={%2X, %2X, %2X, %2X, %2X}\n", - status, status, send_data[0], send_data[1], send_data[2], - send_data[3], send_data[4]); + printf("usb_interrupt_write: status =%d" + " -> TX Buffer[%d]={%2X, %2X, %2X, %2X, %2X}\n", + status, status, send_data[0], send_data[1], send_data[2], + send_data[3], send_data[4]); #endif } return status; @@ -146,19 +145,21 @@ /** * \brief Get commands from Tux's dongle + * * \param dev_h USB device handle * \return USB communication status * - * \todo Need to define the format of the data array to send and pass it as parameter + * \todo Need to define the format of the data array to send and pass + * it as parameter * \todo Need to add some doc or links about what this status is really */ int usb_get_commands(usb_dev_handle * dev_h, uint8_t * receive_data, int size) { int status; - if ((status = - usb_interrupt_read(dev_h, USB_R_ENDPOINT, (char *)receive_data, size, - USB_R_TIMEOUT)) < 0) + status = usb_interrupt_read(dev_h, USB_R_ENDPOINT, (char *)receive_data, + size, USB_R_TIMEOUT); + if (status < 0) { fprintf(stderr, "usb_interrupt_read error: status = %d :: %s \n", status, usb_strerror()); @@ -167,10 +168,10 @@ { /* XXX this is only to test and display what has been received */ #if (PRINT_DATA) - printf - ("usb_interrupt_read: status = %d -> TX Buffer[%d]={%hX, %hX, %hX, %hX, %hX}\n", - status, status, receive_data[0], receive_data[1], receive_data[2], - receive_data[3], receive_data[4]); + printf("usb_interrupt_read: status = %d" + "-> TX Buffer[%d]={%hX, %hX, %hX, %hX, %hX}\n", + status, status, receive_data[0], receive_data[1], receive_data[2], + receive_data[3], receive_data[4]); #endif } return status; |
From: neimad <c2m...@c2...> - 2007-06-17 10:17:39
|
Author: neimad Date: 2007-06-17 12:17:31 +0200 (Sun, 17 Jun 2007) New Revision: 384 Modified: firmware/tuxup/trunk/tux-api.h Log: * Fixed case of one of enum mem_type_t's value. Btw this value (EXTERNAL_FLASH) is not used anywhere. Remove it ? Modified: firmware/tuxup/trunk/tux-api.h =================================================================== --- firmware/tuxup/trunk/tux-api.h 2007-06-17 10:07:50 UTC (rev 383) +++ firmware/tuxup/trunk/tux-api.h 2007-06-17 10:17:31 UTC (rev 384) @@ -30,6 +30,6 @@ #define LIBUSB_I2C_HEADER 2 enum mem_type_t -{ FLASH, EEPROM, EXTERNAL_FlasH }; +{ FLASH, EEPROM, EXTERNAL_FLASH }; #endif /* TUX_API_H */ |
From: neimad <c2m...@c2...> - 2007-06-17 10:07:53
|
Author: neimad Date: 2007-06-17 12:07:50 +0200 (Sun, 17 Jun 2007) New Revision: 383 Modified: firmware/tuxup/trunk/bootloader.c Log: * Fixed lots of comments going far beyond the 80 columns limit (see coding style guidelines). Modified: firmware/tuxup/trunk/bootloader.c =================================================================== --- firmware/tuxup/trunk/bootloader.c 2007-06-17 09:50:17 UTC (rev 382) +++ firmware/tuxup/trunk/bootloader.c 2007-06-17 10:07:50 UTC (rev 383) @@ -79,11 +79,11 @@ FILE_ParsedData_t parsedData; /* Last hunk of data parsed */ FILE_Addr_t segAddr; /* Address of the segment in memory */ FILE_SegmentLen_t segLen; /* Length of the segment in memory */ - int inSeg; /* We've started a segment which hasn't been finished yet */ - FILE_Addr_t currAddr; /* The current address in memory being processed */ + int inSeg; /* Inside a segment */ + FILE_Addr_t currAddr; /* Current address in memory being processed */ uint8_t *segmentData; /* Complete segment data */ - int segmentDataIdx; /* index used for filling in the segment data */ - usb_dev_handle *dev_handle; /* usb device handle for sending parsed data */ + int segmentDataIdx; /* Index used for filling in the segment data */ + usb_dev_handle *dev_handle; /* USB device handle for sending parsed data */ } Parser_t; /** @@ -231,16 +231,19 @@ static int startSegment(Parser_t * parser) { parser->segmentDataIdx = 0; + /* set segment address */ parser->segmentData[parser->segmentDataIdx++] = (uint8_t) (parser->segAddr >> 8); parser->segmentData[parser->segmentDataIdx++] = (uint8_t) parser->segAddr; + /* fill with '0xFF' if necessary */ while (parser->currAddr < parser->parsedData.addr) { parser->segmentData[parser->segmentDataIdx++] = 0xFF; parser->currAddr++; } + return TRUE; } @@ -265,9 +268,12 @@ uint8_t data_buffer[36]; int ret; - parser->inSeg = FALSE; /* inidicates that we completed a segment */ + /* Indicate that we completed a segment */ + parser->inSeg = FALSE; + #if (PRINT_DATA) - printf("segment data: \n"); /* XXX debug */ + /* XXX debug */ + printf("segment data: \n"); for (i = 0; i < parser->segLen + 2; i++) printf("%02x", parser->segmentData[i]); printf("\n"); @@ -275,13 +281,19 @@ data_buffer[0] = LIBUSB_I2C_HEADER; data_buffer[1] = BOOT_FILLPAGE; + + /* + * Send first packet + */ for (i = 2; i < 36; i++) - data_buffer[i] = parser->segmentData[idx++]; /* send first packet */ + data_buffer[i] = parser->segmentData[idx++]; /* EEPROM handling */ if (mem_type == EEPROM) { - usleep(200000); /* try to solve the programming problem with some boards */ - data_buffer[2] |= 0x80; /* set the last bit to 1 to indicate eeprom type to the bootloader */ + /* try to solve the programming problem with some boards */ + usleep(200000); + /* set the last bit to 1 to indicate eeprom type to the bootloader */ + data_buffer[2] |= 0x80; } ret = usb_send_commands(parser->dev_handle, data_buffer, 36); #if (PRINT_DATA) @@ -289,8 +301,12 @@ #endif if (ret != 36) return FALSE; + + /* + * Send second packet + */ for (i = 2; i < 34; i++) - data_buffer[i] = parser->segmentData[idx++]; /* send second packet */ + data_buffer[i] = parser->segmentData[idx++]; keybreak(); ret = usb_send_commands(parser->dev_handle, data_buffer, 34); #if (PRINT_DATA) @@ -300,11 +316,15 @@ return FALSE; keybreak(); + + /* + * Bootlader status command and result + */ ret = usb_get_commands(parser->dev_handle, data_buffer, 5); #if (PRINT_DATA) printf("Status of feedback from bootloader: %x\n", ret); #endif - if ((ret == 5) && (data_buffer[0] == 0xF0) && (data_buffer[1] == 0)) /* Bootlader status command and result */ + if ((ret == 5) && (data_buffer[0] == 0xF0) && (data_buffer[1] == 0)) { printf("."); return TRUE; @@ -324,7 +344,6 @@ * * @return TRUE if parsing should continue, FALSE if it should stop. */ - static int ParsedData(Parser_t * parser, int lastSeg) { FILE_ParsedData_t *parsedData = &parser->parsedData; @@ -335,7 +354,8 @@ #if (PRINT_DATA) printf("--last segment --\n"); #endif - while (parser->currAddr < (parser->segAddr + parser->segLen)) /* fill with '0' until the end of segment */ + /* fill with '0' until the end of segment */ + while (parser->currAddr < (parser->segAddr + parser->segLen)) { fillSegment(parser, 0xFF); } @@ -351,11 +371,14 @@ #endif if (!parser->inSeg) { - parser->currAddr = parsedData->addr & ~(parser->segLen - 1); /* set current address at the segment start by zeroing lower bits */ + /* set current address at the segment start by zeroing lower bits */ + parser->currAddr = parsedData->addr & ~(parser->segLen - 1); break; } fillSegment(parser, 0xFF); - if (parser->currAddr == (parser->segAddr + parser->segLen)) /* end of segment */ + + /* end of segment ? */ + if (parser->currAddr == (parser->segAddr + parser->segLen)) { finishSegment(parser); } @@ -370,19 +393,24 @@ #if (PRINT_DATA) printf("--loop--"); #endif - if (!parser->inSeg) /* start a new segment if needed */ + /* start a new segment if needed */ + if (!parser->inSeg) { #if (PRINT_DATA) printf("--new segment--\n"); #endif parser->inSeg = TRUE; - parser->segAddr = parser->currAddr; /* set address of the segment start */ + /* set address of the segment start */ + parser->segAddr = parser->currAddr; startSegment(parser); } + /* store data in segmentData */ fillSegment(parser, parsedData->data[dataIdx]); dataIdx++; - if (parser->currAddr == (parser->segAddr + parser->segLen)) /* end of segment */ + + /* end of segment ? */ + if (parser->currAddr == (parser->segAddr + parser->segLen)) { #if (PRINT_DATA) printf("--end segment--"); @@ -425,9 +453,8 @@ if (line[0] != ':') { - // In Intel Hex format, lines which don't start with ':' are - // supposed to be ignored. - + /* In Intel Hex format, lines which don't start with ':' are + supposed to be ignored */ return TRUE; } @@ -523,8 +550,13 @@ memset(&parser, 0, sizeof(parser)); /* clear all parser elements */ - parser.segLen = 0x40; /* TODO get this value from either the file or the main program. What if we get an ATM168? */ - parser.dev_handle = dev_h; /* XXX this is not a good way to pass the handle up to finsihSegment, any better idea? */ + /* TODO get this value from either the file or the main program. + What if we get an ATM168? */ + parser.segLen = 0x40; + /* XXX this is not a good way to pass the handle up to + finishSegment, any better idea? */ + parser.dev_handle = dev_h; + if ((parser.segmentData = malloc(parser.segLen + 2)) == NULL) { fprintf(stderr, "Unable to allocate segmentData space"); @@ -570,8 +602,8 @@ { int rc = FALSE; uint8_t data_buffer[5]; - uint8_t page_size = 64; /* XXX should be adapted depending on the CPU type, how to do this? */ - uint8_t packet_total = 2; /* XXX should be adapted depending on the CPU type, how to do this? */ + uint8_t page_size = 64; /* XXX Should depend on CPU type */ + uint8_t packet_total = 2; /* XXX should depend on CPU type */ int ret; /* Set global variable mem_type to the memory type */ |
From: neimad <c2m...@c2...> - 2007-06-17 09:50:22
|
Author: neimad Date: 2007-06-17 11:50:17 +0200 (Sun, 17 Jun 2007) New Revision: 382 Modified: firmware/tuxup/trunk/bootloader.c Log: * Deleted unused variable "hexFile". * Made most functions static. * Merged doxygen comments of those functions who had separate doxygen comments for function description and parameter descriptions. Also fixed these comments: they were all taking about nibbles, while some actually parsed bytes or words. Copy/paste jobs suck ;-) Modified: firmware/tuxup/trunk/bootloader.c =================================================================== --- firmware/tuxup/trunk/bootloader.c 2007-06-17 09:31:19 UTC (rev 381) +++ firmware/tuxup/trunk/bootloader.c 2007-06-17 09:50:17 UTC (rev 382) @@ -56,8 +56,6 @@ #define BOOT_FILLPAGE 2 #define BOOT_EXIT 2 -static const char *hexFile = NULL; - typedef uint32_t FILE_Addr_t; typedef uint32_t FILE_SegmentLen_t; typedef unsigned FILE_LineNum_t; @@ -92,7 +90,7 @@ * Clears any data stored in the parsed data */ -void ClearData(FILE_ParsedData_t * parsedData) +static void ClearData(FILE_ParsedData_t * parsedData) { if (parsedData->dataAlloc > 0) { @@ -105,7 +103,7 @@ * Releases any allocated data in the parsed data buffer. */ -void FreeData(FILE_ParsedData_t * parsedData) +static void FreeData(FILE_ParsedData_t * parsedData) { if (parsedData->dataAlloc > 0) { @@ -120,7 +118,7 @@ * Allocates (or reallocates) the data buffer */ -uint8_t *AllocData(FILE_ParsedData_t * parsedData, FILE_ParsedLen_t reqLen) +static uint8_t *AllocData(FILE_ParsedData_t * parsedData, FILE_ParsedLen_t reqLen) { if (reqLen <= parsedData->dataAlloc) { @@ -141,16 +139,17 @@ } // AllocData /** - * Parses a single nibble from a string containing ASCII Hex characters. + * Parses a single nibble from a string containing ASCII Hex characters. * - * @return TRUE, if a nibble was parsed successfully, FALSE otherwise. + * @param[in,out] parser Parser object that we're reporting about + * @param[in,out] s Pointer to string; will be advanced. + * @param[out] b Nibble that was parsed + * @param[int] label Error string (used for reporting errors) + * + * @return TRUE, if a nibble was parsed successfully, FALSE otherwise. */ - -int GetNibble(Parser_t * parser, ///< (mod) Parser object that we're reporting about. - const char **s, ///< (mod) Pointer to string. Will be advanced. - unsigned char *b, ///< (out) nibble that was parsed. - const char *label ///< (in) Error string (used for reporting errors). - ) +static int GetNibble(Parser_t * parser, const char **s, unsigned char *b, + const char *label) { char ch = **s; @@ -180,16 +179,17 @@ } // GetNibble /** - * Parses a single byte from a string containing ASCII Hex characters. + * Parses a single byte from a string containing ASCII Hex characters. * - * @return TRUE, if a byte was parsed successfully, FALSE otherwise. + * @param[in,out] parser Parser object that we're reporting about + * @param[in,out] s Pointer to string; will be advanced + * @param[out] b Byte that was parsed + * @param[in] label Error string (used for reporting errors) + * + * @return TRUE, if a byte was parsed successfully, FALSE otherwise. */ - -int GetByte(Parser_t * parser, ///< (mod) Parser object that we're reporting about. - const char **s, ///< (mod) Pointer to string. Will be advanced. - unsigned char *b, ///< (out) nibble that was parsed. - const char *label ///< (in) Error string (used for reporting errors). - ) +static int GetByte(Parser_t * parser, const char **s, unsigned char *b, + const char *label) { unsigned char b1, b2; @@ -204,16 +204,17 @@ } // GetByte /** - * Parses two bytes from a string containing ASCII Hex characters. + * Parses two bytes from a string containing ASCII Hex characters. * - * @return TRUE, if a byte was parsed successfully, FALSE otherwise. + * @param[in,out] parser Parser object that we're reporting about + * @param[in,out] s Pointer to string; will be advanced + * @param[out] b Word that was parsed + * @param[in] label Error string (used for reporting errors) + * + * @return TRUE, if a byte was parsed successfully, FALSE otherwise. */ - -int GetWord(Parser_t * parser, ///< (mod) Parser object that we're reporting about. - const char **s, ///< (mod) Pointer to string. Will be advanced. - unsigned short *b, ///< (out) nibble that was parsed. - const char *label ///< (in) Error string (used for reporting errors). - ) +static int GetWord(Parser_t * parser, const char **s, unsigned short *b, + const char *label) { unsigned char b1, b2; @@ -227,7 +228,7 @@ } // GetWord -int startSegment(Parser_t * parser) +static int startSegment(Parser_t * parser) { parser->segmentDataIdx = 0; /* set segment address */ @@ -246,7 +247,7 @@ /** * Put one byte of data in the segmentData */ -int fillSegment(Parser_t * parser, uint8_t data) +static int fillSegment(Parser_t * parser, uint8_t data) { parser->segmentData[parser->segmentDataIdx++] = data; parser->currAddr++; @@ -324,7 +325,7 @@ * @return TRUE if parsing should continue, FALSE if it should stop. */ -int ParsedData(Parser_t * parser, int lastSeg) +static int ParsedData(Parser_t * parser, int lastSeg) { FILE_ParsedData_t *parsedData = &parser->parsedData; @@ -414,7 +415,7 @@ * See: http://www.xess.com/faq/intelhex.pdf for the complete spec */ -int parseIHexLine(Parser_t * parser, const char *line) +static int parseIHexLine(Parser_t * parser, const char *line) { int i; FILE_ParsedData_t *parsedData = &parser->parsedData; @@ -513,7 +514,7 @@ * Parses an intel hex file, calling the appropriate callbacks along the way */ -int FILE_ParseFile(usb_dev_handle * dev_h, const char *fileName) +static int FILE_ParseFile(usb_dev_handle * dev_h, const char *fileName) { FILE *fs = NULL; Parser_t parser; |