Februari 14, 2012

Using OrientDB - Tinkerpop Blueprints from NetBeans

Using OrientDB from NetBeans is pretty easy. Here I will give you some of the steps needed for the uninitiated. NetBeans version is not so important, although in this posting I use NetBeans 7.1. To follow this article, you need OrientDB (as this is about Tinkerpop Blueprints, of course you need orientdb-graphed package - mine is 1.0RC8), JDK (mine is JDK7_u2), and NetBeans (mine is 7.1). This article assume that we will use remote mode URL from OrientDB to connect to database. Here I just use tinkerpop database which already exist in $ORIENTDB_HOME/database/tinkerpop. So, first time is fire up your server:
$ server.sh

Open NetBeans and create your project (File - New Project - Java - Java Application) and put this:


Our project structure looks like this:


Next, we should manage OrientDB library. Choose Tools - Library Manager and put all of the jar files in $ORIENTDB_HOME/lib into one container like this (mine is called OrientDB-Tinkerpop):


After that, we put the library into our project by choosing File - Project Properties (FirstOrientDB) - Libraries then add OrientDB-Tinkerpop library into our project:


That's all the steps needed to prepare our project. For the source code part, it won't be too difficult also since we have the example from Tinkerpop Blueprints wiki (although they use Neo4J as an example). The class for OrientDB is OrientGraph. So, put this source code inside FirstOrientDB.java:
package firstorientdb;

import com.orientechnologies.common.exception.OException;
import com.tinkerpop.blueprints.pgm.impls.orientdb.OrientGraph;

/**
 *
 * @author bpdp
 */
public class FirstOrientDB {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

 OrientGraph graph = null;

        try {

            graph = new OrientGraph("remote:localhost/tinkerpop", "admin", "admin");
            System.out.println("Success");

        } catch (OException e) {
  
            System.out.println("Not succeed - " + e.getMessage());
  
        } finally {

            if( graph != null )
                graph.shutdown();

        }

    }
    
}
In the firstime, usually you have error from NetBeans. This error comes from library which should be imported. Instead of writing import statement by myself, I let the error happened and then resolve it by using Ctrl-Shift-I. From the source code, you may see that the connection was done by OrientGraph class. Its parameters are URL, username, password. We can see also that we can catch error by catching OException, the base Exception class in OrientDB. Here is the result when you press F6 or run the project:


If you can make it until this step, then you may now use Tinkerpop with your OrientDB inside your NetBeans project. Happy hacking!

Introduction to Graph Database and OrientDB

Graph database is a kind of NOSQL database which simply a term to show about the database management system software which is not a part of relational database. Since the scalability issues have arise and become a very big concerns for any company, this kind of database is getting more and more attention. People usually call this kind of needs on data scalability as web scale.

You may see from the data needs and inherent characteristics of web application that web is usually comprise of many resources which can link each other. This characteric is inherent in a graph, just like mathematicians usually care about. While the discussion about graph theory is outside from the scope of this article, readers interested in background theory about graph database should find a good book in discrete mathematics and especially graph theory. Graph theory is one prime object study of discrete mathematics and become one prominent theory since the first publishing of Leonhard Euler paper entitled "Seven Bridges of Königsberg". A graph consists of vertices and edges, as explained in this picture:


Graph theory has a very broad range of application, not just in web and / or computer science. That said, I will not repeat the things that already written in Wikipedia, just have a look at the Wikipedia articles and found it by yourself.

There are some companies and open source projects that realize the importance of graph theory and start the development of graph database. To make you confuse, there are some software that you can use, for example Neo4J, OrientDB, Mulgara - a specialized version of Graph Database which deals with RDF, etc. Benchmarking and choosing which graph database is better is not in the scope of this article and I personally do not interested in all of those lies, so I just want to use OrientDB for all my graph database needs. :p

OrientDB comes with small size zipped file. It takes only around 2 MB for OrientDB or you may get OrientDB with all of Tinkerpop "standard" inside only with around 8 MB size.
...
-rw-r--r-- 1 bpdp users 2689843 Feb  3 06:06 orientdb-1.0rc8.zip
-rw-r--r-- 1 bpdp users 8584056 Feb  3 06:07 orientdb-graphed-1.0rc8.zip
...

You will ask then, what is the difference between those two zip files? orientdb-version is the graph database software and only OrientDB, while for orientdb-graphed, is also consists of Tinkerpop thingie beside the graph database. Tinkerpop builds some software (open source) related with graph. You can use this graphed edition if you want to enable Tinkerpop abilities in your OrientDB database. It provides wrapper for OrientDB database so that you can use Tinkerpop related API in your software. There are 4 API supported by OrientDB: Blueprints, Gremlin, Rexster, and Pipes.

In this article, we will use the graphed version. Installation is pretty easy, as long as you have JDK, then it should not be a problem at all. What you need to do is only unzip the file and set some enviroment variables.
$ unzip orientdb-graphed-1.0rc8.zip
$ cd orientdb-graphed-1.0rc8

I put this in my $HOME/.bashrc file:
export ORIENTDB_HOME=/home/bpdp/software/orientdb/orientdb-graphed
export PATH=$PATH:$ORIENTDB_HOME/bin

One more thing, we should also change the configuration in $ORIENTDB_HOME/config/orientdb-server-log.properties to reflect the location of the log file:
java.util.logging.FileHandler.pattern=/home/bpdp/software/orientdb/orientdb-graphed/log/orient-server.log

You may of course change the location to any other place in filesystem that you want. To execute the server, use $ORIENTDB_HOME/bin/server.sh shell script:
$ server.sh 
           .                                              
          .`        `                                     
          ,      `:.                                      
         `,`    ,:`                                       
         .,.   :,,                                        
         .,,  ,,,                                         
    .    .,.:::::  ````                                   
    ,`   .::,,,,::.,,,,,,`;;                      .:      
    `,.  ::,,,,,,,:.,,.`  `                       .:      
     ,,:,:,,,,,,,,::.   `        `         ``     .:      
      ,,:.,,,,,,,,,: `::, ,,   ::,::`   : :,::`  ::::     
       ,:,,,,,,,,,,::,:   ,,  :.    :   ::    :   .:      
        :,,,,,,,,,,:,::   ,,  :      :  :     :   .:      
  `     :,,,,,,,,,,:,::,  ,, .::::::::  :     :   .:      
  `,...,,:,,,,,,,,,: .:,. ,, ,,         :     :   .:      
    .,,,,::,,,,,,,:  `: , ,,  :     `   :     :   .:      
      ...,::,,,,::.. `:  .,,  :,    :   :     :   .:      
           ,::::,,,. `:   ,,   :::::    :     :   .:      
           ,,:` `,,.                                      
          ,,,    .,`                                      
         ,,.     `,                     GRAPH-DB Server   
       ``        `.                                       
                 ``                                       
                 `                                        

2012-02-11 10:34:02:864 INFO [OLogManager] OrientDB Server v1.0rc8 (build @BUILD@) is starting up...
2012-02-11 10:34:03:336 INFO [OLogManager] -> Loaded memory database 'temp'
2012-02-11 10:34:03:372 INFO [OLogManager] Listening binary connections on 0.0.0.0:2424
2012-02-11 10:34:03:375 INFO [OLogManager] Listening cluster connections on 0.0.0.0:2434
2012-02-11 10:34:03:377 INFO [OLogManager] Listening http connections on 0.0.0.0:2480
2012-02-11 10:34:03:402 INFO [OLogManager] Installing GREMLIN language v.1.4
2012-02-11 10:34:03:437 INFO [OLogManager] OrientDB Server v1.0rc8 is active.

