Tag Archives: unix

Ubuntu, SkyLink, AnyData ADU-510A and other troubles

Today we bought an AnyData ADU-510A modem and SkyLink contract. Works in Windows perfectly, but why not to try Linux as well?

Okay, so I boot into Ubuntu 9.04 after successfully connecting from Windows and find some “broadband something connection” in Network Manager. Great. Trying to connect – it fails, and worse, disappears from Network Manager. Then it does not appear anymore no matter what I do. Time for some research.

OK, so this “flip flop” thing actually is not a modem, but a… CD-ROM drive! At least when you connect it. Then on Windows autorun launches something from this “CD”, which magically transforms it into modem and even installs drivers if they are not installed. Nice thing, but I don’t really need a CD-ROM drive in Ubuntu, what I need is modem. OK, I can boot into Windows, do this “transformation”, and then boot into Linux, but that’s somewhat cumbersome. But it works this way. The reason why it couldn’t connect first time was just because I didn’t specify phone number, login and password before connecting. Now, after I did that, it works. But when you turn the PC off or replug the modem for whatever reason, it turns into “CD” again.

So, I need either modem-modeswitch or usb_modeswitch. Both of them are supposed to do that “magical transformation” in Linux. The problem is that they don’t. At least for me. Time for some more research.

OK, so I have to enable option_zero_cd=2 option for usb_storage module. Creating /etc/modprobe.d/usb-storage.conf didn’t seem to work for whatever reason, so I just booted Linux with no device attached, and then did
modprobe usb_storage option_zero_cd=2
Hmm… now it usb_modeswitch just hangs the entire system. “CD-ROM” now detects, but with errors. Not that I have any use for it anyway. Seems like a dead end, but then I found this thread:
Not that I understood even a half of what it says, but this seemed interesting:

- Option uses the REZERO command (0x01)
- AnyData uses the START/STOP command (eject, 0x1b)
- Samsung uses a command with number 0x16 (not found in specs)

So, eject command, eh? Eject as in “eject cd from the drive”? No joking? Really, what is “eject” command supposed to do for CD-ROM drive that doesn’t even exist? Maybe “eject” it and “inject” a modem instead? It is just might be crazy enough to work:

alqualos@eternity:~$ lsusb
Bus 001 Device 002: ID 04f2:b044 Chicony Electronics Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 004: ID 05c6:1000 Qualcomm, Inc.
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
alqualos@eternity:~$ sudo eject sr1
[sudo] password for alqualos:
alqualos@eternity:~$ lsusb
Bus 001 Device 002: ID 04f2:b044 Chicony Electronics Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 005: ID 16d5:6502 AnyDATA Corporation
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

No, is that really it? No 3rd-party utilities, no need to recompile the entire kernel?

But it really worked. At least for 1 minute. Then it dropped off. Along with the modem. Replug, eject, reconnect. 1 minute. Drop-off. Damn. Let’s see…

Jul 4 20:50:15 eternity kernel: [ 1147.818112] option 2-1:1.0: device disconnected
Jul 4 20:50:15 eternity pppd[24490]: Modem hangup
Jul 4 20:50:15 eternity pppd[24490]: Connect time 0.6 minutes.
Jul 4 20:50:15 eternity pppd[24490]: Sent 28945 bytes, received 70454 bytes.
Jul 4 20:50:15 eternity kernel: [ 1147.880339] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
Jul 4 20:50:15 eternity kernel: [ 1147.884729] option 2-1:1.1: device disconnected
Jul 4 20:50:15 eternity kernel: [ 1147.885010] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
Jul 4 20:50:15 eternity kernel: [ 1147.885041] option 2-1:1.2: device disconnected
Jul 4 20:50:15 eternity pppd[24490]: Connection terminated.
Jul 4 20:50:15 eternity pppd[24490]: Terminating on signal 15
Jul 4 20:50:15 eternity kernel: [ 1147.979524] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
Jul 4 20:50:15 eternity pppd[24490]: Exit.
Jul 4 20:50:15 eternity kernel: [ 1148.020082] usb 2-1: reset full speed USB device using ohci_hcd and address 9
Jul 4 20:50:16 eternity kernel: [ 1148.193195] option 2-1:1.2: GSM modem (1-port) converter detected
Jul 4 20:50:16 eternity kernel: [ 1148.196748] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB0
Jul 4 20:50:16 eternity kernel: [ 1148.196838] option 2-1:1.1: GSM modem (1-port) converter detected
Jul 4 20:50:16 eternity kernel: [ 1148.196956] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB1
Jul 4 20:50:16 eternity kernel: [ 1148.197014] option 2-1:1.0: GSM modem (1-port) converter detected
Jul 4 20:50:16 eternity kernel: [ 1148.197145] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB2

