Showing posts with label Projects. Show all posts
Showing posts with label Projects. Show all posts

Monday, October 01, 2012

Leaving DB

Back to October 2008, when I was in Bandung, I got a call from a HR manager in Jakarta asked me for a job interview. Then 1 week after it, I go to Jakarta to meet the HR manager, after a long negotiation and spending some weeks in the city I'm officially hired by the company.

I started my days to build their network infrastructure and next advance to system programmer. I design Linux device and application for one of their most important device. From this experience I proofed how good Linux for the industry, tons of features, highly customizable and undoubtedly reliable. I proofed how good the collaboration of the Debian project, proofed the GTK+ interface and usability, proofed how good POSIX thread was implemented and more. I have learned many things from serial port devices to card and reader interfaces.

For some personal decisions (human natures such as dislike and disagree) I decided to leave the company and advance to the next level of complexity. I have worked with peoples who has great determination and spirit, got so many friends there. This is my 4th years relation with the company, thanks for giving me such a great experience, wish the best success for you. And I hate to say Goodbye!.

Friday, August 19, 2011

Custom PowerDNS Backend

So here I go, I was busy to develop PowerDNS custom pipe backend, why I develop this because it need:

Filtering: If you familiar with internet filtering service such as OpenDNS or a local service Nawala, they can block domain names based on defined criteria. With custom backend all DNS client's queries are send to the backend, give the backend flexable way to manage them. Filtering or blocking was done by bypassing DNS A (IPv4) or AAAA (IPv6) plus additional SOA record to the client.

Logging: All DNS queries need to be logged for statistics, to generate complex statistics data, log storage should be in structural format such as database.

So I called this backend with cpdns, stand for Custom PowerDNS Backend, cpdns need these following programs.

  • Redis: advanced memory database server, its has key-value concept to store data, perfect for distributed object caching.

  • TCMalloc: fast and efficient memory allocator used by Redis.

  • libunwind: C API used by TCMalloc.

  • hiredis: Redis C client.

  • libldns: C DNS library used by backend's resolver.

  • MySQL: Famous RDBMS database to store domain filtering data and logs.


Short description about how the backend works, I'll divide backend's components based on their responsibility.

Query Parsing: PowerDNS

Pars

Thursday, April 28, 2011

Asterisk Notes

Simple call file contents

Channel: Local@s/default
Callerid: 911
Extension: 12345


Then move the file to /var/spool/asterisk/outgoing (not by copying it) to make a call to default channel.

Creating an extension

[default]
exten => 12345,1,Answer()
exten => 12345,n,Wait(0.5)
exten => 12345,n,AGI(demo)
exten => 12345,n,Hangup()


This will create extension number 12345 at default channel, when dialled it will excecute an AGI file.

Connect to a SIP account

Edit /etc/asterisk/sip.conf and enter the registration information. For this example, I will add SIP server 192.168.1.100 with extension 12345 to be dialled when the extension is called, remember that 12345 must be already defined.

register => username:password@192.168.1.100/12345

SIP server

First create the SIP account, in this example account will use user extension context.

[sip_user]
type=peer
username=sip_user
secret=1234
host=dynamic
context=user


then register it.

register => sip_user:1234@192.168.24.203

Thursday, April 14, 2011

IVR

Today I start to develop IVR (Interactive Voice Response) application, it's interesting and new hacking environment for me. I hope this will be more exciting hack. I noticed about Asterisk, a open source (GPL) telephony communication implementation.

Sunday, February 13, 2011

Sunday Coding

It has been so long since my last post in this blog, many things happen and I can't post all of them. So welcome to my blog again, and here I am, in DB, working with GTO's SOP and standby routines.

Thursday, November 25, 2010

WAFER-LX800 as TCT board

Today I managed to configure IEI WAFER LX-800 board, the most important thing that the board has AMD Geode LX800 500MHz processor and 8 RS-232 port, it will also has to support PM-1028 multi-port PC-104 card.

The board has a configurable IO address at it's BIOS that need to be adjusted in order to make the PM-1028 work, so here the configuration.

WAFER LX2-800 IT8888 ISA Decode IO
----------------------------------

Decode I/O Space 1          [Enabled]
Decode I/O Speed 1          [Slow Speed]
Decode I/O Addr. 1 [15:0]   [0200]
Decode I/O Size 1           [ 64 Bytes]


The 64 bytes size means that address range that PM-1028 used, the PCM-1028 multi-port module has 200H - 238H address range by default so 64 bytes will more than enough and it is the only option after 32 bytes size.

I also configure the PM-1028 multi-port to share one IRQ by using IRQ 5.

The Debian Lenny doesn't provide GEODE Xorg chipset driver by dafault. The package was named xserver-xorg-video-geode, without it the X server will fail to run no matter how the X configuration file is configured.

Monday, November 22, 2010

Bit Packing

Last night I was busy hacking toll ticket, the application will be installed on a device that will be used for reading ticket when the power goes down. The problem is I must not using our ticket format for it, yeah in the name of vandalism. This word is very famous here. So we choose open Mifare Classic 1K card for that, open means with the standard transport key configuration.

