събота, 13 септември 2014 г.

Unlocking Samsung SGH-A157

Not so long ago, I bought Samsung SGH-A157 from US. Since it is locked to ATT, I can not use it here in Bulgaria. Here is what I found in the web in order to unlock it:

  1. Remove SIM card and turn the phone on.
  2. Dial: *2767*3855# . This will initiate a Full reset for Samsung A157.
  3. After phone restart, enter #*7337# . This will remove SIM lock and reset the phone.
  4. Power off the phone. Now you can enter your SIM, turn the phone on and enjoy!

 This procedure is working for me! Good luck :)

вторник, 17 юни 2014 г.

Asus N56's running Ubuntu 14.04: display brighness and subwoofer


Not so long ago I bought an Asus N56JN notebook. Inexpensive, but powerful machine with nice sound. After managing to install UEFI Ubuntu 14.04 (the firmware does not support BIOS compatibility mode), I noticed several problems that really annoys me. First - the subwoofer is not working, next - can not control display brightness with Fn+F5/F6 buttons and constant power cycling of HDD when running on battery.
In order to really enjoy the sound system, I  needed to get your subwoofer working. After looking around, I found several blog posts and forum comments, related to the issue. Here is what I did. First open

/etc/modprobe.d/alsa-base.conf

and add following line to the end:


options snd-hda-intel model=,asus-mode4


Notice the comma sign, I have seen many suggestion doing this without it, but it didn't work on my machine. It won't hurt to try above with and without comma.
Next thing is get appropriate sound configuration 2.1. This is done by doing following. Edit the

/usr/share/pulseaudio/alsa-mixer/profile-sets/extra-hdmi.conf

file and add following:

[Mapping analog-surround-21]
device-strings = surround40:%f
channel-map = front-left,front-right,lfe,lfe
paths-output =
analog-output analog-output-speaker
priority = 7
direction = output



Then edit the file:

/etc/pulse/daemon.conf

and set:

enable-lfe-remix = yes

Now you can restart the system and set "analog-surround-21" in you sound settings. And one more thing - enjoy it!

Getting display brightness working is not so important as subwoofer, but it is still annoying. First I made working around - use custom keyboard shortcut with xbacklight utility. Ugly but working...until last Ubuntu update. So I needed the "real" solution to this problem. And here it is, edit the

/etc/default/grub

and set

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi="

Reboot the system and keep finger crossed.Hope this helps!

сряда, 22 януари 2014 г.

Code coverage with GCC, gcov and lcov

Want to see some code coverage in your C/C++ project. If you are going with gcc/g++ it is very easy. All you need is the GNU toolchain of course and lcov utility. The lcov utility is wrapper around another GNU tool: gcov. Let's see how it works.
Here is vary small c++ project with just 2 source and 1 header file:

main.cpp:
#include <iostream>
#include "testclass.h"
using namespace std;
void local1()
{
        cout << "local1()" << endl;
}
void local2()
{
        cout << "local2()" << endl;
}
int main()
{
        TestClass tc;
        tc.hello();
}
testclass.cpp:
#include <iostream>
#include "testclass.h"
using namespace std;
TestClass::TestClass()
{
        cout << "TestClass::TestClass()" << endl;

}
void TestClass::hello()
{
        cout << "TestClass::hello()" << endl;
}
testclass.h:
class TestClass
{
        public:
                TestClass();
                void hello();
};
makefile:

CPP=g++
CPPFLAGS=-c -Wall --coverage
LDFLAGS=--coverage
SRCS=main.cpp testclass.cpp
OBJS=$(SRCS:.cpp=.o)
EXEC=test

ALL: $(SRCS) $(EXEC)
       
$(EXEC): $(OBJS)
        $(CPP) $(LDFLAGS) $(OBJS) -o $@
.cpp.o:
        $(CPP) $(CPPFLAGS) $< -o $@
clean:
        rm -f $(EXEC)
        rm -f *.o