Oh, so it just reconnects after about a minute, and PPP together with Network Manager just can’t stand it? That’s not good. But then again… Why not to wait another minute? Still connected? Another one… Still connected? So it does this just once? What the hell? Oh, nevermind.

So, from the very beginning:
1. Somehow enable option_zero_cd=2 option on usb_storage. Since modprobe.d doesn’t work, we have to do it manually by booting with no USB storage devices (including the modem) and then doing “modprobe usb_storage option_zero_cd=2”. Or we may try other methods, like /etc/modules or boot scripts…
2. Plug in the device.
3. “eject” it. Use “dmesg” to find out CD-ROM name (sr1 in my case).
4. Watch dmesg and wait until it suddenly disconnects and reconnects. About a minute.
5. Use it! But don’t forget to set up a wirelless broadband connection first!

Still cumbersome but a way better than booting in Windows just to initialize the damn thing.

Qt 4 and iconv(3) mini-HOWTO

Qt 4 since 4.2.0 uses iconv(3) for QTextCodec::codecForLocale() unless thou disablest it with -no-iconv configure option. This leadeth to the two things: name() for this codec returneth “System” and QTextCodec::codecForLocale() just stoppeth working. Try to encode or decode something outside of US-ASCII with it, and thou wilt get either empty string or just US-ASCII characters from it, if there were any.

Here is the fix:

#include <locale.h>
setlocale(LC_ALL, “”) // this goeth to thy main()

The nature of the problem is described in the glibc manual:

A C program inherits its locale environment variables when it starts up.
This happens automatically. However, these variables do not
automatically control the locale used by the library functions, because
ISO C says that all programs start by default in the standard C'
locale. To use the locales specified by the environment, you must call
setlocale’. Call it as follows:

setlocale (LC_ALL, “”);

Bluetooth между двумя компами

Попытался установить соединение между ноутом и старым компом с помощью Bluetooth. Нельзя сказать, чтобы у меня это не получилось. Нельзя сказать, что долго возился. То есть возился долго, но не с самим соединением, а с маршрутизацией – ведь мне нужно было чтобы после установки соединения система забыла, что у неё есть подключение к локалке, так как подразумевалось, что провод при этом будет вытащен – иначе зачем Bluetooth? В общем, это всё получилось. При этом всплыло несколько интересных вещей. Больше всего меня порадовало, что соединения Bluetooth по умолчанию неавторизованы. Другими словами, настроив на одном компе сервер, а на другом – клиент, я с удивлением выяснил, что для установки соединения не требуется ни PIN, ни пароль, ни подтверждение пользователя на стороне сервера (вот телефон у меня подтверждения спрашивал, когда я пытался к нему приконнектиться ещё до спаривания). Кроме того, все устройства Bluetooth видны с помощью команды сканирования. Хрень какая-то. Пошарив в Сети, выяснил как с этим делом бороться и включил обязательную авторизацию. Потом ещё пошарил по man bluetooth.device.conf и ещё сделал так, чтобы сканирование не выявляло мои компы. Стало как-то спокойнее.

Но больше всего меня разочаровало то, что от моей комнаты до кухни Bluetooth не достаёт, хотя тут отсилы метров 15 какие-нибудь, если не меньше. То ли стены плохие, то ли передатчики мне хилые достались. В общем, толку от этой забавы немного. Разве что можно сидеть в Интернете, развалившись на диване, и при этом провода под ногами не путаются. Но вообще технология забавная. И, что радует, хорошо стандартизирована – два разных адаптера прекрасно распознаются FreeBSD, команды все понимают, устройства все между собою соединяются без проблем. Мобильный Интернет меня вообще порадовал – помнится, пару лет назад лазил я через свой старый телефон, так тогда у нас почти ничего не работало. На работе получше было, там сигнал очень сильный. А теперь – ну, медленно, но не сильно отличается от паршивого диалапа.