The card need to hold some informations, the most important thing are shift (SH) and period (PR), vehicle classification (VC), plaza where the vehicle in (PI), post (PS), vehicle's direction (DR). We defined that maximum value for each information below all in integer type.

SH -> 0 - 3, 11 (2 bit), 11 or 0x3 as bitmask
PR -> 0 - 99, 1100011 (7 bit), 1111111 or 0x7f as bitmask
VC -> 0 - 5, 101 (3 bit), 111 or 0x7 as bitmask
PI -> 0 - 99, 1100011 (7 bit), 1111111 or 0x7f as bitmask
PS -> 0 - 99, 1100011 (7 bit), 1111111 or 0x7f as bitmask
DR -> 0 - 3, 11 (2 bit), 11 or 0x3 as bitmask


We have 28 bit, to construct them as integer we use the following as we already know

(SH & 0x3) << 26 | (PR & 0x7f) << 19 | (VC & 0x7) << 16 | (PI & 0x7f) << 9 | (PS & 0x7f) << 2 | (DR & 0x3)

For extracting those integers we use

SH = value >> 26 & 0x3
PR = value >> 19 & 0x7f
VC = value >> 16 & 0x3
PI = value >> 9 & 0x7f
PS = value >> 2 & 0x7f
DR = value & 0x3


This is only a simple bit operation that sometime we forgot how they are works, so here the source code, it need ACR120 communication library to be compiled.

Sunday, November 14, 2010

Saturday Hacking

There are some significant progress with gBilling this week, I already released two development version of 0.2.1 and try to regain control at the forum. Let community know that this project is back in business and ready to rock. Tonight Me and Muchtar are in office, buy some Martabak and of course a hack party.

Tuesday, November 09, 2010

Repairing TCT CF disk

The TCT uses Compact Flash (CF) as it's storage device, the CF technology is cheap now. Depends on CF quality, CF operate in variety of speed, some well known manufacturer produce high-speed transfer rate CF. TCT uses Sandisk Ultra CF which expected to work at 15MB/s theoretically.

Like another flash-based memory that use NAND, beside it has write cycle endurance it also being sensitive with electro static and improper handle. Many TCT's CF were suffer from this, fortunately, this problem didn't affect all memory part of the CF, usually errors only located on several block segment.

First for all notice that in this writing, the CF has master disk with device's name /dev/sdc, to diagnose the bad block, we need to scan the broken CF then it should show up some warnings, maybe something like these

#e2fsck /dev/sdc1
...
Buffer I/O error on device sdc, logical block 1082045
end_request: I/O error, dev sdc, sector 1082045
Buffer I/O error on device sdc, logical block 1082050
end_request: I/O error, dev sdc, sector 1082050
...


Now we know the damaged block, with fdisk we can create a partition with this trick.

Let assume the CF has 1964088 logical block, we noticed in above e2fsck log that blocks upto 1082044 were unusable, we can safely create a partition which has about 1082044 logical block by set the last logical block equal or less than 1082044.

#fdisk /dev/sdc

Command (m for help): u
Changing display/entry units to sectors
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (62-15761087, default 62):
Using default value 62
Last sector, +sectors or +size{K,M,G} (62-1964088, default 1964088): 1082044
The partition table has been altered!


After the new partition has been created, first make sure the partition boot flag also already been activated with fdisk, then create the root filesystem of type ext3 with

#mke2fs -j /dev/sdc1

We need to extracting tar.gzip'ed TCT root filesystem to the partition with

#mount -t ext3 /dev/sdc1 /mnt
#tar xzf tct-rootfs.tar.gz -C /mnt


The tar.gzip'ed root filesystem created by compressing a previously working filesystem, assuming that the current working directory is the root directory of working filesystem.

#tar czf /path/to/save/tct-rootfs.gz .

Now we have a working root filesystem, but one feature that is still missing is bootloader, using GRUB is very complicated, why not use a small and simple bootloader EXTLINUX, from this time the TCT system should use EXTLINUX instead GRUB.

#extlinux --install /mnt/boot
#cat /usr/lib/syslinux/mbr.bin > /dev/sdc


Create a simple configuration file, similar to syslinux configuration file. Use blkid to retrieve device UUID.

# /boot/extlinux.conf
LABEL Lenny
KERNEL /vmlinuz
APPEND initrd=/initrd.img root=UUID=06e8bee6-ad09-41e8-8290-87ef6aa71df8 ro quiet vga=0x314 8250.nr_uarts=12
TIMEOUT 20
PROMPT 0


Unmount and test for it, hopefully it should works!

When working with this problem, I made stupid thing by rm -rf /media, this fuck my important data.

Saturday, November 06, 2010

GTO Test

After so much modification now it is time to see how the GTO should work, the testing taken place at South Sentul plaza and participated by Jasa Marga and some people from University of Indonesia computer science centre.

