Showing posts with label Mac OS X. Show all posts
Showing posts with label Mac OS X. Show all posts

2009-06-19

Semi-automating piece-wise translating texts through Google Translate

I am having to translate a horribly old program (1992?, DOS' Turbo Pascal)… and in german, to make it funnier… to an only-slightly-less-horribly-old environment (Delphi 4, circa 1999). To think that I was complaining about how outdated Borland's C++ Builder 5 felt… oh my.

I guess/hope/fear that later there will be a more modern target. But that will be easy, given that by then I should understand everything and the program itself is not complicated.

2009-01-27

Toshiba G450 en OS X - funcionando sin reiniciar

Por fin me he dedicado a jugar un poco con el driver oficial. El resultado esperado, como Nexus había comentado antes en otro post, era que el G450 sólo funcionase si estaba enchufado desde el arranque.

Pero en mi caso era peor: ni siquiera así funcionaba. Además he visto por la red más gente con el mismo problema. El "Toshiba PC Tool.app" que se instala junto al driver simplemente dice que no encuentra el modem, y ni siquiera aparece montado el disco USB que debería aparecer al conectar el G450.

El Perfil del Sistema muestra sin embargo que en el bus USB está conectado un disco de Toshiba, y la Consola muestra que diskarbitrationd no ha podido crear un disco ("unable to create /dev/disk2"). Esto se mantuvo así aunque reseteé el G450 y reformateé el disco con el propio menú del teléfono/modem/bicho.

Pero he encontrado una solución, que aunque no es ideal, tampoco cuesta mucho. Cuando el G450 está apagado y es enchufado al ordenador, la pantalla muestra una animación de carga de batería. Y el Perfil del Sistema muestra que hay un disco USB conectado. Cuando el G450 está encendido y es enchufado al ordenador, también se comporta como un disco. Pero se enciende un LED verde en la pantalla del modem. En Windows y Linux, cuando el G450 pasa al modo modem (gracias a un comando que el driver le manda), ése LED verde se pone azul. Y esto no estaba sucediendo en el Mac.

Pero en uno de los reinicios que probé, resultó que el LED se puso azul justo cuando el ordenador se apagaba. Y así se quedó cuando reinicié (no lo desconecté). Así que esta vez el Toshiba PC Tool sí que encontró el modem y ofreció un botón de "Conectar". Por fin! (también creó 3 interfaces de red nuevos, que seguramente permitirán manejar el modem más fácilmente mediante los Ross' Scripts, igual que ya hago con el Huawei E220. Pero eso, para otro día)

Así que: por alguna razón, el G450 está pasando a modo modem cuando el ordenador se apaga. Supongo que el driver de almacenamiento USB de OS X se adueña del G450 (aunque no consigue crear el disco!) así que el driver de Toshiba no puede mandar el comando de cambio de modo; y durante el apagado, cuando el driver de almacenamiento USB libera el disco, el driver de Toshiba por fin consigue mandar el comando justo antes del apagado final. O quizás es sólo un efecto secundario del apagado del bus USB, oiga. Quién sabe. En cualquier caso, funciona y es repetible.

Pero lo mejor es que no hace falta el apagado. Resulta que si pones el Mac a dormir (menú manzana -> reposo, o por ejemplo cerrando la tapa del Macbook) el efecto es el mismo: el LED se pone azul, y después el Toshiba PC Tool funciona. (ojo, el Mac no se queda dormido! Debe haber algún problema, porque inmediatamente después de empezar a dormir se despierta, y si la tapa está cerrada vuelve a dormir y a despertarse..... lo cual me temo que provocará algún cuelgue en algún momento. Así que si vas a probar esto, primero guarda lo que tengas abierto. De todas formas, quizás el problema del duerme-despierta sea cosa de los chungos drivers de Huawei que tengo instalados, que también instalaron un kext sobre algo de "USB wakeup"...)

En fin: finalmente he podido usar el G450 en mi Macbook. Ahora tocará ver si es mejor que el E220... que da bastantes problemas cuando lo usas con programas P2P con el operador Play. (aún no sé si es por drivers chungos o porque Play esté haciendo alguna jugarreta... cuando pueda, tendré que experimentar un poco con algún detector de gracias, como el Switzerland de la EFF).

Por completitud: he probado a descargar el driver de almacenamiento USB para ver si así el driver de Toshiba funciona mejor (mediante "sudo kextunload -b com.apple.iokit.IOUSBMassStorageClass"). Pero no sólo no funciona, sino que deja de funcionar el truco de dormir al mac. Así que mejor no tocarlo.

Otra forma de forzar el paso al modo modem sería usando USB_ModeSwich, que en OS X funciona tras desactivar el driver de almacenamiento USB... pero mientras no me provoque algún cuelgue, seguiré usando el truco de dormirlo. Más rápido ;P.

2008-09-08

Bus error in MacPorts' Python

PyQt4 (MacPorts' py25-pyqt4) was causing a Bus Error.

Some previous problems with the Python 2.5 installed by MacPorts made me think it could be some dependency with the native library called by the Python module; that is what I think that was also happening with py25-hashlib, which caused an error about being unable to find _md5 or some such, and which got fixed by uninstalling MacPorts' openssl 0.9.8g and installing 0.9.8h (and reinstalling py25-hashlib afterwards).

(and I say "think" because maybe that problem was unrelated to openssl, and in fact could be related to python_select, which I maybe had or had not run. Read on for more on that. Anyway, there was also some report online of problems between Pythons' hashlib and openssl because of the exact version used, and mentioned Python being a bit fragile in that respect — although it didn't say if that was because of a not-too-robust build/installation process, or because of Python's design.)

But here the problem was different. Reinstalling Qt 4 and PyQt4 did not help. After some googling, I found someone (thanks jherm) with the same problem... and who in some chat log is told by some MacPorts developer (?) the anticlimactical solution: follow the instructions at the end of the installation of MacPorts' Python 2.5. That is,
$ sudo port install python_select $ sudo python_select python25
Looks like this has to be run "to complete the installation". Sheesh. So that was a hard requisite? Shouldn't that have been told pretty explicitly then? (I'm seeing a number of reports about this kind of problem, so yes, I think the warning should be quite more explicit... I should start some bug reporting, I guess.)

So the problem seems to be that PyQt4 uses Python in its build process, assuming that it is the same in which it will be run afterwards. But in my case I had not run python_select after installing MacPorts' python25, because it seemed optional, and I didn't want to use it as the default… so PyQt4 was building against OS X's default Python.

So, after python_select, PyQt4 builds OK. It doesn't manage to get fully installed, mind you, but I guess that this other problem has more to do with MacPorts. Anyway, with a
$ sudo port -f install py25-pyqt4
it finally gets installed (although something remains to be finished, like the MacPorts' database getting properly updated; that can be checked with -d).

All of this was in the process to try to make Anki run from source. I was trying to test some modifications before sending the patches, but making sense out of the tortuous source and setting up the environment have required much more time than expected. I should be studying Polish instead! The exam is coming! :P

2008-08-15

Making a Mac OS X driver for the Toshiba G450 3G modem

About 3 weeks ago, I had to buy the 3G modem Toshiba G450 because Polish operator Play would not let me get the plan I wanted without it.

A few hours later, I had to accept that there are no Mac OS X drivers for it! Which would have made me, say, unhappy, had I not had my trusty Huawei E220. The only information I have been able to come up with are amazed reviews from gadget websites. Not even a driver for Linux... And this happens when I was thinking about polishing my low-level development powers (there is more to life than Java and C#, you know!)... so, why not take the chance to learn about what is needed to make a driver?

The modem uses the ZeroCD "trick" of appearing as a USB drive to the OS, until it receives an existent-but-generally-unused-in-USB-drives command; at that moment, the drive is "unplugged" and a new device appears in the bus: the modem. So in the USB drive that appears first, there is a driver installer (for Windows, of course). The user (or the autorun) installs the driver, and it sends the switching command to the USB drive it recognizes as the masked modem. Drive goes away, modem appears, and driver finally does its thingy with the modem.

Up to now, I have been successful in capturing the appropiate command with usbsniff and making the USB drive switch in Linux and Mac OS X, with the help of usb_modeswitch (http://www.draisberghof.de/usb_modeswitch/ , where I have already sent the info so they can use it in later versions). So now the modem is waiting for my next move. I was half expecting it to just be recognized by the serial driver, but that would have been too easy, wouldn't it?

So I have been reading about the internals of USB, now about IOKit (the driver subsystem in OS X), have re-learnt C in a rush, and now am contemplating starting with C++, of which IOKit uses "a restricted subset" (no RTTI, no templates, no exceptions... which in part I guess will make the thing easier, although I am afraid those were the interesting parts of it). And yet looks like I will have to read a bit about kernel programming in OS X. Which is also something I wanted to do, but... I was expecting this first project to be a little lighter!

On the other hand, I am suspecting this won't be THAT difficult. The Huawei E220's software for OS X (driver and app) doesn't look exactly brilliant, which makes me think someone hacked it together somewhat quickly; and it works in a similar way to the Toshiba G450. I even thought about hacking a bit the Huawei's kernel extension (looks like I should only edit an XML file in the bundle), but even if it worked I don't think I would be able to distribute it nor would I learn anything. And I don't actually need the modem ;P.

Also, the Darwin open source repositories have an example driver for USB modems. And after all we are only talking about making the OS see "the serial ports" in the USB interfaces... I mean, it should be as easy as it can get, since everything beyond that point will be taken care of by other parts of the OS. But still this is about kernel programming in C++ for a novice. Lots of little interestingly nasty ways to hose the whole OS. Nice!

Of course, no small part of the problem is making sense of all of this and still having time for language courses, travelling, personal life... and my regular job - and searching for a new one. Sounds a bit like DDoS, doesn't it? :)