DOCUMENTATION OF TUXDROID PYTHON API 0.2.0 (SVN/UNRELEASED)
Table of content :
1) Class : tux (tuxapi_class.TUXTCPCommunicator)
1.1) Class : tux.cmd (tuxapi_class.TUXcmd)
1.1.1) Function : tux.cmd.audio_channel_general
1.1.2) Function : tux.cmd.audio_channel_tts
1.1.3) Function : tux.cmd.eyes_close
1.1.4) Function : tux.cmd.eyes_off
1.1.5) Function : tux.cmd.eyes_on
1.1.6) Function : tux.cmd.eyes_on_free
1.1.7) Function : tux.cmd.eyes_open
1.1.8) Function : tux.cmd.ir_off
1.1.9) Function : tux.cmd.ir_on
1.1.10) Function : tux.cmd.ir_send
1.1.11) Function : tux.cmd.ledl_during
1.1.12) Function : tux.cmd.ledl_during_free
1.1.13) Function : tux.cmd.ledl_off
1.1.14) Function : tux.cmd.ledl_on
1.1.15) Function : tux.cmd.ledr_during
1.1.16) Function : tux.cmd.ledr_during_free
1.1.17) Function : tux.cmd.ledr_off
1.1.18) Function : tux.cmd.ledr_on
1.1.19) Function : tux.cmd.leds_blink
1.1.20) Function : tux.cmd.leds_during
1.1.21) Function : tux.cmd.leds_during_free
1.1.22) Function : tux.cmd.leds_off
1.1.23) Function : tux.cmd.leds_on
1.1.24) Function : tux.cmd.mouth_close
1.1.25) Function : tux.cmd.mouth_off
1.1.26) Function : tux.cmd.mouth_on
1.1.27) Function : tux.cmd.mouth_on_free
1.1.28) Function : tux.cmd.mouth_open
1.1.29) Function : tux.cmd.ping
1.1.30) Function : tux.cmd.raw
1.1.31) Function : tux.cmd.sleep_off
1.1.32) Function : tux.cmd.sleep_on
1.1.33) Function : tux.cmd.sound_play
1.1.34) Function : tux.cmd.sound_store_index
1.1.35) Function : tux.cmd.sound_storing
1.1.36) Function : tux.cmd.sound_test
1.1.37) Function : tux.cmd.spinl_off
1.1.38) Function : tux.cmd.spinl_on
1.1.39) Function : tux.cmd.spinl_on_free
1.1.40) Function : tux.cmd.spinr_off
1.1.41) Function : tux.cmd.spinr_on
1.1.42) Function : tux.cmd.spinr_on_free
1.1.43) Function : tux.cmd.structured
1.1.44) Function : tux.cmd.wings_off
1.1.45) Function : tux.cmd.wings_on
1.1.46) Function : tux.cmd.wings_on_free
1.2) Class : tux.daemon (tuxapi_class.TUXdaemon)
1.2.1) Function : tux.daemon.auto_connect
1.2.2) Function : tux.daemon.connect
1.2.3) Function : tux.daemon.disconnect
1.2.4) Function : tux.daemon.disconnect_client
1.2.5) Function : tux.daemon.get_client_count
1.2.6) Function : tux.daemon.get_client_name
1.2.7) Function : tux.daemon.get_my_client_id
1.2.8) Function : tux.daemon.get_version
1.2.9) Function : tux.daemon.kill
1.2.10) Function : tux.daemon.print_clients_name
1.2.11) Function : tux.daemon.set_my_client_name
1.3) Class : tux.event (tuxapi_class.TUXevent)
1.3.1) Function : tux.event.clear
1.3.2) Function : tux.event.remote_key_to_string
1.3.3) Function : tux.event.restore
1.3.4) Function : tux.event.store
1.3.5) Function : tux.event.wait_bt_pushed
1.3.6) Function : tux.event.wait_head_bt_pushed
1.3.7) Function : tux.event.wait_head_bt_released
1.3.8) Function : tux.event.wait_lwing_bt_pushed
1.3.9) Function : tux.event.wait_lwing_bt_released
1.3.10) Function : tux.event.wait_remote_bt
1.3.11) Function : tux.event.wait_rwing_bt_pushed
1.3.12) Function : tux.event.wait_rwing_bt_released
1.3.13) Function : tux.event.wait_stable_status
1.3.14) Function : tux.event.wait_status
1.4) Class : tux.hw (tuxapi_class.TUXhw)
1.4.1) Function : tux.hw.alsa_devices_count
1.4.2) Function : tux.hw.alsa_devices_select
1.4.3) Function : tux.hw.audio_get_version
1.4.4) Function : tux.hw.behavior_get_version
1.4.5) Function : tux.hw.donglerf_get_version
1.4.6) Function : tux.hw.tuxrf_get_version
1.5) Class : tux.misc (tuxapi_class.TUXmisc)
1.5.1) Function : tux.misc.doc
1.5.2) Function : tux.misc.build_documentation
1.5.3) Function : tux.misc.print_api_version
1.6) Class : tux.status (tuxapi_class.TUXStatus)
1.6.1) Function : tux.status.charger_state
1.6.2) Function : tux.status.eyes_closed
1.6.3) Function : tux.status.eyes_counter
1.6.4) Function : tux.status.eyes_motor
1.6.5) Function : tux.status.eyes_opened
1.6.6) Function : tux.status.get
1.6.7) Function : tux.status.head_bt
1.6.8) Function : tux.status.ir_led
1.6.9) Function : tux.status.ir_signal
1.6.10) Function : tux.status.light_level
1.6.11) Function : tux.status.lled
1.6.12) Function : tux.status.lwing_bt
1.6.13) Function : tux.status.mouth_closed
1.6.14) Function : tux.status.mouth_counter
1.6.15) Function : tux.status.mouth_motor
1.6.16) Function : tux.status.mouth_opened
1.6.17) Function : tux.status.power_plug
1.6.18) Function : tux.status.rf_state
1.6.19) Function : tux.status.rled
1.6.20) Function : tux.status.rwing_bt
1.6.21) Function : tux.status.sounds_count
1.6.22) Function : tux.status.sound_muted
1.6.23) Function : tux.status.spin_backward
1.6.24) Function : tux.status.spin_bt
1.6.25) Function : tux.status.spin_counter
1.6.26) Function : tux.status.wings_backward
1.6.27) Function : tux.status.wings_counter
1.6.28) Function : tux.status.wings_motor
1.6.29) Function : tux.status.wings_forward
1.6.30) Function : tux.status.wings_bt
1.6.31) Function : tux.status.get_wings_position_switch
1.6.32) Function : tux.status.to_string
1.7) Class : tux.sys (tuxapi_class.TUXsys)
1.7.1) Function : tux.sys.add_time_event
1.7.2) Function : tux.sys.clear_time_events
1.7.3) Function : tux.sys.delayed_function
1.7.4) Function : tux.sys.looped_function
1.7.5) Function : tux.sys.shell
1.7.6) Function : tux.sys.shell_free
1.7.7) Function : tux.sys.time
1.7.8) Function : tux.sys.wait
1.8) Class : tux.tts (tuxapi_class.TUXtts)
1.8.1) Function : tux.tts.auto_connect
1.8.2) Function : tux.tts.connect
1.8.3) Function : tux.tts.disconnect
1.8.4) Function : tux.tts.kill_daemon
1.8.5) Function : tux.tts.pause
1.8.6) Function : tux.tts.play
1.8.7) Function : tux.tts.select_voice
1.8.8) Function : tux.tts.select_voice_fr_female
1.8.9) Function : tux.tts.select_voice_fr_female_tuxed
1.8.10) Function : tux.tts.select_voice_fr_male
1.8.11) Function : tux.tts.select_voice_fr_male_tuxed
1.8.12) Function : tux.tts.select_voice_us_female
1.8.13) Function : tux.tts.select_voice_us_female_tuxed
1.8.14) Function : tux.tts.select_voice_us_ma
le
1.8.15) Function : tux.tts.select_voice_us_male_tuxed
1.8.16) Function : tux.tts.send_command_to_tts
1.8.17) Function : tux.tts.speak
1.8.18) Function : tux.tts.speak_free
1.8.19) Function : tux.tts.stop
1) Class : tux (tuxapi_class.TUXTCPCommunicator)
Main class of tux object
Sub class of this class:
"cmd" as class : Class which manages the tux commands
"daemon" as class : Class which manages the daemon commands
"event" as class : Class which manages the events
"hw" as class : Class which manages the tux hardware
"misc" as class : Class which manages the miscellaneous
functions
"status" as class : Class which manages the request of a
status
"sys" as class : Class which manages the system functions
"tts" as class : Class which manages the text to speech
Global variables of this class:
"my_name" as string : Name of the api instance
"print_status" as boolean : Allow to print the raw statuses
"print_warnings" as boolean : Allow to print the warnings
Comments:
Call the destroying function at the end of your script for closing
the api correctly.
>>> tux.destroy()
1.1) Class : tux.cmd (tuxapi_class.TUXcmd)
Class which manages the tux commands
Global variables of this class:
"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
1.1.1) Function : tux.cmd.audio_channel_general
Send a command to tux for selecting the "general" audio channel in
the dongle
Example:
>>> tux.cmd.audio_channel_general()
1.1.2) Function : tux.cmd.audio_channel_tts
Send a command to tux for selecting the "TTS" audio channel in
the dongle
Example:
>>> tux.cmd.audio_channel_tts()
1.1.3) Function : tux.cmd.eyes_close
Send a command to tux for closing the eyes
Example:
>>> tux.cmd.eyes_close()
1.1.4) Function : tux.cmd.eyes_off
Send a command to tux for stopping the eyes movement
Example:
>>> tux.cmd.eyes_off()
1.1.5) Function : tux.cmd.eyes_on
Send a command to tux for moving the eyes
Parameters:
"count" as integer : Number of movements
(default = 1)
Example:
>>> tux.cmd.eyes_on()
>>> tux.cmd.eyes_on(2)
1.1.6) Function : tux.cmd.eyes_on_free
Send a command to tux for moving the eyes in free mode
Parameters:
"count" as integer : number of movements
(default = 1)
Example:
>>> tux.cmd.eyes_on_free()
>>> tux.cmd.eyes_on_free(2)
1.1.7) Function : tux.cmd.eyes_open
Send a command to tux for opening the eyes
Example:
>>> tux.cmd.eyes_open()
1.1.8) Function : tux.cmd.ir_off
Send a command to tux for turning the IR off
Example:
>>> tux.cmd.ir_off()
1.1.9) Function : tux.cmd.ir_on
Send a command to tux for turning the IR on
Example:
>>> tux.cmd.ir_on()
1.1.10) Function : tux.cmd.ir_send
Send a command to tux for sending an IR code
Parameters:
"address" as integer : RC5 address
"command" as integer : RC5 command
Example:
>>> tux.cmd.ir_send(1,1)
1.1.11) Function : tux.cmd.ledl_during
Send a command to tux for turning the left led on during a specified
time
Parameters:
"seconds" as float : time to wait in seconds
Example:
>>> tux.cmd.ledl_during(2.5)
1.1.12) Function : tux.cmd.ledl_during_free
Send a command to tux for turning the left led on during a specified
time in free mode
Parameters:
"seconds" as float : time to wait in seconds
Example:
>>> tux.cmd.ledl_during_free(2.5)
1.1.13) Function : tux.cmd.ledl_off
Send a command to tux for turning the left led off
Example:
>>> tux.cmd.ledl_off()
1.1.14) Function : tux.cmd.ledl_on
Send a command to tux for turning the left led on
Example:
>>> tux.cmd.ledl_on()
1.1.15) Function : tux.cmd.ledr_during
Send a command to tux for turning the right led on during a specified
time
Parameters:
"seconds" as float : time to wait in seconds
Example:
>>> tux.cmd.ledr_during(2.5)
1.1.16) Function : tux.cmd.ledr_during_free
Send a command to tux for turning the right led on during a specified
time in free mode
Parameters:
"seconds" as float : time to wait in seconds
Example:
>>> tux.cmd.ledr_during_free(2.5)
1.1.17) Function : tux.cmd.ledr_off
Send a command to tux for turning the right led off
Example:
>>> tux.cmd.ledr_off()
1.1.18) Function : tux.cmd.ledr_on
Send a command to tux for turning the right led on
Example:
>>> tux.cmd.ledr_on()
1.1.19) Function : tux.cmd.leds_blink
Send a command to tux for blinking the leds
Parameters:
"count" as integer : number of blink(0..255)
"delay" as integer : delay between 2 states (u=4msec)
Example:
>>> tux.cmd.leds_blink(10,25)
1.1.20) Function : tux.cmd.leds_during
Send a command to tux for turning the leds on during a specified time
Parameters:
"seconds" as float : time to wait in seconds
Example:
>>> tux.cmd.leds_during(2.5)
1.1.21) Function : tux.cmd.leds_during_free
Send a command to tux for turning the leds on during a specified time
in free mode
Parameters:
"seconds" as float : time to wait in seconds
Example:
>>> tux.cmd.leds_during_free(2.5)
1.1.22) Function : tux.cmd.leds_off
Send a command to tux for turning the leds off
Example:
>>> tux.cmd.leds_off()
1.1.23) Function : tux.cmd.leds_on
Send a command to tux for turning the leds on
Example:
>>> tux.cmd.leds_on()
1.1.24) Function : tux.cmd.mouth_close
Send a command to tux for closing the mouth
Example:
>>> tux.cmd.mouth_close()
1.1.25) Function : tux.cmd.mouth_off
Send a command to tux for stopping the mouth movement
Example:
>>> tux.cmd.mouth_off()
1.1.26) Function : tux.cmd.mouth_on
Send a command to tux for moving the mouth
Parameters:
"count" as integer : number of movements
(default = 1)
Example:
>>> tux.cmd.mouth_on()
>>> tux.cmd.mouth_on(2)
1.1.27) Function : tux.cmd.mouth_on_free
Send a command to tux for moving the mouth in free mode
Parameters:
"count" as integer : number of movements
(default = 1)
Example:
>>> tux.cmd.mouth_on_free()
>>> tux.cmd.mouth_on_free(2)
1.1.28) Function : tux.cmd.mouth_open
Send a command to tux for opening the mouth
Example:
>>> tux.cmd.mouth_open()
1.1.29) Function : tux.cmd.ping
Send a command to tux for the "ping-pong" test
Parameters:
"count" as integer : number of pong requested
(default = 200)
Example:
>>> tux.cmd.ping()
>>> tux.cmd.ping(200)
1.1.30) Function : tux.cmd.raw
Send a raw command to tux
Parameters:
"cmd" as integer : command
"param1" as integer : parameter 1 of these command
"param2" as integer : parameter 2 of these command
"param3" as integer : parameter 3 of these command
Return a ACK if it's required
Example:
>>> tux.cmd.raw(BLINK_EYES_CMD,4,0,0)
1.1.31) Function : tux.cmd.sleep_off
Send a command to tux for turning the sleep mode off
Example:
>>> tux.cmd.sleep_off()
1.1.32) Function : tux.cmd.sleep_on
Send a command to tux for turning the sleep mode on
Example:
>>> tux.cmd.sleep_on()
1.1.33) Function : tux.cmd.sound_play
Send a command to tux for playing a sound from the flash
memory
Parameters:
"index" as integer : index of the sound
"volume" as integer : volume of the sound(0..7,0=max)
(default = 0)
Example:
>>> tux.cmd.sound_play(1)
>>> tux.cmd.sound_play(1,0)
1.1.34) Function : tux.cmd.sound_store_index
Send a command to tux for indexing the sound
Parameters:
"highAdd" as integer : high byte address of the sound
"middleAdd" as integer : middle byte address of the sound
"lowAdd" as integer : low byte address of the sound
Example:
>>> tux.cmd.sound_store_index(0x00,0x04,0x00)
1.1.35) Function : tux.cmd.sound_storing
Send a command to tux for storing a sound collection in the
memory flash
Parameters:
"number" as integer : number of sounds to be stored
Example:
>>> tux.cmd.sound_storing(10)
1.1.36) Function : tux.cmd.sound_test
Send a command to tux for testing the sound in tux
Example:
>>> tux.cmd.sound_test()
1.1.37) Function : tux.cmd.spinl_off
Send a command to tux for stopping the spinning movement
Example:
>>> tux.cmd.spinl_off()
1.1.38) Function : tux.cmd.spinl_on
Send a command to tux to spin to the left
Parameters:
"count" as integer : number of quarter turns
(default = 4)
"speed" as integer : speed of the movement(1..5)
(default = 5)
Example:
>>> tux.cmd.spinl_on()
>>> tux.cmd.spinl_on(2) (count = 2)
>>> tux.cmd.spinl_on(2,5) (count = 2 and speed = 5)
1.1.39) Function : tux.cmd.spinl_on_free
Send a command to tux to spin to the left in free mode
Parameters:
"count" as integer : number of quarter turns
(default = 4)
"speed" as integer : speed of the movement(1..5)
(default = 5)
Example:
>>> tux.cmd.spinl_on_free()
>>> tux.cmd.spinl_on_free(2) (count = 2)
>>> tux.cmd.spinl_on_free(2,5) (count = 2 and speed = 5)
1.1.40) Function : tux.cmd.spinr_off
Send a command to tux for stopping the spinning movement
Example:
>>> tux.cmd.spinr_off()
1.1.41) Function : tux.cmd.spinr_on
Send a command to tux to spin to the right
Parameters:
"count" as integer : number of quarter turns
(default = 4)
"speed" as integer : speed of the movement(1..5)
(default = 5)
Example:
>>> tux.cmd.spinr_on()
>>> tux.cmd.spinr_on(2) (count = 2)
>>> tux.cmd.spinr_on(2,5) (count = 2 and speed = 5)
1.1.42) Function : tux.cmd.spinr_on_free
Send a command to tux to spin to the right in free mode
Parameters:
"count" as integer : number of quarter turns
(default = 4)
"speed" as integer : speed of the movement(1..5)
(default = 5)
Example:
>>> tux.cmd.spinr_on_free()
>>> tux.cmd.spinr_on_free(2) (count = 2)
>>> tux.cmd.spinr_on_free(2,5) (count = 2 and speed = 5)
1.1.43) Function : tux.cmd.structured
Send a structured command to tux
Parameters:
"fct" as integer : function of tux
"cmd" as integer : command for this function
"param1" as integer : parameter 1 for this command
"param2" as integer : parameter 2 for this command
"param3" as integer : parameter 3 for this command
Return a ACK as integer
Example:
>>> tux.cmd.structured(TUX_CMD_STRUCT_EYES,TUX_CMD_STRUCT_SUB_ON
,count,0,0)
1.1.44) Function : tux.cmd.wings_off
Send a command to tux for stopping the wings movement
Example:
>>> tux.cmd.wings_off()
1.1.45) Function : tux.cmd.wings_on
Send a command to tux for moving the wings
Parameters:
"count" as integer : number of movements
(default = 1)
"speed" as integer : speed of the movement(1-5)
(default = 5)
Example:
>>> tux.cmd.wings_on()
>>> tux.cmd.wings_on(2) (2 movements)
>>> tux.cmd.wings_on(2,5) (2 movements and speed=5)
1.1.46) Function
: tux.cmd.wings_on_free
Send a command to tux for moving the wings in free mode
Parameters:
"count" as integer : number of movements
(default = 1)
"speed" as integer : speed of the movement(1..5)
(default = 5)
Example:
>>> tux.cmd.wings_on_free()
>>> tux.cmd.wings_on_free(2) (2 movements)
>>> tux.cmd.wings_on_free(2,5) (2 movements and speed=5)
1.2) Class : tux.daemon (tuxapi_class.TUXdaemon)
Class which manages the daemon commands
Global variables of this class:
"connected" as boolean : State of the connection to tuxdaemon
1.2.1) Function : tux.daemon.auto_connect
Allow to connect the api to tuxdaemon automatically
Parameters:
"value" as boolean : turn on/off the auto_connect mode
"address" as string : Tcp/IP Host address
(default = 'localhost')
"port" as integer : Tcp/IP Port number
(default = 5000)
Examples:
>>> tux.daemon.auto_connect(True)
>>> tux.daemon.auto_connect(True,'192.168.0.1')
>>> tux.daemon.auto_connect(True,'192.168.0.1',5000)
1.2.2) Function : tux.daemon.connect
Connect tux object to tuxdaemon
Parameters:
"port" as integer : Tcp/IP Port number
(default = 5000)
"address" as string : Tcp/IP Host address
(default = 'localhost')
Examples:
>>> tux.daemon.connect()
>>> tux.daemon.connect('192.168.0.1')
>>> tux.daemon.connect('192.168.0.1',5000)
Comment:
The variable "tux.daemon.connected" contains the result of
this method
1.2.3) Function : tux.daemon.disconnect
Disconnect tux object from tuxdaemon
Example:
>>> tux.daemon.disconnect()
1.2.4) Function : tux.daemon.disconnect_client
Disconnect a client from tuxdaemon
Parameters:
"id_client" as integer : id of the client to disconnect
Example:
>>> tux.daemon.disconnect_client(0)
1.2.5) Function : tux.daemon.get_client_count
Get the number of clients connected to tuxdaemon
Return an integer
Example:
>>> print tux.daemon.get_client_count()
1.2.6) Function : tux.daemon.get_client_name
Get the name of a client of tuxdaemon
Return a string
Example:
>>> print tux.daemon.get_client_name(0)
1.2.7) Function : tux.daemon.get_my_client_id
Get the client id of my connection to tuxdaemon
Return an integer
Example:
>>> print tux.daemon.get_my_client_id()
1.2.8) Function : tux.daemon.get_version
Get the version of tuxdaemon
Return a string
Example:
>>> print tux.daemon.get_version()
1.2.9) Function : tux.daemon.kill
Kill tuxdaemon
Example:
>>> tux.daemon.kill()
1.2.10) Function : tux.daemon.print_clients_name
Print the name of all the clients connected to tuxdaemon
Example:
>>> tux.daemon.print_clients_name()
1.2.11) Function : tux.daemon.set_my_client_name
Set my client name on tuxdaemon
Parameters:
"name" as string : name of this client (max 11 char)
Example:
>>> tux.daemon.set_my_client_name('Py client')
Comment:
The variable 'tux.my_name' is affected by this function
1.3) Class : tux.event (tuxapi_class.TUXevent)
Class which manages the events
Global variables of this class:
"on_bt_pushed" as pof : On tux button pushed
"on_head_bt_pushed" as pof : On tux head button pushed
"on_lwing_bt_pushed" as pof : On tux left wing button pushed
"on_rwing_bt_pushed" as pof : On tux right wing button pushed
"on_bt_released" as pof : On tux button released
"on_head_bt_released" as pof : On tux head button released
"on_lwing_bt_released" as pof : On tux left wing button released
"on_rwing_bt_released" as pof : On tux right wing button released
"on_remote_bt" as tuple of pof : On remote controller button pressed
param 1 : Key as integer
"on_status" as pof : On status arrival
"on_remote" as pof : On remote controller event
"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_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
"on_power_unplugged" as pof : On power unplugged event
"on_left_blue_led_on" as pof : On left blue led changed to on
"on_left_blue_led_off" as pof : On left blue led changed to off
"on_right_blue_led_on" as pof : On right blue led changed to on
"on_right_blue_led_off" as pof : On right blue led changed to off
"on_eyes_open" as pof : On eyes open event
"on_eyes_close" as pof : On eyes close event
"on_rf_connected" as pof : On RF is connected
"on_rf_disconnected" as pof : On RF is disconnected
"on_pong_received" as pof : On pong status received
"on_mouth_stop" as pof : On mouth stop event
"on_eyes_stop" as pof : On eyes stop event
"on_wings_stop" as pof : On wings stop event
"on_spin_stop" as pof : On spin stop event
(pof = pointer of function)
Example of associating a function to an event:
>>> def my_function():
>>> print "hello"
>>> tux.event.on_bt_pushed=my_function
Example of associating a function to a remote event:
>>> def my_function(key):
>>> print "Button %s is pressed"%remote_bt_name[key]
>>> tux.event.on_remote_bt=my_function
Key constants of the remote controller:
(K_0,K_1,K_2,K_3,K_4,K_5,K_6,K_7,K_8,K_9,K_STANDBY,
K_MUTE,K_VOLUMEPLUS,K_VOLUMEMINUS,K_ESCAPE,K_YES,
K_NO,K_BACKSPACE,K_STARTVOIP,K_RECEIVECALL,K_HANGUP,
K_STAR,K_SHARP,K_RED,K_GREEN,K_BLUE,K_YELLOW,
K_CHANNELPLUS,K_CHANNELMINUS,K_UP,K_DOWN,K_LEFT,
K_RIGHT,K_OK,K_FASTREWIND,K_FASTFORWARD,K_PLAYPAUSE,
K_STOP,K_RECORDING,K_PREVIOUS,K_NEXT,K_MENU,K_MOUSE,
K_ALT)
1.3.1) Function : tux.event.clear
Clear all events
Example:
>>> tux.event.clear()
1.3.2) Function : tux.event.remote_key_to_string
Get the string name of a remote key value
Parameters:
"key" as integer : key to translate to string
Return a string
Example:
>>> print tux.event.remote_key_to_string(10)
1.3.3) Function : tux.event.restore
Restore all events
Example:
>>> tux.event.restore()
1.3.4) Function : tux.event.store
Store all events
Example:
>>> tux.event.store()
1.3.5) Function : tux.event.wait_bt_pushed
Wait until a tux button is pushed
Parameters:
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return the button value as integer
(HEAD_BT|LEFT_WING_BT|RIGHT_WING_BT|NONE_BT)
Example:
>>> tux.event.wait_bt_pushed(10)
1.3.6) Function : tux.event.wait_head_bt_pushed
Wait until head button is pushed
Parameters:
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return a boolean
Example:
>>> tux.event.wait_head_bt_pushed(2)
1.3.7) Function : tux.event.wait_head_bt_released
Wait until head button is released
Parameters:
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return a boolean
Example:
>>> tux.event.wait_head_bt_released(2)
1.3.8) Function : tux.event.wait_lwing_bt_pushed
Wait until left wing is pushed
Parameters:
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return a boolean
Example:
>>> tux.event.wait_lwing_bt_pushed(2)
1.3.9) Function : tux.event.wait_lwing_bt_released
Wait until left wing is released
Parameters:
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return a boolean
Example:
>>> tux.event.wait_lwing_bt_released(2)
1.3.10) Function : tux.event.wait_remote_bt
Wait until a specified key of the remote is pressed
Parameters:
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return a boolean
Example:
>>> tux.event.wait_remote_bt(K_OK,2)
1.3.11) Function : tux.event.wait_rwing_bt_pushed
Wait until right wing is pushed
Parameters:
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return a boolean
Example:
>>> tux.event.wait_rwing_bt_pushed(2)
1.3.12) Function : tux.event.wait_rwing_bt_released
Wait until right wing is released
Parameters:
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return a boolean
Example:
>>> tux.event.wait_rwing_bt_released(2)
1.3.13) Function : tux.event.wait_stable_status
Wait for stable status
Parameters:
"DATA_STATUS" as integer : Desired status
"DATA_VALUE" as integer : Desired value
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
"stable_out" as integer : Time of stable status request in seconds
Return a boolean
Example:
>>> var=tux.event.wait_status(DATAS_STATUS_HEAD_PUSH_SWITCH,1,5,2)
1.3.14) Function : tux.event.wait_status
Wait until the specified status arrives
Parameters:
"DATA_STATUS" as integer : Desired status
"DATA_VALUE" as integer : Desired value
"time_out" as integer : Time-out in seconds
(9999 = infinite wait)
Return a boolean
Example:
>>> var=tux.event.wait_status(DATAS_STATUS_HEAD_PUSH_SWITCH,1,2)
(see 'tuxapi_const.py' for the complete list of statuses)
1.4) Class : tux.hw (tuxapi_class.TUXhw)
Class which manages the tux hardware
Global variables of this class
"TUX_devices" as tuple : tuple of tux devices as tuple
(param 0 = alsa device name)
(param 1 = sound card)
(param 2 = sound device)
(param 3 = usb bus)
(param 4 = usb device)
(param 5 = usb PID)
(param 6 = usb VID)
"TUX_devices_count" as integer : number of tux devices
"alsa_device" as string : current alsa device name
(is selected on the beginning
of the api with the first tux
sound card)
1.4.1) Function : tux.hw.alsa_devices_count
Return the number of tux alsa devices
Return an integer
Example:
>>> print tux.hw.alsa_devices_count()
1.4.2) Function : tux.hw.alsa_devices_select
Get the alsa device name of a tux sound card
Return a string (ex: 'hw:1,0')
Example:
>>> print tux.hw.alsa_devices_select(0)
1.4.3) Function : tux.hw.audio_get_version
Get the version of the audio firmware
Return a tuple : (major version, minor version, update version,
revision, author_id)
Example:
>>> print tux.hw.audio_get_version()
1.4.4) Function : tux.hw.behavior_get_version
Get the version of the behavior firmware
Return a tuple : (major version, minor version, update version,
revision, author_id)
Example:
>>> print tux.hw.behavior_get_version()
1.4.5) Function : tux.hw.donglerf_get_version
Get the version of the donglerf firmware
Return a tuple : (major version, minor version, update version,
revision, author_id)
Example:
>>> print tux.hw.donglerf_get_version()
1.4.6) Function : tux.hw.tuxrf_get_version
Get the version of the tuxrf firmware
Return a tuple : (major version, minor version, update version,
revision, author_id)
Example:
>>> print tux.hw.tuxrf_get_version()
1.5) Class : tux.misc (tuxapi_class.TUXmisc)
Class which manages the miscellaneous functions
1.5.1) Function : tux.misc.doc
Print the docstring of an element of tux api
Parameters:
"element" as methode or class
Examples:
>>> tux.misc.doc(tux)
>>> tux.misc.doc(tux.cmd.eyes_on)
1.5.2) Function : tux.misc.build_documentation
Build the documentation of this api
Parameters:
"doc_path" as string : path of the output text file
Example:
>>> tux.misc.build_documentation('/home/remi/tuxapi_doc')
1.5.3) Function : tux.misc.print_api_version
To print the version of the API
Example:
>>> tux.misc.print_api_version()
1.6) Class : tux.status (tuxapi_class.TUXStatus)
Class which manages the request of a status
Global variables of this class:
"rf_connected" as boolean : State of the droid/dongle connection
1.6.1) Function : tux.status.charger_state
Get the status of the charger
Return 1 for charging and 0 for not charging
Example:
>>>var = tux.status.charger_state()
1.6.2) Function : tux.status.eyes_closed
Get the last state of "eyes closed position switch" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.eyes_closed()
1.6.3) Function : tux.status.eyes_counter
Get the number of remaining movements of the eyes
Return an integer (0..255)
Example:
>>> var = tux.status.eyes_counter()
1.6.4) Function : tux.status.eyes_motor
Get the last state of "head motor for eyes" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.eyes_motor()
1.6.5) Function : tux.status.eyes_opened
Get the last state of "eyes open position switch" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.eyes_opened()
1.6.6) Function : tux.status.get
Get a specified status
Parameters:
"DATA_STATUS" as integer : desired status
Return a boolean
(True if the status arrives before 2 seconds)
(The raw of the status response is in tux.tcp_data)
Example:
>>> tux.status.get(DATAS_STATUS_WINGS_MOTOR_BACKWARD)
1.6.7) Function : tux.status.head_bt
Get the status of the head button
Return 1 for on and 0 for off
Example:
>>> var = tux.status.head_bt()
1.6.8) Function : tux.status.ir_led
Get the last state of "IR led" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.ir_led()
1.6.9) Function : tux.status.ir_signal
Get the last state of "IR receiver signal" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.ir_signal()
1.6.10) Function : tux.status.light_level
Get the last light level
Return an integer (0..1024, max light=0)
Example:
>>> var = tux.status.light_level()
1.6.11) Function : tux.status.lled
Get the state of the left blue led
Return 1 for on and 0 for off
Example:
>>> var = tux.status.lled()
1.6.12) Function : tux.status.lwing_bt
Get the last state of "left wing push" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.lwing_bt()
1.6.13) Function : tux.status.mouth_closed
Get the last state of "mouth closed position" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.mouth_closed()
1.6.14) Function : tux.status.mouth_counter
Get the number of remaining movements of the mouth
Return an integer (0..255)
Example:
>>> var = tux.status.mouth_counter()
1.6.15) Function : tux.status.mouth_motor
Get the last state of "head motor for mouth" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.mouth_motor()
1.6.16) Function : tux.status.mouth_opened
Get the last state of "mouth open position" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.mouth_opened()
1.6.17) Function : tux.status.power_plug
Get the last state of "power plug switch" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.power_plug()
1.6.18) Function : tux.status.rf_state
Get the last state of the RF status
Return 1 for connected and 0 for disconnected
Example:
>>>var = tux.status.rf_state()
1.6.19) Function : tux.status.rled
Get the state of the right blue led
Return 1 for on and 0 for off
Example:
>>> var = tux.status.rled()
1.6.20) Function : tux.status.rwing_bt
Get the last state of "right wing push" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.rwing_bt()
1.6.21) Function : tux.status.sounds_count
Get the number of sounds stored in the flash memory
Return a integer (0..255)
Example:
>>> var = tux.status.sounds_count()
1.6.22) Function : tux.status.sound_muted
Get the last state of "tux mute sound" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.sound_muted()
1.6.23) Function : tux.status.spin_backward
Get the last state of "spin motor forward" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.spin_forward()
1.6.24) Function : tux.status.spin_bt
Get the last state of "spin position switch" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.spin_bt()
1.6.25) Function : tux.status.spin_counter
Get the number of remaining movements of 'spinning'
Return an integer (0..255)
Example:
>>> var = tux.status.spin_counter()
1.6.26) Function : tux.status.wings_backward
Get the last state of "wings motor backward" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.wings_backward()
1.6.27) Function : tux.status.wings_counter
Get the number of remaining movements of the wings
Return an integer (0..255)
Example:
>>> var = tux.status.wings_counter()
1.6.28) Function : tux.status.wings_motor
Get the last state of "motor for wings" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.wings_motor()
1.6.29) Function : tux.status.wings_forward
Get the last state of "wings motor forward" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.wings_forward()
1.6.30) Function : tux.status.wings_bt
Get the last state of "wings position switch" status
Return 1 for on and 0 for off
Example:
>>> var = tux.status.wings_bt()
1.6.31) Function : tux.status.get_wings_position_switch
Deprecated : see 'tux.status.wings_bt'
1.6.32) Function : tux.status.to_string
Convert the current raw statuses to an explicit string
Return a string
Example:
>>> print tux.status.to_string()
1.7) Class : tux.sys (tuxapi_class.TUXsys)
Class which manages the system functions
1.7.1) Function : tux.sys.add_time_event
Add a time event in the time event handler
Parameters:
"cmd_type" as number : Command type (CT_SHELL|CT_FUNCTION)
"cmd" as string : Command to execute
"year" as integer : (ex : 2006) (9999 : parameter ignored)
"month" as integer : (ex : 12) (99 : parameter ignored)
"day" as integer : (ex : 23) (99 : parameter ignored)
"hour" as integer : (ex : 08) (99 : parameter ignored)
"minute" as integer : (ex : 55) (99 : parameter ignored)
"second" as integer : (ex : 30) (99 : parameter ignored)
Example:
>>> tux.sys.add_time_event(CT_SHELL,'xmms',9999,99,99,8,5,0)
1.7.2) Function : tux.sys.clear_time_events
Clear the time events of the time event handle
Example:
>>> tux.sys.clear_time_events()
1.7.3) Function : tux.sys.delayed_function
To execute a function with a delay
Parameters:
"function" as pointer of function : function to execute
"delay" as float : time to wait before executing
the function. In seconds
Example:
>>> def test():
... print "hello world"
...
>>> tux.sys.delayed_function(test,10)
1.7.4) Function : tux.sys.looped_function
Looping on a function with a delay
Parameters:
"function" as pointer of function: function to execute
"delay" as float : time to wait between 2 executions
of the function. In seconds
Example:
>>> def test():
... print "hello world"
... return True
...
>>> tux.sys.looped_function(test,10)
Comment:
While the return of the function is true, the loop remains
active
1.7.5) Function : tux.sys.shell
Execute a shell command
Parameters:
"command" as string : Shell command
Example:
>>> tux.sys.shell('ls -al')
1.7.6) Function : tux.sys.shell_free
Execute a shell command in free mode
Parameters:
"command" as string : Shell command
Example:
>>> tux.sys.shell_free('ls -al')
1.7.7) Function : tux.sys.time
Get the current time in seconds
Return an integer
Example:
>>> var=tux.sys.time()
1.7.8) Function : tux.sys.wait
Wait a time in seconds
Parameters:
"seconds" as float : Time to wait in seconds
Example:
>>> tux.sys.wait(2.4)
1.8) Class : tux.tts (tuxapi_class.TUXtts)
Class which manages the text to speech
Global variables of this class:
"connected" as boolean : State of the connection to tuxttsdaemon
"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
"on_sound_on" as pof : event on tts speaking on
"on_sound_off" as pof : event on tts speaking off
(pof = pointer of function)
Example of associating a function to an event:
>>> def my_function():
>>> tux.cmd.mouth_open()
>>> tux.tts.on_sound_on=my_function
1.8.1) Function : tux.tts.auto_connect
Allow to connect the api to tuxttsdaemon automatically
Parameters:
"value" as boolean : turn on/off the auto_connect mode
"address" as string : Tcp/IP Host address
(default = 'localhost')
"port" as integer : Tcp/IP Port number
(default = 5500)
Examples:
>>> tux.tts.auto_connect(True)
>>> tux.tts.auto_connect(True,'192.168.0.1')
>>> tux.tts.auto_connect(True,'192.168.0.1',5500)
1.8.2) Function : tux.tts.connect
Connect tts object to tuxttsdaemon
Parameters:
"port" as integer : Tcp/IP Port number
(default = 5500)
"address" as string : Tcp/IP Host address
(default = 'localhost')
Examples:
>>> tux.tts.connect()
>>> tux.tts.connect('192.168.0.1')
>>> tux.tts.connect('localhost',5500)
Comment:
The variable "tux.tts.connected" contains the result of this method
1.8.3) Function : tux.tts.disconnect
Disconnect tts object from tuxttsdaemon
Example:
>>> tux.tts.disconnect()
1.8.4) Function : tux.tts.kill_daemon
Kill the tuxttsdaemon
Example:
>>> tux.tts.kill_daemon()
1.8.5) Function : tux.tts.pause
Pause the sound
Example:
>>> tux.tts.pause()
1.8.6) Function : tux.tts.play
Play the sound if it's in "pause" state
Example:
>>> tux.tts.play()
1.8.7) Function : tux.tts.select_voice
Select a speaker voice
Parameters:
"speaker" as integer : speaker id (SPK_FR_MALE|SPK_FR_FEMALE|
SPK_US_MALE|SPK_US_FEMALE)
"pitch" as integer : raised pitch in % (100..330)
Example:
>>> tux.tts.select_voice(SPK_FR_MALE,100)
1.8.8) Function : tux.tts.select_voice_fr_female
Select the French female speaker voice with a normal pitch
Example:
>>> tux.tts.select_voice_fr_female()
1.8.9) Function : tux.tts.select_voice_fr_female_tuxed
Select the French female speaker voice with a raised pitch
Example:
>>> tux.tts.select_voice_fr_female_tuxed()
1.8.10) Function : tux.tts.select_voice_fr_male
Select the French male speaker voice with a normal pitch
Example:
>>> tux.tts.select_voice_fr_male()
1.8.11) Function : tux.tts.select_voice_fr_male_tuxed
Select the French male speaker voice with a raised pitch
Example:
>>> tux.tts.select_voice_fr_male_tuxed(
)
1.8.12) Function : tux.tts.select_voice_us_female
Select the US English female speaker voice with a normal pitch
Example:
>>> tux.tts.select_voice_us_female()
1.8.13) Function : tux.tts.select_voice_us_female_tuxed
Select the US English female speaker voice with a raised pitch
Example:
>>> tux.tts.select_voice_us_female_tuxed()
1.8.14) Function : tux.tts.select_voice_us_male
Select the US English male speaker voice with a normal pitch
Example:
>>> tux.tts.select_voice_us_male()
1.8.15) Function : tux.tts.select_voice_us_male_tuxed
Select the US English male speaker voice with a raised pitch
Example:
>>> tux.tts.select_voice_us_male_tuxed()
1.8.16) Function : tux.tts.send_command_to_tts
Not a user function
1.8.17) Function : tux.tts.speak
Speak a text with the acapela text to speech engine
Parameters:
"text" as string : text to read
Example:
>>> tux.tts.speak('My name is tux! tux droid !')
1.8.18) Function : tux.tts.speak_free
Speak a text with the acapela text to speech engine in free mode
Parameters:
"text" as string : text to read
Example:
>>> tux.tts.speak_free('My name is tux! tux droid !')
1.8.19) Function : tux.tts.stop
Stop the sound
Example:
>>> tux.tts.stop()