From another terminal, we may use $ORIENTDB_HOME/bin/console.sh shell script to access the server:
$ console.sh 
OrientDB console v.1.0rc8 (build @BUILD@) www.orientechnologies.com
Type 'help' to display all the commands supported.

Installing extensions for GREMLIN language v.1.4

> 

The database usually located in $ORIENTDB_HOME/database. Although you may have filesystem and memory as a URL for connection, this time we will use only remote to connect to the database. Here is how you will do it and how you will display information about the database:
> connect remote:localhost/tinkerpop admin admin
Connecting to database [remote:localhost/tinkerpop] with user 'admin'...OK

> info
Current database: tinkerpop (url=remote:localhost/tinkerpop)

Total size: 1.48Mb

Cluster configuration: {
    }

CLUSTERS:
----------------------------------------------+------+---------------------+-----------+-----------+
 NAME                                         |  ID  | TYPE                | RECORDS   | SIZE      |
----------------------------------------------+------+---------------------+-----------+-----------+
 index                                        |     1| PHYSICAL            |        11 |Not supported |
 orole                                        |     3| PHYSICAL            |         3 |Not supported |
 ouser                                        |     4| PHYSICAL            |         3 |Not supported |
 default                                      |     2| PHYSICAL            |         0 |Not supported |
 ographvertex                                 |     6| PHYSICAL            |       813 |Not supported |
 ographedge                                   |     7| PHYSICAL            |      8051 |Not supported |
 orids                                        |     5| PHYSICAL            |      3080 |Not supported |
 internal                                     |     0| PHYSICAL            |         3 |Not supported |
----------------------------------------------+------+---------------------+-----------+-----------+
 TOTAL                                                                               0 |        0b |
--------------------------------------------------------------------------------------- -----------+

CLASSES:
----------------------------------------------+---------------------+-----------+
 NAME                                         | CLUSTERS            | RECORDS   |
----------------------------------------------+---------------------+-----------+
 ORIDs                                        | 5                   |      3080 |
 OUser                                        | 4                   |         3 |
 OGraphEdge                                   | 7                   |      8051 |
 ORole                                        | 3                   |         3 |
 OGraphVertex                                 | 6                   |       813 |
----------------------------------------------+---------------------+-----------+
 TOTAL                                                                    11950 |
--------------------------------------------------------------------------------+

INDEXES:
----------------------------------------------+------------+-----------------------+----------------+-----------+
 NAME                                         | TYPE       |         CLASS         |     FIELDS     | RECORDS   |
----------------------------------------------+------------+-----------------------+----------------+-----------+
 edges                                        | NOTUNIQUE  |                       |                |        89 |
 vertices                                     | NOTUNIQUE  |                       |                |       977 |
 dictionary                                   | DICTIONARY |                       |                |         0 |
----------------------------------------------+------------+-----------------------+----------------+-----------+
 TOTAL = 3                                                                                                 1066 |
----------------------------------------------------------------------------------------------------------------+


> 

To shutdown the server, give shutdown.sh command from the shell:
$ shutdown.sh 
Sending shutdown command to remote OrientDB Server instance...
Shutdown executed correctly

You will see this one from server console:
2012-02-14 10:47:50:750 INFO [OLogManager] Received shutdown command from the remote client /127.0.0.1:57411
2012-02-14 10:47:50:750 INFO [OLogManager] Remote client /127.0.0.1:57411 authenticated. Starting shutdown of server...
2012-02-14 10:47:50:751 INFO [OLogManager] OrientDB Server is shutdowning...
2012-02-14 10:47:51:497 INFO [OLogManager] Shutdowning handler graph...
2012-02-14 10:47:51:498 INFO [OLogManager] Shutdowning handler default...
2012-02-14 10:47:51:499 INFO [OLogManager] Shutdowning handler automaticBackup...
2012-02-14 10:47:51:499 INFO [OLogManager] Shutdowning connection listener 'ONetworkProtocolBinary /0.0.0.0:2424:'...
2012-02-14 10:47:51:499 INFO [OLogManager] Shutdowning connection listener 'OClusterNetworkProtocol /0.0.0.0:2434:'...
2012-02-14 10:47:51:500 INFO [OLogManager] Shutdowning connection listener 'ONetworkProtocolHttpDb /0.0.0.0:2480:'...
2012-02-14 10:47:51:500 INFO [OLogManager] OrientDB Server shutdown complete

To conclude, there are still some areas that maybe need more attention. People in IT love standardization, although sometimes they create more than one standard for one purpose. UnQL, the standard for document-oriented is alredy discussed while there are still a little bit flux in Graph Database world. Someday maybe people start to discuss this issue and come up with the result. Well, hopefully :)

Februari 13, 2012

Apache OFBiz - ASF Solution for Enterprise Automation

As my daily jobs require me to pay attention only to the development tools, I don't pay attention to this software in the first place. What I mean by this is, I realized that there is an ERP solution from Apache Software Foundation before but after I promise my students to give them a free and open source software in my "Business Information Systems" class, then I started to look for free and open source ERP package. Then I remember about Apache OFBiz Project which provide with a complete ERP package for free (in the sense of free beer and free speech). In the list below, you may have these functionalities inside (taken from the website):
  1. Advanced e-commerce 
  2. Catalog management 
  3. Promotion and pricing management 
  4. Order management (sales and purchase) 
  5. Customer management (part of general party management) 
  6. Warehouse management 
  7. Fulfillment (auto stock moves, batched pick, pack and ship) 
  8. Accounting (invoice, payment and billing accounts, fixed assets)
  9. Manufacturing management 
  10. General work effort management (events, tasks, projects, requests, etc)
  11. Content management (for product content, web sites, general content, blogging, forums, etc) 
  12. A maturing Point Of Sales (POS) module using a rich client interface 
  13. /etc
