Developers/FAQ/lang-es: Difference between revisions

From OLPC
Jump to navigation Jump to search
Line 155: Line 155:


==== Como edito con [[Emacs]] en una laptop? ====
==== Como edito con [[Emacs]] en una laptop? ====
* See [[Emacs]] or [[TextEditor]] for alternatives
* Ver [[Emacs]] o [[TextEditor]] para alternativas


==== Como monto una memoria USB? ====
==== Como monto una memoria USB? ====

Revision as of 05:44, 31 May 2011

  Please copy/paste "{{Translationlist | xx | origlang=en | translated={{{translated}}}}}" (where xx is ISO 639 language code for your translation) to Developers/FAQ/lang-es/translations HowTo [ID# 256676]  +/-  

Previo Siguiente

Esta página reúne preguntas que deberán eventualmente encontrar su camino en el cuerpo del manual de Desarrolladores (i.e. estas páginas de Developers/*), una vez que tengamos un buen lugar donde ponerlas.

Como hago redes en Sugar?

Patrones recomendados para redificar aplicaciones en las laptops OLPC estan usadas en sistemas de Tubes/Telepathy. Esto es basicamente un DBUS - RPC a traves de la red de Telepathy. El framework de Telepathy framework permite a las sesiones estabilizar y ruteo atraves de topoligias de red extrañas. Ver compartiendo actividades para un resumen y tutorial de colaboración.

Código de ejemplo:

Las laptops tendrán conectividad IPv6 y IPv4, ellos pueden usar internet "normal" primitivas disponibles en Python, Scheme y C.

  • Standard Python supports synchronous and asynchronous networking including basic web-servers and the like.
  • Twisted no estara disponible por defacto en las laptops pero instalaciones parciales en el framework pueden ser incluidas en tu actividad si deseas hacer muchas operaciones en red con multiples potocolos
  • PyRO (objetos remotos en python) es otro enfoque común de RPC usado en Python.
  • XMLRPC/SOAP pueden ser usados para crear servicios web
Puedo usar sockets sobre Tubos?

...para obetener NAT traversal y otras cosas, pero usar codigo de sockets antiguo?

Si, usas Stream Tubes, disponible en gabble y salut (pero no antes de Update.1).

Como creo un servidor/servicio persistente?

  • Como registro el tiempo de inicio de carga?
  • Existe algun servicio de evento en dbus para cargar unicamente cuando se responde un mensaje? Eso es, no cargar hasta que haya algún evento o haya dado un tipo tal como la presencia del evento?
    • Si, mas o menos, los servicios son definidos en un archivo de servicios, estos servicios se asemejan a un ejecutiable que provee un servicio. Aunque uno puede registrarlos para una peticion de manejo de algun servicio especifico, pero hasta ahora necesita que el servicio sea llamado por algo.

Como acceso al hardware especial?

Mientras Sugar corra en muchas maquinas, la OLPC-XO tiene cierto hardware especial el cual puede ser explotado por el software.

Cámara / Cámara como video (v4l2)

Ver GStreamer para instrucciones generales y OLPCGames para instrucciones especificas a Pygame.

Control pad direccionales/botones
  • Tiene sus propias nombres de teclas X
  • Ver OLPCGames para instrucciones especificas a Pygame, distribución llave y discusiones de uso del pad direccional para situaciones de juego
  • Mapeo del pad de juego a Inicio, Fin, Pagina-arriba, Pagina-abajo
  • Mapeo del pad direccion a las teclas de cursor (en el teclado numerico)
Touchpad / Sensor desplazamiento
  • Muestra como un mouse normal bajo X.
  • Este no es un sensor capaz de multi-toque
Pad de dibujo (pad con stylus)
  • Como cambiar dentro/fuera del modo stylus?
  • Como fijar parametros en la interpretación?
Configuración del puerto de audio

El mejor codigo de ejemplo disponible en el medición de actividad.

  • Como obtener acceso?
    • Configuras el mezclador ALSA (usando os.system en el código de ejemplo) y despues usas eventos gstreamer para procesar el audio-buffer receptor "handoff" usando una sincronización de datos simulado. Desempaqueta los datos de los valores de la cadena y obten el valor de los integros. (O simplemente usa la utileria de clase (AudioGrab) en la medición de actividad).
  • What's going to come out when I get access (keeping in mind I (the developer) likely won't have the actual hardware available)?
    • You are processing a stream of audio data. In the sample code you are configuring gstreamer to produce a stream of integers at 48000 Hz. You should be able to produce the same effect using gstreamer on any linux box using your normal microphone port.
Mode-switching code for the screen

Much of this is controlled via the HardwareManager service on DBUS. There is sample code for getting a reference to the hardware manager in the Read Activity, from there, simply call the dbus-exposed methods to set the values you want. HardwareManager controlled operations:

  • Display Controller (DCON) data-source (CPU or DCON)
  • DCON freeze/unfreeze
  • backlight brightness
  • keyboard light brightness
  • color/black and white mode

How do we:

  • set all 8 (4 distinct) settings for MODE_MONO_LUMA, MODE_CSWIZZLE, MODE_COL_AA (as distinct from just colour/black and white)
  • query, change, and restrict screen orientation
  • drop to a lower resolution for performance or ease of porting, such as 600x450 or 400x300

See also Display.

Como creo mi actividad en GUI?

  • Can I just use Cairo, Pygame or GTK directly?
    • PyGTK, Pango and PyCairo are the recommended GUI toolkit for coding new window/button/text/vector-graphics activities
    • Pygame is recommended for arcade-style raster-graphics games which need performance
    • Etoys can be used to produce sophisticated object-scripting GUIs, with support for rich media
  • How can a non-GTK (or Qt) app fully interact with Sugar?
    • At the moment the Low-level Activity API is quite involved
    • Can be "fixed" by creating a wrapper in Python (e.g. the ClassicGnome activity with a performance and memory penalty)
    • Can write various DBUS services using a GTK event loop to provide the required introspection services (implies that GTK must be loaded by every process, regardless of whether it is needed)
    • Can alter your core event loop to cooperate with an embedded GObject event loop (PyGame allows this, for instance), with the small concern that this requires loading GObject into your process' memory space
  • How flexible does the GUI need to be?
    • Should be able to handle a resize-and-rotate event from the X server
    • Should be able to handle internationalisation/localisation, including to right-to-left-written scripts
  • What's the best development approach:
    • Write outside Sugar, finish and debug, then port?
      • For older PowerPC-based Macs, this is likely the best approach
    • Write to Sugar, test and debug within the system?
      • Usable if you can set up a reasonably-performing emulated system or upgrade your system to support Sugar directly
    • Write directly on the XO
      • Usable if you are comfortable with command-line Linux editing tools, or want to use Etoys. As Develop becomes available this should become more approachable.

Como empaqueto mi actividad?

  • How do I work from an in-process activity (develop registration)?
    • setup.py develop
    • You can use sugar-activity to start the activity, but you have to manually close it (note that by default there is no way to easily kill a mis-behaving activity in Sugar)
  • How do I produce a binary extension?
    • On a workstation with Qemu, you can create a compilation workspace. (Using a Qemu qcow overlay lets you do this without corrupting your base OS image). Within that work-space, compile the packages you want using gcc, yum, and all the traditional tools. Package and upload the results.
  • How do I share code between activities?
    • How do I use (large, common) Python packages?
      • The system will "unify" common files across packages, so if you have a large package and another activity also uses that package then the system will only store one copy of the package (using a file-by-file comparison).
      • Numpy
      • Matplotlib
      • MySQL or PostgreSQL client code
      • Twisted
      • Zope Interfaces
      • Pygsear, PGU or other PyGame extensions
    • How do I provide my own base packages on top of which I have written dozens of applications?
      • As with the common activities, the current plan is to have the system unify the packages on the laptop. There is a cost in that the packages must contain complete copies of their supporting framework for each activity.

How do I publish for others to download?

  • The Activities page is where most users will go to find new Activities
  • Any http (web) server can be used to distribute packages
    • Users can download a .xo package, when the package completes downloading, they use the Journal activity to "resume" the downloaded package
  • How do I tell users about updates to the packages?

Como comparto archivos entre las aplicaciones?

Plan at the moment is to have file-sharing handled by the underlying system. That is, the system will simply notice that you have duplicate files with the same properties and hash and will share them between the two activities.

Como pruebo una actividad en Sugar?

  • Use the standard logging module in Python where possible
  • Start your activity normally, its logs will be sent to the ~/.sugar/default/logs/ directory named after your Activity's DBUS service
  • You can use the built-in Log Viewer activity on production XO versions (build 649 and up), alternately you can just view the logs in a developer's console using less or vi
  • If you like you can also use:
sugar-jhbuild shell
sugar-activity YourActivityName

to run your activity from a shell and be able to drop into pdb or similar command-line debuggers.

Como debugeo una actividad con Sugar?

If you start your Sugar activity from the command line (see above), you can insert a standard Python:

 import pdb
 pdb.set_trace() 

command into your activity and then use the Python debugger to step through your activity's behaviour. Note that this will "freeze" your application while you are working, so you may have display issues.

Como edito con Emacs en una laptop?

Como monto una memoria USB?

Normally this is done automatically by the HAL when you plug the USB flash drive into the laptop. It will show up at the bottom of the Journal and as a directory in the /media folder. If, however, you had the USB key in when you started the machine, or the HAL doesn't recognize the key, you may not get the mount completed. In that case you can try manually mounting the key:

  • Start Terminal Activity
  • Become root: $ su
  • Then make a place to mount it: $ mkdir /mnt/usb
  • Then mount the drive: $ mount /dev/sda1 /mnt/usb
  • Don't forget to unmount it before removal: $ umount /mnt/usb
  • If anything fails you should edit your /etc/fstab file to include the mount point, device, and filesystem for the device to mount.

Previo Siguiente