The GTO tested first with self-testing procedures by using our cars, work fine as expected. Then it tested directly to the toll user, directly means the user come to the GTO and simulated like the user take the ticket by giving the real ticket as soon as produced card from GTO are taken by our man who stand in front of the GTO. The testing is smooth except for an CSD error that caused by mechanical problem. That's a good improvement.

Tonight, Me and Muchtar are occupied this place.

Friday, October 29, 2010

Another GTO modification

Another GTO modification discussed today (again), that sucks because the GTO things such as distance between sensor is not properly calculated or in another word is inconsistent. Therefore, the software need to be adjusted to handle the stupid design.

Wednesday, October 27, 2010

GTO Modification

Today I was so busy with the TCT for GTO transaction. The software need to modified in such way so it could produce a ticket without fail, the production is triggered by a sensor called LND, in the previous version when the CSD (Contactless Smartcard Dispenser) is currently busy the TCT could not manage to produce since the CSD was busy therefore it can't complete TCT request. The modification is about to save the LND count first and produce it as soon as the CSD becomes ready. Yes it's the correct trick.

Meanwhile I have receive a appointment letter from my company, describe my position and new salary.

Sunday, October 24, 2010

Saturday night with E-Toll

Tonight I resumed Mandiri E-Toll reader communication module to be used by the TCT, the documentations shared with us deliberately, so it's impossible to know such error or response code, the program only know an operational error, but not the reason 'why?'. In my opinion, this device (E-Toll card reader) created without full understanding about how the TCT works and how it will be used in Toll transactions. One of the biggest mistake is the device provide timeout mechanism that should handled by TCT.

Thursday, October 21, 2010

New Hosting

So here I am in the new domain and hosting, to run my modest blog, will transfer posts from my old blog manually later, this domain ordered and activated pretty fast, thanks for hosting corporation. Beside blog, I can store and manage my pieces of code here rather than the paste-like-bin sites. What do you think with the domain's name? too difficult? indeed, this is just for my personal information.

Thursday, September 02, 2010

Improving the TCT Tool

This previous post describes how TCT Tool was written, It is using POSIX Message Queue to exchange data. Basic on work, TCT Tool's message queue implementation almost work, only the main problem is the sender could read it's sent data, this sound weird because the TCT Tool would read it's data that intended to be read by the TCT. On the Toll, this problem hung up the TCT.

I change the IPC implementation using UNIX Domain Socket, first with datagram socket, the problem was just like the message queue, the TCT Tool receive it's sent data. The TCT Tool was not work until I use reliable stream socket, here the source code.

Sunday, August 29, 2010

Rock on Saturday

From yesterday I just stayed in my room, playing with my old friend: Thinkpad T30. I registered M2 Broadband and did some fun in the net, I admit that the broadband service is sucks, better than nothing, isn't it?. I was working on gBilling did many improvements and pushing the source code to SourceForge Git repository, from now gBilling development should use the repo, I will announce it later in pre-release. I also create a Python script to be used to simulate GTO and KSPT Terminal communication.

At Sunday afternoon, I played my PRS guitar, learn a lesson from John Petrucci's Rock Discipline video as Guitar Pro format. Had fried rice after fasting at Super Grosir store. But sorry, I'll pay it later.

Saturday, July 10, 2010

TCT's cycle time algorithm

This is a code that describes TCT cycle algorithm, the first method is by using a thread, i don't know why i should use the unimportant thread in the past. However, this is the newest and improved code.

http://pastebin.com/raw.php?i=ZgLh7k7A

PS. I wrote these without the fucking smokes, what a progress.

Friday, July 02, 2010

TCT Launch at Cibubur

Last night we were in Cibubur Ramp to install our new toll equipments, new TCT was installed in all post (there are 8 posts at Cibubur Ramp). We began the switching process at 3rd shift one by one. Before operating for the real transactions, each TCT is examined by some JM official. So far so good except for the post officer's scheduling, this happen when entering new day at 00.00 AM. Something that never predicted or examined before.

Some improvements made, but the changes is not heavily tested and another problem come. I already made some fix and improvements with TCT regarding these issues, such as the cycle time source (TCT capability to decide if new cycle has been passed or not), transaction's data ID, etc.

Monday, June 21, 2010

First TCT Launch

New TCT are now operating in Bogor Ring Road Toll today, it's already used for real transaction. So far so good, made me a litle proud and confident. At least, my work was used in a real Toll system. The TCT system is based on Debian 5.04 (Lenny) on a 1 Ghz Intel Celeron single-board computer. Recall my worst day at Kalijati - Antapani when learning C and Linux, i miss that days! Rock with Alter Bridge's songs ;p.

Wednesday, June 16, 2010

TCT Tool

TCT Tool is a application that do some privileged tasks in the TCT machine. By default, TCT run in non-privileged mode so it can't do for example sending ioctl to the ethernet driver, update the system time, and many more. They use POSIX message queue for communication. Thanks for Glynn Clements at linux-c-programming who helped me out with message queue descriptor permission.

http://pastebin.com/raw.php?i=x4X6G4uf