Bluetooth и GPRS

С подачи обзавёлся Nokia 6021. Очень неплохой недорогой телефон. Немного поковырявшись, настроил в своём ноутбуке GPRS и Bluetooth – и вот вам неплохой мобильный Интернет. Работает довольно шустро, очень удобная штука. Цены на телефон меня, кстати, поразили – сначала мы его увидели в “Гиперглобусе”, вернее в одном из прилегающих дурацких маленьких магазинчиков. Там он стоил около 3800 – зная, что телефон должен стоить около 3500 и что в таких магазинчиках цены всегда завышены, решил, что это дороговато. Но не сильно. Ага. Приехав домой пошёл в “Берингов”, который всю жизнь отличался нормальными ценами, так там этот же мобильник лежит в двух экземплярах, причём один стоит 4200, а другой – 4400! Причёмро мужик сказал, что правильная цена – вторая! Я прифигел и решил покататься по мобильным салонам. “Связной” был закрыт, зато был открыт неплохой салон “АльтТелекома”, где я и купил этот телефон за 3400 рублей, то есть на 1000 рублей дешевле, чем в “Берингове” и на 400 рублей дешевле дурацкого “Цифрограда” в “Гиперглобусе”. На эту сэкономленую тыщу я купил пару адаптеров Bluetooth, второй потом попробую использовать для соединения ноутбука с локальной сетью, чтобы через неё можно было, к примеру, в Интернет выходить из любой точки квартиры, не таская за собой провод.

Кстати, мужик на вопрос “А хренли цена такая?” честно ответил “Ну, у нас вообще цены на мобильники высокие”. Приятно удивил. Всё-таки хороший магазин, мы там и пылесос, и стиральную машину покупали, и микроволновки – всё хорошо, и недорого, только с мобильниками они чего-то того…

Dell Inspiron 1300 with FreeBSD review

I have just completed installing and configuring FreeBSD and necessary software on my new Dell Inspiron 1300. I have to say that I like it.

What worked not at the beginning and what still worketh not.

ACPI. I have not expected ACPI to work from the very beginning, since I know that it is still one hell of incompatibilities and bugs. One problem that was really annoying is that closing and reopening lid with ACPI enabled was leading to display turned off and there was no apparent way to turn it back on. At first I decided to disable ACPI but then found out that in this case I would be unable to check battery status and CPU temperature. CPU temperature is not that important to me since I believe that it should be okay under normal circumstances, but battery status is another story. I really like typing acpiconf -i0 and getting something like “Remaining capacity: 100%” in return. So I decided to enable ACPI back and find out how to make lid behave well. And I found out. A nice config file /etc/devd.conf now containeth:

notify 10 {
match “system” “ACPI”;
match “subsystem” “Lid”;
action “/etc/rc.lid $notify”;

where /etc/rc.lid is:


if [ “$1” = “0x00” ]; then
logger -t Lid Closed
sysctl hw.acpi.video.out0.active=0
logger -t Lid Opened
sysctl hw.acpi.video.out0.active=1

(I had to replace out0 with lcd0 after upgrading from 6.1 to RELENG_6_2.)

Now the lid worketh as it should, and as a bonus I get a message in my log when I close or open the lid. Very nice. Suspend/resume still worketh not, but I care not since I need it not anyway. Turning off display to save power seemeth reasonable, but why put system to sleep when I can just turn it off instead – everything booteth up and shutteth down very fast anyway.

Modem and WiFi. WiFi is listed in pciconf -l -v, but it seemeth that there is no driver. Well, maybe there is one somewhere, but I never tried to look since I need it not anyway. Modem is not even in pciconf -l -v, which surpriseth me extremely since everything connected to bus should show up there. But I need it not either, so might as well forget about it.

Sound. There is no driver in kernel, but there is one being developed. It worketh pretty nice. I heard that there is no recording support and some problems with volume control other than PCM, but I need not neither recording support nor anything except PCM, so I have everything I need.

DRI/XVideo. It seemeth that there are some strange problems with AGP on i915. Well, another thing that is nice to have, but I care not of. I intend not play games on this laptop, nor something that would require XV. Playing video worketh fine with -vo x11, which is supposed to be slower than XV, but suffices for my needs, like anime watching.

Everything else worketh fine including 1280×800 native video mode and integrated Ethernet (well, who ever heard of Ethernet not working in Unix?). CD worketh too, of course. But I need not to burn anything here so I am not sure that CD burning worketh. See no reason for it not to work, though.

Now I can: play video and sound, use ICQ, mail and surf the Web with Firefox, use Japanese and English dictionaries. I could do more, but I need not.

Keyboard is pretty nice, and here I can feel all the power of Unix, where thou needest not much keys like “Home/End”, arrows and such. Working in Vim here is very cool, I can feel it when I type something in LogJam, for example, which useth more Windows-like keys. Touchpad is another thing when Unix power cometh handy simply because thou needest not it much! Many things can be done with keyboard much more efficiently.

In general, laptop is very nice. The only thing I miss is Bluetooth, which I would like to be integrated rather than have a separate USB device. But it is not that much of inconvenience and can be tolerated.

P. S. Some things I discovered later:

Upgrade to RELENG_6_2 improved not situation with XVideo, but then I realized that it is acpi_video’s fault. Disabling it enableth DRM and everything. So I can either have lid working but no XVideo or XVideo but either not working lid or no ACPI support at all. I chose no XVideo since I need not it that much. Upgrading to CURRENT might help, but I want not unstable system.

There is indeed no driver for WiFi, but Windows one worketh fine!

Modem seemeth to be connected through sound card somehow, considering how I made similar sound card working in Windows XP on another laptop – I had to install fresh drivers, then sound card showed up and so did modem. So I have to play around with sound card driver and/or try to install some special modem drivers in order to get it working. Not that I need it, though ^_^

So now I only have not working modem, mentioned conflict between DRM and acpi_video and no suspend/resume. Everything else is perfectly fine.

The Unix way in Windows, msmtp(1) and ssh example

The task. There is Nagios system running on some host in LAN. It checketh for some things and if something is bad, it sendeth out notifications to people who should fix it. The problem is that there is no Internet access from the LAN, so it is impossible to send out notifications using Internet e-mail, only locally. There is, however, an SMTP server in the LAN, which provideth access to Internet e-mail, but the host where Nagios is running is not allowed to send e-mail. The task is to solve this problem somehow.

Now there is true Unix solution: take some host in the LAN which is authorized to send mail and make Nagios remotely call something on it to send mail, like this:

echo “Notification” | ssh allowed-host nail -s “Subject” to@address.zone

Where nail on allowed-host is configured to send mail using msmtp(1).

However, on all authorized hosts there are only Windows and ancient HP-UX systems. HP-UX is a problem because everything so ancient there so it is virtually impossible to install msmtp(1) and nail(1) there. But who said that the Unix way solution cannot be applied to Windows? Nobody. So…

Final design of the solution looketh like this:

echo “Notification” | nail -A “Inet” -s “Subject”

Where “Inet” nail account is configured to use something like this instead of sendmail:

ssh allowed-host msmtp “$@”

Now the only problem is to install msmtp on the Windows machine and set up ssh access to it. msmtp was not a problem at all–binary distribution for Windows is available. As for ssh, Cygwin did its job. OpenSSH Cygwin package containeth very nice command ssh-config-host-or-something which configureth ssh to run as NT service. The funny part was that Cygwin must be downloaded from Internet using setup.exe, which is Windows application. But, as I said, there is no Internet access there and I have no Windows at home. So I had to run setup.exe using wine, and it worked nice except for that I had to switch wine to virtual desktop mode.

Now everything is set up and working just fine. Everything took about two or three hours, mostly because I never did anything like this before. I can not imagine more elegant solution.

Unix for professionals?

I just realised something about Unix. It is not only for professionals and hackers who love to learn and program. Not at all. I myself successfully use Unix, but I am not even a good programmer nor I like to learn or have fun with it. I am lazy, I like not to learn (although I learn if it can save me from doing extra work), I fully know any programming language not, and I tend to leave job half-done all the time. Imagine, if a person like me can use Unix and be happy with it, how accessible and easy to use this OS should really be, contrary to popular beliefs!

The only thing thou really need to use Unix is some ability to see things how they are, not how they seem to be. Not to the fullest, no, but at least above average level. Is it really that hard? I think so not. But maybe normal humans have another way of thinking.

Qt Jambi

People often say that I like Java not. It is not strictly true. Java would be a wonderful language, if… if what? I usually say it not, because people would not listen anyway ^_^ There are a lot of ifs actually, and all of them combined make java almost useless. Not in sense that it is not suited to any task, but in sense that there is always a better way. Graphics in Java is too slow, so everything that hath GUI should be developed with something like Qt (that means, C++ or Python). Long-running applications are vulnerable to memory leaks in Java VM, so it is also a bad task for Java. Various text-processing tasks would be wonderful job for Java, if there was no Perl nor Bison and Flex. High-level network applications require an elegant API, so Java may rest, Qt will do a job here. Low-level require high performance which also meaneth Qt or C for lower-level tasks.

Now there are a lot of Java applications but they just make no sense. Azureus, for example, which I had to replace with poor analog in Python because Azureus was overloading my X server (a network application, not a video player or 3D game!). Azureus would be better implemented in Qt/C++ or Qt/Python (GUI part) and Qt/C++ or plain C (network part). There are much more examples of improper uses of Java. I know of no proper one.

But now something happened what really made me feel slightly more better for Java. Trolltech released Technology Preview of Qt Jambi – a Qt variant for Java. Now a lot of things became better.

First of all, it is finally possible to create efficient GUI applications in Java. Unfortunately, I still know Python not, so I am unable to say whether there are any cases when Qt Jambi would be somehow better than PyQt, but the very fact that it is now possible to write something in Java that will have a GUI but will not make everything slow as hell is rather nice.

Another thing, Qt seemeth to become not only cross-platform, but also cross-language toolkit. On top of all, it is now possible to create applications consisting of parts in C++ and Java. Of course, there is JNI, but it is something like black magic compared to Qt Jambi in terms of clarity ^_^

What I like not is that they released it in binary form. And they are telling us something about feedback from open source community! How the hell can they hope for it without releasing source code?! Hope they will dual-license Qt Jambi with its official release.

Nonetheless, it is something unbelievably wonderful. Just the feeling of using Qt Designer for Java application is something.

Unix is for thee, if…

Just for fun. Note that it is mostly about Unix philosophy, not about technical side. Nothing preventeth one to apply Unix philosophy in non-Unix systems, and it is often done with great results. It is just that Unix is the best place to apply Unix philosophy, so if thou findest out that applying Unix philosophy doth great things, maybe it is time to switch to Unix and to use its full power. So…

Unix is for thee, if…

Thou wantest to fully control everything thou dost even if that meaneth that thou sometimes must control something that seemeth not necessary to control.
Thou likest to learn.
Thou preferrest to spend a lot of time learning some powerful tool and then save much more time using this tool, rather than wasting thy time using less powerful tools.
Thou wantest a system that breaketh without a reason not.
Thou wantest to be able to see anything that happeneth inside the system.
Thou art a programmer or just likest programming.
Thou likest freedom and hatest the very idea of deceiving and controlling others.
Thou believest that reinventing the wheel is a very stupid thing to do.
Thou likest to play with software, configure it, plug different things together.
Thou wantest simple tasks to be simple to do, and wantest to automate everything that is possible to automate.
Thou likest free and open source software.
Thou likest small but powerful programs.
Thou likest portable software.

Unix is not for thee, if…

Thou wantest not to control anything that is not necessary to control, even if thou loose a lot of power.
Thou likest to learn not.
Thou wantest tools to be as simple to use as possible, even if that meaneth that they will be slow and somewhat defective.
Thou wantest not to know about anything that happeneth inside the system, except when thou really must know about it.
Somebody tried to explain basics of programming to thee, but thou couldst not even begin to understand it. Neither thou wanted to.
Thou carest not about taking away somebody’s freedom.
Thou seest nothing bad in having only one way to do something.
Thou hatest to configure something, thou wantest everything to work right away.
Thou mindest not to spend a lot of time doing some stupid simple work like typing a lot of similar text fragments.
Thou likest big powerful programs and mindest not them being commercial ones.
Thou mindest not if the program is not portable as long as it runneth everywhere thou wantest it to.
Thou wantest everything in thy system to be in thy native language, even debugging messages in English annoy thee.

Note that it is not exhaustive list, neither it is some logically selected sub-list – just random thoughts.