In order to collect coverage data, you need to compile and link source and object files with --coverage option.  Have a look at the makefile!
Data is analyzed by lcov utility:

$lcov -t "Coverage test" -o coverage.info -c -d .
And output is produced by genhtml tool:

$genhtml -o results coverage.info

Now you can go to "results" folder and enjoy the colorful output! Just open index.html and have fun:





събота, 6 април 2013 г.

My firsr Android App

As a android newbie I enjoy every little piece of code which can do something useful. After spending some time with several books and guides I became familiar with android's concept and framework. I was really surprised that after more than 10 years of software development, I would be happy with my initial attempts to develop "Hello world" like applications. This reminds me to my firsts attempts with programming: Quick Basic application for space flight simulation long time ago ...
Anyway, now I am proud with my first app, which can do something useful. It is called "SMSCarParking". Created in response to a request of one my colleagues, this utility is capable of sending predefined SMSes. The original idea is to simplify life with modern SMS Parking applications, which are quite common today.
The application is more like a toy, rather than real big application. But it can do the job! :) You can have a look at: http://code.google.com/p/smscarparking/. I am not ready to go to Google Play, but hopefully you will find it there any moment now.
The application is free, open source, no ads. Any comments, critics and ideas will be appreciated!

сряда, 22 август 2012 г.

Garmin NUVI 760 reset & map hacking

Всеки, който е използвал автомобилна навигация, знае колко полезна джаджа е това. И както всяко друго устройство, което използва софтуер, навигацията също може да се ушие. Това се случи и на моя любим Garmin Nuvi 760, в един слънчев ден при преминаването на Предела. Без външно захранване (т.е. на добре заредена батерия) изобщо не искаше да тръгне, а при включено захранване се пуска и зависва след 10-15 сек работа. Кофти работа ... Имах известни опасения, че устройството може да е дало фира, но все пак се захванах с по-оптимистичния вариант: проблем в софтуера. Първата и съвсем логична стъпка беше да върна началните настройки. Nuvi 760 няма reset бутон и се налага използването на следния "трик":

1. устройството се спира
2. натиска се и се задържа долния десен ъгъл на екрана
3. устройството се пуска
4. след няколко секунди се появява съобщение за потвърждение на началното установяване.

До колкото разбрах това работи за Garmin nuvi 200, 250, 360 750, 760. Е загубих всички натсройки, но ......... устройството отново работи :) За моя радост последната карта, която сложих беше непокътната, както и POI за камерите в България.

Малко по-късно реших да обновя картата на България в GPS-a. Както се досещате това трябваше да стане по нелегалния начин... За моя радост се натъкнах на това:

http://pitagorid.blog.bg/drugi/2010/04/28/kak-da-si-zaredim-karti-v-gps-garmin-ustroistvoto.535905


Мисля, че всичко е описано ясно и повярвайте - работи :)

вторник, 29 май 2012 г.

Bootable CDROM with isolinux & memdisk

Building your own, customizable, bootable CD is not a common task. You may never need to do it on your own. If you just want to boot a system - use any of the already pre-build bootable CDs. Here is an incomplete list of some of them:





Not so long ago, I need to get MS-DOS program running on my laptop. Unfortunately, the obvious choice here -  virtualization (i.e. VirtualBox, QEMU and others), was not possible. The program needs a PC running DOS compatible operating system as host operating systems. Beside this the program needs access to hardware serial port (no USB to Serial adapters). It also needs RW access to the the file system, which can be only FAT16/FAT32.Therefore I had two choices: to install DOS in separate FAT16/FAT32 partition on the hdd  and place the program inside it or build my own, customized bootable CD, which boots DOS and provides virtual disk drive in RAM so there is RW access to it. I decided to go with the bootable CD, since it provides portable solution which can be run on other PCs, without to need to re-partition the drive or install something.
I had some basic knowledge on booting process of x86 system and expected there is some kind of tool suite that would let me prepare the CD in few minutes.  Unfortunately it wasn't that easy. Following the tutorial from UBCD project: http://www.hiren.info/pages/bootablecd, I was able to build a bootbale CD very easy but for some reasons the provided MSCDEX driver (this is the DOS driver for CDROM support) can not recognize the CDROM of my laptop. It works fine in VirtualBox but not in the "real world". I tried with another driver but still no success. I suspect that problem here is the CDROM of the laptop, but I had to overcome it somehow. Obviously I need to read for a while and find better solution ...
After reading some wikis and blogs, I got the answers. There is lot of information but it was not collected in a single place. So here I will try to provide brief explanation how to create bootable CD with FreeDOS. My choice for a bootloader for the bootable CD is the syslinux/isolinux (http://www.syslinux.org/wiki/index.php/The_Syslinux_Project). I believe this is most flexible solution I've discovered. Syslinux can be used to boot any OS from a HDD, while isolinux is used with a CD. The combination of isolinux bootloader and memdisk module can provide bootable CD which creates virtual RAM drive wich have read write access. The virtual drive is fullfiled with  image file, containing  file system. The image file can be build in many ways, in particular I used QEMU emulator and UBCD bootable cd used as installation CD for the FreeDOS. The image contains FAT16 file system with installed FreeDOS operating system plus the program I need to run. The final step was mkiso utility which actually builds the iso file.


Tools required:

1. isolinux
2. QEMU
3. mkisofs
4. UBCD iso file

Step by step guide:

1. Create image file with QEMU. Following command will create 20MByte image file.

qemu-img create -f raw dos.img 20M

2. Install DOS compatible operating system. I used the UBCD as install CD for FreeDOS. Booting virtual PC with previously created image file as hard disk and UBCD iso file as CDROM can be done with the command:


qemu visa.img -cdrom ubcd511.iso -boot d

Before DOS installation I need to partition disk (i.e. the image file) and format the partitions. I used XFDISK from UBCD:



Installation of the FreeDOS was rather simple. It was done by booting the FreeDOS (from UBCD):





and executing following commands:

a:
format c:
sys c:
copy a:\bin\emm386.exe c:\
copy a:\bin\himem.exe c:\
copy q:\bin/edit.com c:\

For those one of you, who had used DOS operating systems before, these commands should be pretty clear. The format command performs partition formating, the sys command performs actual system installation. Basic install includes only modification of MBR and files: io.sys and msdos.sys. So here some additonal 9and optional) files are copied: drivers for high memory, extended memory and text editor.

If you need access to the file system from Linux, you are lucky:

sudo mount -o loop,offset=32256 dos.img /mnt

That's why I love Linux, try to do this within Windows ..... :)

I created two files in the root directory of the image file: config.sys and autoexec.bat. The contents of config.sys is:

device=c:\himem.exe
dos=high,umb
device=c:\emm362.exe noems
files=20

The file autoexec.bat contains commands which are executed during startup (for an example you can run any program you need to). I left it empry. Be aware for line endings in autoexec.bat and config.sys - unlike linux text files, they must end with CR LF!



3. Install bootloader and memdisk module. This is done by following commands:


mkdir iso
mkdir iso/isolinux
cp  /usr/lib/syslinux/isolinux.bin iso/isolinux/
cp  /usr/lib/syslinux/memdisk iso/isolinux/

Configuration file for the bootloader (iso/isolinux/isolinux.cfg) should have following contents:

default dos
timeout 1
label dos
      linux memdisk
      append initrd=/dos.img



4. Create iso file. This is done with mkiso utility:


cd iso
mkiso -o ../dos.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-tabl



5. Test the image file. You can use QEMU to test iso file before burning it:

qemu -cdrom ../dos.iso -boot d






6. Burn the iso file.


Well ...that was not that hard, right? :) Go and try it.



Some useful references:

http://en.wikibooks.org/wiki/QEMU/FreeDOS

http://www.syslinux.org/wiki/index.php/SYSLINUX

http://www.syslinux.org/wiki/index.php/MEMDISK

http://www.syslinux.org/wiki/index.php/Doc/isolinux

http://www.earth.li/~noodles/blog/2011/06/building-a-freedos-bootable-us.html

http://riskofruin.markmccracken.net/2011/02/booting-custom-isos-with-syslinux.html

http://www.nu2.nu/bootcd/






неделя, 29 април 2012 г.

Звездите, провинцията и бинокъла ...

Астрономията е готино хоби! Ясно небе, звезди, красота ... малка част от нещата, които веднага асоциирам с нея. Наистина не е толкова популярна като риболова например, нито има репутация на "мъжкарско" хоби или пък идеалния начин на разпускане. Изненадан съм, че не малка част от младите хората в България, го намират за странна екзотика и губене на време.Разбира се, всичко това няма значение, достатъчно е веднъж да отправиш поглед към нощното небе и да се влюбиш в звездите ...
Усещанията, които провокира астрономията у мен, са силни и противоречиви. От една страна не мога да се отърся от сладката романтика на добре познатата картинката: нощен пейзаж, звездно небе и наблюдател. Бих казал, че има и носталгичен привкус, който в моя случай ме връща назад в детските години и топлите нощи на село. От друга страна знанията за вселената и нейните мащаби, разстоянията до другите звезди и техните светове и човешкия живот като временна и пространствена рамка във вселената, ме кара да се чувствам подтиснат и незначителен. Нашия познат свят: Земята и  слънчевата система за просто капчица в океана на вселената, а човешкия живот - миг във вечността ...
За добри резултати в астрономията,  е необходимо човек да избяга от големия град и да си намери тихо, тъмно и приятно място. В моя случай бягството беше от мръсната и голяма София към родното място на любимата: малкото и китно Етрополе. След 2 силни ракии със мезе салата, реших да изляза на двора на къщата и да погледам наоколо ... Повечето хора асоциират телескопа като неделима "част" от всеки астроном. В същност не е съвсем така. Изобщо не искам да омаловажавам ролята на телескопа нито гледките, които може да ни покаже. И все пак - хората понякога подценяват "силата" на бинокъла. Голяма грешка - той е наистина чудесен инструмент. Тази вечер оставих телескопа и се въоръжих само със SkyMaster 15x70:


Достъпен и мощен - наистина страхотен бинокъл. Започнах с най-забележимото на небосклона:


Макар и спрягана като голям враг на астронома, поради силната светлина, луната е една чудесна гледа дори с невъоръжено око. След като се полюбувах на нашия спътник (за кой ли път), преместих погледа към Марс, който се намира в съзвездието Лъв:


С бинокъл не може да види диска. Но това не ми попречи да си припомня, че на Марс е имало океани, а може би дори живот ... преди някакви си 3.5 милиарда години. Разгледах и Сатурн. Дори и през бинокъл се виждаха пръстените. Е не е като в телескопа, но все пак си бяха там.
Голямата мечка беше точно над главата ми и нямаше как да я пропусна, особено двойката Алкор и Мицар:

След това дойде ред и на звездните купове. Макар, че луната създаваше известни пречки за наблюдение на deep space обекти, не се поколебах да атакувам.  Първо се порадвах на M44:

  Спираща дъха гледка!!!  Този отворен звезден куп е доста разпръснат и се вижда добре само с инструмент с широко зрително поле.
Насочих вниманието си към известния М13. Беше доста на изток т.е. далеч от най-добрата позиция за наблюдение, но все пак си заслужаваше:


За последно оставих М3. До сега не го бях виждал и реших да го оставя за десерт. Не беше много лесен за намиране с телескоп, но с бинокъла се справих бързо:


Ами това беше - чудесна вечер, приятна компания, страхотни гледки!