The installation is pretty straightforward as it was written in README files that goes inside the tarball (or actually the zipped file) that you can download. Unfortunately, you have to build and populate the database first (at first, it uses only JavaDB, but you may change it to another DBMS software.

To install the software, just unpack and then build and populate database by using Apache Ant which is already included in the distribution, and you are good to go:


$ unzip apache-ofbiz-10.04.zip
$ cd apache-ofbiz-10.04
$ ./ant run-install

Notes
 You can not use JDK7 with Apache OFBiz, instead use JDK6 (latest version is 1.6.0_29). I use 1.6.0_27 and it still works correctly. If you use Windows, read the README file. If you are too lazy, wipe away your Windows OS, install Linux, follow the instruction in this blog and you are all set. :p

After finish with "BUILD SUCCESS" notification, run Apache OFBiz using the shell script (startofbiz.sh) or batch file (startofbiz.bat) if you use Windows. At first you will be overwhelmed by too many messages in console:

$ ./startofbiz.sh 
Set OFBIZ_HOME to - /home/bpdp/master/apache-ofbiz/apache-ofbiz-10.04
Admin socket configured on - /127.0.0.1:10523
2012-02-14 01:34:02,569 (main) [    ContainerLoader.java:50 :INFO ] [Startup] Loading containers...
2012-02-14 01:34:02,966 (main) [ ComponentContainer.java:177:INFO ] Auto-Loading component directory : [/home/bpdp/master/apache-ofbiz/apache-ofbiz-10.04/framework]
2012-02-14 01:34:03,007 (main) [ ComponentContainer.java:238:INFO ] Loading component : [geronimo]
2012-02-14 01:34:03,062 (main) [ ComponentContainer.java:238:INFO ] Loading component : [sql]
..........
..........
..........
..........
..........
2012-02-14 01:35:00,935 (default-invoker-Thread-11) [                Log.java:111:INFO ] [CommonPermissionServices.xml#genericBasePermissionCheck] Checking for primary permission ACCOUNTING_CREATE
2012-02-14 01:35:00,961 (default-invoker-Thread-11) [     ServiceEcaRule.java:134:INFO ] For Service ECA [fixedAssetPermissionCheck] on [return] got false for condition: [hasPermission][equals][false][true][Boolean]
2012-02-14 01:35:00,972 (default-invoker-Thread-11) [  ServiceDispatcher.java:599:INFO ] Sync service [JobDispatcher/fixedAssetPermissionCheck] finished in [3751] milliseconds
2012-02-14 01:35:01,000 (default-invoker-Thread-8) [  ServiceDispatcher.java:599:INFO ] Sync service [JobDispatcher/sendEmailDated] finished in [4124] milliseconds
2012-02-14 01:35:01,105 (default-invoker-Thread-11) [  ServiceDispatcher.java:599:INFO ] Sync service [JobDispatcher/createMaintsFromTimeInterval] finished in [3898] milliseconds

To see your e-Commerce site (the front page of your Apache OFBiz application), go to http://server:8080/ecommerce.




The backend can be accessed by using http://server:8443/webtools.





For the first time, you may login using "admin" as username and "ofbiz" as password.




Here is the result of backend login:





You may see that this kind of software can be a good example of free and open source software for your business need. If you are a technopreneur, why don't you get involved in the project and sell the service to customers? It's up to you now, you have all you need.

Enjoy!

Januari 22, 2012

Arrows Problem in NERDTree Vim Plugin

The NERDTree plugin in Vim is used to present and display directories and files in your filesystem location. I found this plugin very useful to manage my code. The small problem at the first time I used this plugin is the display of explored filesystem. Default in my terminal like this:


Not beautiful of course. So, I tried to find the solution. The problem lies in how we define arrow for explored filesystem. Just add this in your $HOME/.vimrc:
let g:NERDTreeDirArrows=0
Here's the more beautiful result:



Just for the record, I also use this startup NERDTree command in my .vimrc:
 
" always open NERDTree 
autocmd vimenter * NERDTree

" if the last window is NERDTree, then close Vim
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif 

let g:NERDTreeDirArrows=0 

Januari 16, 2012

Menggunakan awesome Window Manager untuk Keperluan Sehari-hari

Tulisan ini hanya sedikit sekali membahas tentang awesome Window Manager (http://awesome.naquadah.org/). Kalau mau mengetahui apa itu awesome, mengapa dibuat awesome, dan lain-lain yang lebih lengkap, ya ke 'rumah'nya saja. Tulisan ini barangkali tidak akan menarik bagi orang-orang yg tdk menyukai old school. Jika tidak mengetahui arti dari old school, ya berarti memang anda termasuk orang-orang yg tdk menyukai itu. hehehe ...

Saya pertama kali mengetahui awesome dari TL twitter-nya Zed Shaw. Berhubung orang ini memang termasuk freak, saya jadi ingin tahu tentang awesome. Fakta bahwa awesome meng-embedd Lua dan menggunakan Lua untuk konfigurasinya juga menarik perhatian saya.

Untuk menginstall, karena saya menggunakan Frugalware, ya cukup begini saja:
pacman-g2 -S awesome
Kalau memang mau install from scratch alias mengkompilasi sendiri, ya boleh juga. Setelah itu, akan muncul di menu display manager dan bisa dipilih saat akan login. Kalau tidak mengaktifkan display manager, cukup menuliskan berikut ini di file $HOME/.xinitrc:
exec /usr/bin/awesome
Catatan: sesuaikan letak dari binary executable di sistem anda.

Tampilan awal nanti akan seperti berikut ini:



Konfigurasi awasome diletakkan di /etc/xdg/awesome/rc.lua dan berupa script Lua. Pada konfigurasi tersebut, saya ubah terminal yang akan digunakan oleh awesome saat menampilkan manual page maupun saya mengeksekusi perintah. Terminal yang saya gunakan adalah mrxvt. sedangkan editor yang saya gunakan adalah vim. Berikut ini adalah bagian yang saya ubah:
-- This is used later as the default terminal and editor to run.
terminal = "mrxvt"
editor = os.getenv("EDITOR") or "vim"
-- editor_cmd = terminal .. " -e " .. editor
editor_cmd = "xterm -e " .. editor
Kondisi lainnya saya biarkan tetap default. Mengaturnya nanti kalau udah punya waktu untuk belajar lagi. Hehehe ... Hasilnya kurang lebih ya seperti ini:


Setelah itu tinggal menggunakan beberapa kombinasi tombol:
  1. [Windows start] + Enter = membuka terminal baru (mrxvt)
  2. [Windows start] + r = eksekusi perintah
  3. [Windows start] + j atau k = mengaktifkan window sebelum atau sesudahnya
  4. [Windows start] + m atau n = maximize window atau minimize window
Tombol [Windows start] di manual awesome adalah tombol Mod4. Tombol ini biasanya digunakan di SO Windows untuk mengaktifkan start menu. Tombol ini sebenarnya bisa diganti-ganti, cuman saya pakai ini karena kasihan tombol itu gak pernah disentuh. hahaha ...

Barangkali cukup itu dulu untuk sehari-hari. Enjoy awesome and become awesome! awesome - wm untuk #gali!

Desember 24, 2010

Mengaktifkan command line editing (Readline) di Python


Secara default, pada saat kita masuk ke python command line, tidak akan ada completion seperti halnya bila kita menggunakan bash, tcsh, atau zsh. Untuk mengaktifkan tab completion, biasanya kita menggunakan langkah-langkah berikut:
[bpdp@bpdp-arch ~]$ python
Python 3.1.3 (r313:86834, Dec  1 2010, 12:35:23)
[GCC 4.5.1 20101125 (prerelease)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import readline
>>> import rlcompleter
>>> readline.parse_and_bind(“tab: complete”)
Untuk mengotomatiskan langkah-langkah tersebut sehingga tidak perlu mengeksekusi berbagai perintah diatas, gunakan langkah-langkah sebagai berikut (asumsi: OS Linux dengan shell Bash):
Buat file $HOME/.pythonrc. Isinya:
import readline
import rlcompleter
readline.parse_and_bind(“tab: complete”)
Tambahkan env var yang diperlukan di $HOME/.bashrc
export PYTHONPATH=~/.pythonrc
Selesai
Saat masuk ke command line Python, otomatis mode command line editing telah tersedia dengan menekatan tombol tab, sama halnya dengan di Bash:
[bpdp@bpdp-arch ~]$ python
Python 3.1.3 (r313:86834, Dec  1 2010, 12:35:23)
[GCC 4.5.1 20101125 (prerelease)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> help(
Display all 163 possibilities? (y or n)

Oktober 21, 2010

Menggunakan AHA dengan Olive VME-110 di Arch Linux

Tulisan sederhana ini sekedar menjelaskan sedikit cara untuk bisa menggunakan modem EVDO dari AHA di Arch Linux. Untuk modem, saya menggunakan Olive VME-110 yang berwarna putih (yang berwarna perak merk-nya Huawei, caranya mungkin beda sedikit dengan yang ada di tulisan ini). Di tulisan ini, penyebutan "modem" berarti akan mengacu ke Olive VME-110 (males nulisnya kalau panjang ... :-D).

Paket yang Diperlukan

Ada beberapa paket yang diperlukan untuk mengaktifkan modem ini yaitu: wvdial dan usb_modeswitch. Untuk menginstall, gunakan pacman (tentu saja jika belum bisa koneksi ke Internet, ngalah dulu sebentar cari koneksi kabel atau wifi):
# pacman -S wvdial usb_modeswitch
Biasanya instalasi wvdial juga akan menyertakan wvstreams.

Mengubah dari Mode Storage ke Mode Modem

Setelah instalasi paket yang diperlukan di atas, lakukan langkah-langkah berikut untuk konfigurasi.

Aktifkan modul kernel usbserial:
# modprobe usbserial
Masukkan modem ke USB port. Kernel akan mengenali device sebagai USB storage (karena modem ini bisa difungsikan juga sebagai USB flashdisk) berikut ini:

Initializing USB Mass Storage driver...
scsi6 : usb-storage 2-1.1:1.0
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
scsi 6:0:0:0: CD-ROM            Qualcomm MMC Storage      2.31 PQ: 0 ANSI: 2
sr1: scsi3-mmc drive: 0x/58x caddy
sr 6:0:0:0: Attached scsi CD-ROM sr1
sr 6:0:0:0: Attached scsi generic sg2 type 5
sr1: CDROM (ioctl) error, command: cdb[0]=0x51 51 00 00 00 00 00 00 00 02 00
sr: Sense Key : 0x4 [current] 
sr: ASC=0x0 ASCQ=0x0

Supaya bisa dikenali sebagai GSM modem (/dev/ttyUSB*), maka fasilitas storage (diatas dikenali sebagai Qualcomm - di Windows juga dikenali sebagai Qualcomm) harus di-eject dulu:
# eject /dev/sr1
Saya menggunakan /dev/sr1 karena sesuai dengan pesan yang ada di atas, bahwa storage tersebut di kenali sebagai sr1 (lihat baris "sr1: scsi3-mmc drive: 0x/58x caddy", di tempat lain, bisa saja sr0). Setelah di-eject, maka modem baru akan dikenali:

usb 2-1.1: USB disconnect, address 3
cdrom: issuing MRW back ground format suspend
usb 2-1.1: new full speed USB device using ehci_hcd and address 4
option 2-1.1:1.0: GSM modem (1-port) converter detected
usb 2-1.1: GSM modem (1-port) converter now attached to ttyUSB0
option 2-1.1:1.1: GSM modem (1-port) converter detected
usb 2-1.1: GSM modem (1-port) converter now attached to ttyUSB1
option 2-1.1:1.2: GSM modem (1-port) converter detected
usb 2-1.1: GSM modem (1-port) converter now attached to ttyUSB2

Device juga muncul:

[bpdp@bpdp-arch ~]$ ls -la /dev/ttyUSB*
crw-rw---- 1 root uucp 188, 0 Oct 22 08:45 /dev/ttyUSB0
crw-rw---- 1 root uucp 188, 1 Oct 22 08:45 /dev/ttyUSB1
crw-rw---- 1 root uucp 188, 2 Oct 22 08:45 /dev/ttyUSB2
[bpdp@bpdp-arch ~]$ 

Konfigurasi usb_modeswitch

Paket usb_modeswitch yang saya gunakan belum menyertakan definisi hardware dari modem, jadi kita akan membuat konfigurasinya sendiri. Pertama, kita mencari ID dari device modem:

[bpdp@bpdp-arch ~]$ lsusb 
Bus 002 Device 004: ID 201e:2009  
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 0b05:1788 ASUSTek Computer, Inc. 
Bus 001 Device 003: ID 04f2:b071 Chicony Electronics Co., Ltd 2.0M UVC Webcam / CNF7129
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[bpdp@bpdp-arch ~]$

Di Arch Linux, device dikenali dengan ID vendor 201e dan ID product 2009. Setelah mengetahui ID ini, buat konfigurasi file baru di "/etc/usb_modeswitch.d/201e\:2009" yang berisi teks berikut:

########################################################
# AHA.co.id
# 201e:2009


DefaultVendor= 0x201e
DefaultProduct=0x2009


TargetVendor= 0x201e
TargetProduct= 0x2009


CheckSuccess=20


MessageContent="555342431234567824000000800108df200000000000000000000000000000"

Konfigurasi wvdial

Buat file baru (atau tambahkan entry berikut jika sudah ada filenya) untuk konfigurasi wvdial di "/etc/wvdial.conf". Isinya adalah teks sebagai berikut:

[Dialer aha]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = USB Modem
Baud = 115200
Modem= /dev/ttyUSB0


Phone = #777
Username = aha@aha.co.id
Password = aha
New PPPD = yes
Stupid Mode = 1

Konfigurasi udev

Konfigurasi udev diperlukan supaya kita tidak perlu repot-repot meng-eject setiap kali memasukkan modem ke USB port. Buatlah file baru di "/etc/udev/rules.d/99-evdo-modem.rules" yang berisi:

SYSFS{idVendor}=="201e",
SYSFS{idProduct}=="2009", RUN+="/usr/bin/eject %k"

Konfigurasi Modul Kernel

Masukkan "usbserial" dalam array MODULES yang ada di file "/etc/rc.conf". Jika sebelumnya sudah ada modul lainnya, tinggal tambahkan saja sebagai berikut (di file saya sudah ada modul ath9k, tidak perlu anda tulis jika tidak menginginkan modul ath9k tersebut aktif):

...
...
MODULES=(ath9k usbserial)
...
...

Menggunakan Modem

Langkah-langkah di atas sudah cukup untuk mengkonfigurasi modem. Jika kita ingin mengaktifkan, tinggal men-dial menggunakan wvdial sebagai berikut:

[root@bpdp-arch ~]# wvdial aha
--> WvDial: Internet dialer version 1.61
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT 3100000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Fri Oct 22 09:13:09 2010
--> Pid of pppd: 2578
--> Using interface ppp0
--> pppd:  [01]� �[01]� 
--> pppd:  [01]� �[01]� 
--> pppd:  [01]� �[01]� 
--> pppd:  [01]� �[01]� 
--> pppd:  [01]� �[01]� 
--> local  IP address 10.69.7.130
--> pppd:  [01]� �[01]� 
--> remote IP address 192.168.11.10
--> pppd:  [01]� �[01]� 
--> primary   DNS address 10.8.9.2
--> pppd:  [01]� �[01]� 
--> secondary DNS address 192.168.190.66
--> pppd:  [01]� �[01]� 

Jika ingin disconnect, tekan Ctrl-C di posisi tersebut. Untuk seterusnya, jika ingin koneksi ke Internet menggunakan modem, yang kita lakukan hanya:
1. Masukkan modem ke port USB
2. dari terminal, sebagai root, ketikkan "wvdial aha"

Mudah bukan? Happy browsing using Arch Linux! :)

Catatan: 
Saat mencari cara untuk koneksi menggunakan AHA dengan modem Olive VME-110 ini, saya sangat terbantu dengan artikel dan komentar di URL http://www.icemanblogger.com/2010/07/setting-modem-aha-olive-v-me110-di.html. Bersama ini, rasanya saya perlu mengucapkan terima kasih untuk yang telah menulis artikel di atas dan komentar-komentar di bawahnya.

September 05, 2010

Model Interaksi Aplikasi Web

Pendahuluan


Tulisan ini membahas tentang gambaran umum model interaksi dari aplikasi web. Seperti yang kita ketahui, aplikasi web pada dasarnya terdiri atas dua sisi yaitu sisi klien dan sisi server. Meskipun selalu mempunyai pola klien-server, implementasi model ini mempunyai perkembangan yang menarik untuk diamati karena semakin hari semakin berkembang ke arah interaktivitas yang lebih baik.



Berbagai Model Interaksi Aplikasi Web


Aplikasi web mempunyai siklus request-response. Klien web (web browser) mengirimkan permintaan ke server (request), server menerima request tersebut kemudian memproses request dan mengirimkan hasilnya (response) ke server. Siklus ini bisa kita lihat pada gambar berikut:


Sampai saat ini, ada tiga kategori besar dari aplikasi web berdasarkan pada model interaksi klien-server:
  1. Model Tradisional
  2. Model Ajax
  3. Model Comet
Model Interaksi Tradisional

Model interaksi tradisional mempunyai pola halaman-demi-halaman. Pola ini yang pertama kali digunakan pada saat Tim Berners-Lee mulai mengembangkan HTML dan ingrastrukturnya. Pada model ini, web browser mengirimkan permintaan ke web server, sementara itu web server menerima permintaan dan mengirimkan hasilnya ke web browser. Saat menerima response dari web server, web browser akan me-refresh keseluruhan halaman web. Model ini masih digunakan sampai saat ini. Model ini dianggap "mahal" karena "memaksa" web server untuk mengirimkan keseluruhan halaman yang ditampilkan oleh web browser sehingga memerlukan sumber daya Internet yang relatif besar untuk lalu lintas data. Secara konsepsual, model ini bisa digambarkan untuk aplikasi web yang meminta user untuk melakukan login sebagai berikut:



Pada gambar tersebut, kira-kira logik yang harus dikerjakan oleh pemrogram adalah membuat form HTML dengan action ke script pemroses di server. Saat user mengklik tombol Submit, web browser akan mengirimkan variabel-variabel yang terdapat pada form tersebut dan akan diproses oleh server begitu server menerima variabel tersebut. Setelah diproses, seluruh HTML dikirimkan kembali ke web browser untuk di-render.

Untuk membuat aplikasi web seperti ini, yang diperlukan adalah komponen-komponen berikut:
  1. Web browser yang bisa me-render HTML beserta pendukungnya (CSS,JavaScript, jpg, png, gif, dan lain-lain).
  2. Web server (Apache web server, IIS, yaws, lighttpd, nginx, dan lain-lain)
  3. Jika akan menambahkan pemrosesan business logic di sisi server, bisa ditambahkan server-side scripting language (PHP, JSP, ASP, dan lain-lain tergantung pada compiler/interpreter yang didukung oleh web server).
Model Ajax

Ajax (Asynchronous JavaScript and XML) adalah sekumpulan teknologi untuk membuat aplikasi web lebih interaktif dengan cara menggunakan berbagai teknologi dan spesifikasi yang telah ada untuk mengambil data dari server secara asynchronous dan me-render hasilnya ke display web browser tanpa "mengganggu" bagian lainnya. Konsep inti dari Ajax adalah menetapkan bagian tertentu dari halaman web yang akan diambil dari server, kemudian secara asynchronous mengambil data di latar belakang setelah itu menampilkan hanya pada bagian yang berubah itu saja. Istilah Ajax dikemukakan oleh Jesse James Garret pada essay yang ditulisnya pada tahun 2005 dengan judul "Ajax: A New Approach to Web Applications" (http://www.adaptivepath.com/ideas/essays/archives/000385.php).

Secara konsepsual, model interaksi ini bisa digambarkan sebagai berikut (gambar diambil dari artikel milik Jesse James Garret dan merupakan hak cipta dari yang bersangkutan):


Ajax bekerja dengan menggunakan berbagai teknologi berikut:
  1. HTML/XHTML dan CSS (serta pendukung lainya - gambar PNG, JPG, GIF) untuk lapisan presentasi.
  2. DOM (Document Object Model) merupakan konvensi yang cross-platform dan language-independent untuk merepresentasikan dan berinteraksi dengan obyek dalam HTML, XHTML, dan XML. Antarmuka publik dari DOM ini diimplementasikan dalam bentuk API (Application Programming Interface). JavaScript adalah salah satu contoh bahasa yang mendefinisikan API untuk memanipulasi berbagai elemen DOM ini. Teknologi ini tidak selalu menggunakan JavaScript, tetapi bisa juga menggunakan client-side programming language lainnya seperti JScript (implementasi ECMAScript dari Microsoft) atau VBScript (hanya bisa digunakan di Internet Explorer).
  3. XML untuk format pertukaran data serta XSLT untuk pemrosesnya. Teknologi ini tidak selalu digunakan, banyak diantara pemrogram yang menggunakan JSON sehingga XSLT tidak diperlukan lagi.
  4. XMLHttpRequest, yaitu API yang terdapat pada client-side scripting language (diantaranya JavaScript) yang digunakan untuk mengirimkan request HTTP/S secara langsung ke web server dan me-load response dari web server secara langsung ke dalam script.
  5. JavaScript untuk mem-binding berbagai teknologi tersebut ke dalam suatu interaksi baik dari suatu aplikasi web.
Contoh dari aplikasi yang berbasis Ajax ini bisa dilihat pada berbagai implementasi dari aplikasi web berikut:
  1. Suggestions pada saat mengisikan input text di mesin pencarian Google/Yahoo/dan lain-lain.
  2. Mengisi komentar, mengirimkan message di Facebook dan masih banyak lainnya.
Model Comet

Model ini merupakan model yang mulai banyak digunakan dan merupakan perkembangan terakhir dengan tingkat interaktivitas aplikasi ke user yang paling bagus. Istilah Comet muncul pertama kali pada blog Alex Russel (project leader dari Dojo Toolkit dan presiden dari Dojo Foundation) di http://infrequently.org/2006/03/comet-low-latency-data-for-the-browser/. Comet dikenal juga dengan berbagai istilah berikut:
  1. Ajax Push
  2. Reverse Ajax
  3. Two-way-web
  4. HTTP Streaming
  5. HTTP Server Push
Model ini sebenarnya merupakan sekumpulan teknologi yang memungkinkan suatu aplikasi web untuk mengirimkan data dari server ke browser menggunakan teknologi push. Secara konsepsual, Coment bekerja menggunakan gambaran berikut (gambar diambil dari blog Alex Russel):


Comet bisa diimplementasikan menggunakan dua metode yaitu Streaming dan Long Polling, meskipun penggunaan Long Polling makin banyak digunakan. Contoh dari aplikasi web menggunakan Comet ini antara lain bisa dilihat di Facebook. Pada aplikasi Facebook, notification akan secara otomatis muncul (dalam bentuk angka dengan latar belakang merah) tanpa diminta atau di-request ulang ke server. Server Facebook akan mem-push notification tersebut ke web browser.

Beberapa web server yang sudah mendukung Comet ini antara lain adalah:
  1. Caplin Liberator (http://www.freeliberator.com/ - dibangun menggunakan C)
  2. Cometd (http://cometd.com/ - dibangun menggunakan Python)
  3. ErlyComet (http://erlycomet.googlecode.com/ - Erlang)
  4. Glassfish (http://glassfish.dev.java.net/ - Java)
  5. Jetty (http://jetty.mortbay.org/ - Java)
  6. Lightstreamer (http://lightstreamer.com/ - Java)
  7. Meteor (http://meteorserver.org/ - Perl)
  8. Orbited (http://www.orbited.org/ - Python)
  9. Persevere (http://persevere.sitepen.com/ - Java-JavaScript)
  10. RMDS2Web Server (http://www.migratory.ro/ - Java)
Penutup

Model interaksi tersebut sebenarnya tidak tergantung pada tingkat kekinian tools. Sebagai contoh, menggunakan Jetty yang sudah mendukung Comet tidak serta merta menjadikan aplikasi tersebut sebagai model aplikasi web yang menggunakan interaksi Comet. Dengan demikian, memang harus berhati-hati dalam mendefinisikan hal ini.

Tertarik? Silahkan mencoba membuat aplikasi dengan berbagai macam teknologi dan model interaksi tersebut. Tools sudah banyak tersedia dan banyak pula yang merupakan software bebas.

Selamat belajar dan berkarya :)

September 01, 2010

Masalah upgrade Ruby di Arch Linux

Untuk rekan-rekan yang menggunakan Arch Linux, proses update dan upgrade Ruby dari versi 1.9.1 (atau 1.8.7 juga ya?) ke versi berikutnya (1.9.2) mungkin bisa melihat ada masalah. Mulai dari instalasi yang gagal karena menumpuki file-file lama di /usr/share/ri dan /usr/lib/ruby, sampai dengan gem yang jika dijalankan malah memunculkan error.

Saya belum melihat ke bug yang di-report, tapi langsung saya mencoba otak atik. Untuk instalasi saja sebenarnya bisa selesai dengan menyertakan --force:

# pacman -S --force ruby

Sayangnya, ini akan menimbulkan kekacauan saat menjalankan 'gem'. Jika mengalami masalah ini, silahkan uninstall ruby, hapus direktori /usr/lib/ruby dan /usr/share/ri. Setelah itu, baru install ruby yang baru.

Catatan: Upgrade ke 1.9.2 perlu dilakukan jika kita ingin menggunakan Rails 3.0.

Selamat mencoba.

Mei 25, 2010

Konfigurasi EV-DO Smart di Chakra (Phoix) / Arch Linux

Chakra (http://www.chakra-project.org) merupakan (saat ini) distrolet yang dikembangkan dari Arch Linux (http://www.archlinux.org). Chakra mempermudah anda jika ingin langsung mempunyai desktop yang fully functional dengan menggunakan desktop environment KDE. Tulisan ini akan menjelaskan cara menggunakan USB Modem EVDO ZTE AC 2726 dengan provider Smart. Tulisan ini berdasarkan pada pengalaman mas Muhammad Iqbal di http://masiqbal.net/modem-smart-evdo-zte-ac2726-di-linux.php (terima kasih mas!) dan manual dari usb_modeswitch yang bisa diperoleh di http://www.draisberghof.de/usb_modeswitch/

OS yang saya gunakan adalah Chakra versi terakhir (Phoix). Meskipun menggunakan Chakra, tulisan yang ada disini bisa diterapkan juga untuk Arch Linux. Chakra dan Arch yang akan anda gunakan sudah harus mempunyai Yaourt karena instalasi nantinya akan menggunakan Yaourt. Jika belum mempunyai, anda bisa menggunakan Pacman untuk menginstall Yaourt.

Pada saat modem USB dicolokkan, Chakra sudah langsung mengenali. Berikut adalah snapshot dari lsusb:

[root@chakra etc]# lsusb 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 003: ID 19d2:fff5 ONDA Communication S.p.A. 
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 03f0:171d Hewlett-Packard Wireless (Bluetooth + WLAN) Interface [Integrated Module]
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 04f2:b016 Chicony Electronics Co., Ltd VGA 30fps UVC Webcam
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[root@chakra etc]# 

Device yang dikenali disitu adalah "Bus 005 Device 003: ID 19d2:fff5 ONDA Communication S.p.A.". Meskipun sudah dikenali, perlu digunakan usb_modeswitch untuk mengubah dari mode storage ke mode Modem. Berikut adalah langkah-langkan instalasi paket supaya modem bisa digunakan.

Langkah pertama adalah instalasi usb_modeswitch menggunakan Yaourt:

[root@chakra ~]# yaourt -Ss usb_modeswitch
aur/usb_modeswitch 1.1.2-1 (83)
  Activating switchable USB devices on Linux.
aur/usb_modeswitch-fixed 1.1.1-3 (Out of Date) (13)
  Activating switchable USB devices on Linux.
aur/usb_modeswitch-updated 1.1.1-1 (2)
  Activating switchable USB devices on Linux.
[root@chakra ~]# yaourt -S usb_modeswitch
==> WARNING: Building package as root is dangerous.
 Please run yaourt as a non-privileged user.

==> Downloading usb_modeswitch PKGBUILD from AUR...
--2010-05-26 09:43:18--  http://aur.archlinux.org/packages/usb_modeswitch/usb_modeswitch.tar.gz
Resolving aur.archlinux.org... 208.92.232.29
Connecting to aur.archlinux.org|208.92.232.29|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 693 [application/x-tgz]
Saving to: “usb_modeswitch.tar.gz”

100%[=============================================================>] 693         --.-K/s   in 0s      

2010-05-26 09:43:24 (54.7 MB/s) - “usb_modeswitch.tar.gz” saved [693/693]

bsdtar: Removing leading '/' from member names
x PKGBUILD

Comment by: cyberpatrol on Wed, 24 Mar 2010 22:23:14 +0000
Please, update this package. Version 1.1.1 is out and the version 1.1.0 is not available for downloading anymore.

Comment by: helios on Fri, 26 Mar 2010 13:46:40 +0000
I will update it as soon as I get back from holiday.

Comment by: gborzi on Tue, 20 Apr 2010 22:29:21 +0000
Version 1.1.2 is available, it requires tcl to work. Also udev doesn't seem able to find the tcl script which is installed by default as
/lib/udev/usb_modeswitch/usb_modeswitch.tcl
installing it as /lib/udev/usb_modeswitch it is found and works. This is the PKGBUILD I've used to make the package
pkgname=usb_modeswitch
pkgver=1.1.2
pkgrel=1
_pkgdata=20100418
pkgdesc="Activating switchable USB devices on Linux."
arch=('i686' 'x86_64')
url="http://www.draisberghof.de/usb_modeswitch/"
license=('GPL')
depends=('libusb' 'tcl')
makedepends=('gcc' 'make' 'wget')
backup=('/etc/$pkgname.conf')
source=("http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-${pkgver}.tar.bz2"
"http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-data-${_pkgdata}.tar.bz2")
md5sums=('071cb300d00938bfe20025c654303d92' '659c9633513fa2f84465244a50c351b3')
build() {
cd $srcdir
# fetching
wget -Nc http://www.draisberghof.de/usb_modeswitch/usb_modeswitch.setup || return 1
# extracting
cd $srcdir/usb-modeswitch-$pkgver/
mkdir -p $pkgdir/lib/udev/usb_modeswitch || return 1
mkdir -p $pkgdir/etc || return 1
mkdir -p $pkgdir/usr/share/man/man1 || return 1
# deleting the precompiled binary
make clean || return 1
# recompiling
make || return 1
# installing
make DESTDIR=${pkgdir} install || return 1
# adjusting the tcl script location
mv ${pkgdir}/lib/udev/usb_modeswitch/usb_modeswitch.tcl ${pkgdir}/lib/udev/usb_modeswitch.tcl || return 1
rmdir ${pkgdir}/lib/udev/usb_modeswitch || return 1
mv ${pkgdir}/lib/udev/usb_modeswitch.tcl ${pkgdir}/lib/udev/usb_modeswitch || return 1
# installing data
cd $srcdir/usb-modeswitch-data-${_pkgdata} || return 1
make DESTDIR=$pkgdir install || return 1
# installing config
cp $srcdir/usb_modeswitch.setup $pkgdir/etc/ || return 1
}

Comment by: helios on Sun, 25 Apr 2010 12:35:48 +0000
thanks and updated


      First Submitted: Thu, 26 Jun 2008 17:00:39 +0000
usb_modeswitch 1.1.2-1 : Activating switchable USB devices on Linux.
( Unsupported package: Potentally dangerous ! )
==>  Edit PKGBUILD ? [Y/n] ("A" to abort)
==>   ----------------------------------------------
==>n


==> usb_modeswitch dependencies:
 - libusb (already installed)
 - tcl (package found)
 - gcc (package found)
 - make (package found)
 - wget (already installed)
==>  Continue the building of usb_modeswitch ? [Y/n]
==>   ----------------------------------------------
==>Y


==> Install or build missing dependencies for usb_modeswitch:
resolving dependencies...
looking for inter-conflicts...

Targets (7): libmpc-0.8.2-1  ppl-0.10.2-3  cloog-ppl-0.15.9-1  libelf-0.8.13-1  gcc-4.5.0-2  
             make-3.81-5  tcl-8.5.8-1  

Total Download Size:    19.83 MB
Total Installed Size:   79.74 MB

Proceed with installation? [Y/n] 
:: Retrieving packages from core...
 libmpc-0.8.2-1-i686...    68.0K   31.8K/s 00:00:02 [############################################] 100%
 ppl-0.10.2-3-i686.p...     2.4M   15.0K/s 00:02:47 [############################################] 100%
 cloog-ppl-0.15.9-1-...   119.5K   16.0K/s 00:00:07 [############################################] 100%
 libelf-0.8.13-1-i686      84.6K   23.9K/s 00:00:04 [############################################] 100%
 gcc-4.5.0-2-i686.pk...    14.7M   15.5K/s 00:16:12 [############################################] 100%
 make-3.81-5-i686.pk...   322.7K   18.5K/s 00:00:17 [############################################] 100%
:: Retrieving packages from extra...
 tcl-8.5.8-1-i686           2.1M   16.1K/s 00:02:17 [############################################] 100%
checking package integrity...
(7/7) checking for file conflicts                   [############################################] 100%
(1/7) installing libmpc                             [############################################] 100%
(2/7) installing ppl                                [############################################] 100%
(3/7) installing cloog-ppl                          [############################################] 100%
(4/7) installing libelf                             [############################################] 100%
(5/7) installing gcc                                [############################################] 100%
(6/7) installing make                               [############################################] 100%
(7/7) installing tcl                                [############################################] 100%
==> Building and installing package

==> usb_modeswitch dependencies:
 - libusb (already installed)
 - tcl (already installed)
 - gcc (already installed)
 - make (already installed)
 - wget (already installed)
==> Making package: usb_modeswitch 1.1.2-1 i686 (Wed May 26 10:06:36 WIT 2010)
==> Checking Runtime Dependencies...
==> Checking Buildtime Dependencies...
==> Retrieving Sources...
  -> Downloading usb-modeswitch-1.1.2.tar.bz2...
--2010-05-26 10:06:36--  http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-1.1.2.tar.bz2
Resolving www.draisberghof.de... 194.0.247.207
Connecting to www.draisberghof.de|194.0.247.207|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35001 (34K) [application/x-bzip]
Saving to: “usb-modeswitch-1.1.2.tar.bz2.part”

100%[=============================================================>] 35,001      25.0K/s   in 1.4s    

2010-05-26 10:06:44 (25.0 KB/s) - “usb-modeswitch-1.1.2.tar.bz2.part” saved [35001/35001]

  -> Downloading usb-modeswitch-data-20100418.tar.bz2...
--2010-05-26 10:06:44--  http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-data-20100418.tar.bz2
Resolving www.draisberghof.de... 194.0.247.207
Connecting to www.draisberghof.de|194.0.247.207|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13967 (14K) [application/x-bzip]
Saving to: “usb-modeswitch-data-20100418.tar.bz2.part”

100%[=============================================================>] 13,967      16.2K/s   in 0.8s    

2010-05-26 10:06:52 (16.2 KB/s) - “usb-modeswitch-data-20100418.tar.bz2.part” saved [13967/13967]

==> Validating source files with md5sums...
    usb-modeswitch-1.1.2.tar.bz2 ... Passed
    usb-modeswitch-data-20100418.tar.bz2 ... Passed
==> Extracting Sources...
  -> Extracting usb-modeswitch-1.1.2.tar.bz2 with bsdtar
  -> Extracting usb-modeswitch-data-20100418.tar.bz2 with bsdtar
==> Starting build()...
--2010-05-26 10:06:52--  http://www.draisberghof.de/usb_modeswitch/usb_modeswitch.setup
Resolving www.draisberghof.de... 194.0.247.207
Connecting to www.draisberghof.de|194.0.247.207|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 38634 (38K) [text/plain]
Saving to: “usb_modeswitch.setup”

100%[=============================================================>] 38,634      12.6K/s   in 3.0s    

2010-05-26 10:07:01 (12.6 KB/s) - “usb_modeswitch.setup” saved [38634/38634]

/bin/rm -f usb_modeswitch
gcc -o usb_modeswitch usb_modeswitch.c -march=i686 -mtune=generic -O2 -pipe -Wall -l usb
usb_modeswitch.c: In function ‘search_devices’:
usb_modeswitch.c:1120:8: warning: ‘listcopy’ may be used uninitialized in this function
install -d /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/usr/sbin
install --mode=755 usb_modeswitch /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/usr/sbin/usb_modeswitch
install --mode=755 usb_modeswitch.tcl /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/lib/udev/usb_modeswitch
install --mode=644 usb_modeswitch.conf /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/etc/usb_modeswitch.conf
install --mode=644 usb_modeswitch.1 /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/usr/share/man/man1/usb_modeswitch.1
install -d /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/etc/usb_modeswitch.d
install --mode=644 -t /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/etc/usb_modeswitch.d ./usb_modeswitch.d/*
install -d /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/lib/udev/rules.d
install --mode=644 40-usb_modeswitch.rules /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/lib/udev/rules.d
if [ -f /tmp/yaourt-tmp-root/aur-usb_modeswitch/usb_modeswitch/pkg/etc/issue ]; then \
                if [ -n `which udevadm 2>/dev/null` ]; then \
                        UDEVADM=`which udevadm`; \
                        UDEVADM_VER=`$UDEVADM -V 2>/dev/null`; \
                        if [ -z $UDEVADM_VER ]; then \
                                UDEVADM_VER=`$UDEVADM --version 2>/dev/null`; \
                        fi; \
                        if [ $UDEVADM_VER -gt 127 ]; then \
                                $UDEVADM control --reload-rules; \
                        else \
                                $UDEVADM control --reload_rules; \
                        fi \
                elif [ `which udevcontrol 2>/dev/null` ]; then \
                `which udevcontrol` reload_rules; \
                fi \
        fi
==> Tidying install...
  -> Purging other files...
  -> Compressing man and info pages...
  -> Stripping debugging symbols from binaries and libraries...
==> Creating package...
  -> Generating .PKGINFO file...
  -> Compressing package...
==> Finished making: usb_modeswitch 1.1.2-1 i686 (Wed May 26 10:07:03 WIT 2010)

==>  Continue installing usb_modeswitch? [Y/n]
==>  [v]iew package contents [c]heck package with namcap
==>   ----------------------------------------------
==>Y

loading package data...
checking dependencies...
(1/1) installing usb_modeswitch                     [############################################] 100%
If you like this package, please install aurvote
and vote for its inclusion/keeping in [community]

[root@chakra ~]# 

Snapshots di atas adalah yang saya ambil dari screen pada saat instalasi. Perintah yang diketikkan sebenarnya hanya satu, yaitu "yaourt -S usb_modeswitch" dan setelah itu menjawab untuk meneruskan instalasi.

Konfigurasi /etc/usb_modeswitch_setup

File ini berisi setup untuk hardware yang kita gunakan. Yang perlu dilakukan hanya menghilangkan komentar ";" di depan konfigurasi hardware yang kita gunakan. Dalam hal ini, karena menggunakan ZTE 2726, kita akan mengedit bagian tersebut menjadi sebagai berikut:

DefaultVendor=  0x19d2
DefaultProduct= 0xfff5

TargetVendor=   0x19d2
TargetProduct=  0xfff1

# only for reference and 0.x versions
# MessageEndpoint=0x05

MessageContent="5553424312345678c00000008000069f030000000000000000000000000000"

Setelah selesai, jalankan usb_modeswitch berikut ini:

[root@chakra etc]# usb_modeswitch 

Looking for target devices ...
 No devices in target mode or class found
Looking for default devices ...
 Found devices in default mode or class (1)
Accessing device 002 on bus 005 ...
Using endpoints 0x0a (out) and 0x89 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
 OK, driver found ("usb-storage")
 OK, driver "usb-storage" detached

SCSI inquiry data (for identification)
-------------------------
  Vendor String: ZTE     
   Model String: USB Storage FFF1
Revision String: 2.31
-------------------------

USB description data (for identification)
-------------------------
Manufacturer: ZTE, Incorporated
     Product: USB Storage
  Serial No.: 000000000002
-------------------------
Setting up communication with interface 0 ...
Using endpoint 0x0a for message sending ...
Trying to send message 1 to endpoint 0x0a ...
 OK, message successfully sent
-> Run lsusb to note any changes. Bye.

[root@chakra etc]# 

Setelah itu, lihat hasilnya menggunakan lsusb, jika berhasil, pada baris kedua akan berubah menjadi fff1 bukan fff5 seperti di awal tulisan ini:

[root@chakra etc]# lsusb 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 003: ID 19d2:fff1 ONDA Communication S.p.A. 
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 03f0:171d Hewlett-Packard Wireless (Bluetooth + WLAN) Interface [Integrated Module]
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 04f2:b016 Chicony Electronics Co., Ltd VGA 30fps UVC Webcam
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[root@chakra etc]# 

Untuk mengaktifkan, tinggal kita gunakan wvdial:

[root@chakra etc]# pacman-color -S wvdial
resolving dependencies...
looking for inter-conflicts...

Targets (3): xplc-0.3.13-2  wvstreams-4.6.1-2  wvdial-1.61-2  

Total Download Size:    1.25 MB
Total Installed Size:   8.27 MB

Proceed with installation? [Y/n] 
:: Retrieving packages from extra...
 xplc-0.3.13-2-i686        43.5K   25.1K/s 00:00:02 [############################################] 100%
 wvstreams-4.6.1-2-i...  1152.1K   16.4K/s 00:01:10 [############################################] 100%
 wvdial-1.61-2-i686        85.9K   32.3K/s 00:00:03 [############################################] 100%
checking package integrity...
(3/3) checking for file conflicts                   [############################################] 100%
(1/3) installing xplc                               [############################################] 100%
(2/3) installing wvstreams                          [############################################] 100%
(3/3) installing wvdial                             [############################################] 100%
[root@chakra etc]# 

Jalankan wvdialconf untuk membuat konfigurasi wvdial berikut ini:

[root@chakra ~]# wvdialconf 
Editing `/etc/wvdial.conf'.

Scanning your serial ports for a modem.

Modem Port Scan<*1>: S0   S1   S2   S3   
WvModem<*1>: Cannot get information for serial port.
ttyUSB0<*1>: ATQ0 V1 E1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB0<*1>: Modem Identifier: ATI -- Manufacturer: QUALCOMM INCORPORATED
ttyUSB0<*1>: Speed 9600: AT -- OK
ttyUSB0<*1>: Max speed is 9600; that should be safe.
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
WvModem<*1>: Cannot get information for serial port.
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB1<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB2<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB2<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB2<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB3<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB3<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB3<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
WvModem<*1>: Cannot get information for serial port.
ttyUSB4<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyUSB4<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud
ttyUSB4<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.

Found a modem on /dev/ttyUSB0.
/etc/wvdial.conf: Can't open '/etc/wvdial.conf' for reading: No such file or directory
/etc/wvdial.conf: ...starting with blank configuration.
Modem configuration written to /etc/wvdial.conf.
ttyUSB0: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
[root@chakra ~]# 

Hasilnya adalah sebagai berikut:

[root@chakra ~]# cat /etc/wvdial.conf 

[Dialer Defaults]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
; Phone = 
ISDN = 0
; Username = 
Init1 = ATZ
; Password = 
Modem = /dev/ttyUSB0
Baud = 9600
[root@chakra ~]# 

Ubah sesuai dengan konfigurasi Smart:

[root@chakra ~]# cat /etc/wvdial.conf 

[Dialer Smart]
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone = #777
ISDN = 0
Username = smart
Init1 = ATZ
Password = smart
Modem = /dev/ttyUSB0
Baud = 9600
FlowControl = CRTSCTS
Carrier Check = No
New PPPD = yes
[root@chakra ~]# 

Untuk mengaktifkan koneksi ke Internet, yang perlu dilakukan hanya memanggil wvdial berikut ini:

[root@chakra ~]# wvdial Smart
--> WvDial: Internet dialer version 1.61
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT
--> Carrier detected.  Waiting for prompt.
~[7f]}#@!}!}!} }9}"}&} } } } }#}%B#}%}%}&} }/[0f]9}'}"}(}"dq~
--> PPP negotiation detected.
--> Starting pppd at Wed May 26 10:53:55 2010
--> Pid of pppd: 6231
--> Using interface ppp0
--> pppd: H~� Pt� 
--> pppd: H~� Pt� 
--> pppd: H~� Pt� 
--> pppd: H~� Pt� 
--> pppd: H~� Pt� 
--> local  IP address 10.12.26.89
--> pppd: H~� Pt� 
--> remote IP address 10.20.4.138
--> pppd: H~� Pt� 
--> primary   DNS address 10.17.3.244
--> pppd: H~� Pt� 
--> secondary DNS address 10.17.3.252
--> pppd: H~� Pt� 

Selesai. Lain waktu, saat booting komputer dan masuk ke Linux, dari terminal aktifkan wvdial dengan perintah "wvdial Smart" sebelum mulai menggunakan.

Selamat mencoba!