Search This Blog

Friday, November 4, 2011

TCP/IP over SLIP on GNU/Linux (Ubuntu)


As title, I need to implement TCP/IP stack on Embedded System that doesn't have Ethernet, only RS232. assume you understand what is TCP/IP over SLIP. If not, just google it.
                                                                               
The following shows how to setup your GNU/Linux PC running Ubuntu (hopefully, any version) to implement TCP/IP over SLIP, so you can test the other end. The example below will use 2 PCs running Ubuntu. Once you get it running, you can  replace one end with other device, in my case, my Embedded System.
                                                                               
Check if slip module is in your system:                                        
                                                                               
   $> find /lib/modules/$(uname -r) -name slip*                                 
                                                                               
Load slip module:                                                              
                                                                               
   $> modprobe slip                                                             
                                                                               
If you want to automatically load it during startup, edit:                    
                                                                               
   /etc/modules                                                                 
                                                                               
Now, link Serial port with TCP/IP so we can access it using IP address. The example below using Serial port /dev/ttyUSB3 running at 115200bps.

   $> sudo slattach -p slip -s 115200 / dev/ttyUSB3 &
                                                                               
Check device name, look for something like sl0, sl1.                          
                                                                               
   $> ifconfig -a                                                               
                                                                               
Assume it's sl0, assign static IP address to it. Because SLIP is point-to-point connection, you also need to tell the IP address of the other end. The example below says, my Serial port sl0 is assigned IP address of 192.169.55.1 and is connected to other end Serial port that is assigned IP address of 192.169.55.2.

$> sudo ifconfig sl0 192.169.55.1 pointopoint 192.169.55.2 up                                                                  
Repeat all of the above on the other end swapping IP addresses during ifconfig setup.
                                                                               
Try ping each other. If you are on 192.169.55.1:                              
                                                                               
   $> ping 192.169.55.2                                                         
                                                                               
If you are on 192.169.55.2:                                                    
                                                                               
   $> ping 192.169.55.1                                                         
                                                                               
If you find it too slow, try change the baudrate.                              
                                                                               
That's it. Try other program to talk to each other like web browser, telnet, ssh, etc. Once you know it's working, replace the other end with any device that supports TCP/IP over SLIP.
                                                                               
Hope you find it usefull.

Saturday, July 17, 2010

Coding Standard - Cherina Standard

Ever looking for coding standard that you can follow and available online? I've written one and will be available shortly in Launchpad as open source project.

My background in IT and Embedded Systems Engineer means having to deal with different projects using different programming languages, dealing with different programmers each which different mindset and style and don't like them because none of them using any standard.

Anyway, instead of dealing with my frustration, I would like to introduce you to a new Coding Standard named Cherina. It has been written to best fit most programming languages including scripting, clear, neat and beautiful.

Saturday, November 7, 2009

Wireless Settings in Linux - Kubuntu

If you have difficulty in setting up wireless network in Kubuntu (also in Ubuntu), you can find the following link very helpful.

The following is example of my wireless network configuration:
  1. Hidden SSID
  2. Using WPA2-PSK and AES
  3. Running DHCP Server

First, you need to find out which interface supports wireless:
$> sudo iwconfig

Second, you need to modify:
sudo vi /etc/network/interfaces

The following is example of my /etc/network/interfaces entry:
auto eth1
iface eth1 inet dhcp
wpa-driver wext
wpa-ssid "hidden_essid"
wpa-ap-scan 2
wpa-proto RSN
wpa-pairwise CCMP
wpa-group CCMP
wpa-key-mgmt WPA-PSK
wpa-psk "your_hex_key"

Where:
  • eth1 is my wireless interface
  • "you_hex_key" can be found by issuing the following command:
$> wpa_passphrase "hidden_essid" "your_ascii_key"
  • For more information click this link

NOTE: you may need to reboot for it to work.

That's it. Hope it helps to solve your problem.

Saturday, October 24, 2009

Vi: Search and Replace Command

Vi, my favourite text editor in Unices. One problem I always encountered is search and replace command. The good news is you can find the answer by searching it on the internet. Anyway, I would like to keep record of what I've done.

Search and Replace all occurences in file:
:%s/OLD/NEW/g
Between 2 lines:
:#,#s/OLD/NEW/g
First occurence on current line:
:s/OLD/NEW
All occurences on current line:
:s/OLD/NEW/g

Monday, October 12, 2009

Windows XP - Disable default C (C$) Drive Network Sharing

By default, Windows XP will share C drive (\\localhost\C$) over the network accessible by Administrators. I do not like this default behaviour so I decided to turn in off.

The following are steps to turn off default local drive shares across networks. I've only tried it on Windows XP.
  1. Type 'regedit.exe' in "command prompt" or "run"
  2. Navigate to:
    HKey_Local_Machine\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AutoShareWks
  3. If it doesn't exist, create one using DWORD key
  4. Set it to 0 (zero) to disable C$, D$ or other local drive shares over the networks
  5. Set it to 1 (one) to enable C$, D$ or other local drive shares over the networks
  6. Restart your Windows XP
  7. To confirm, in "command prompt", type 'net share'
  8. You shouldn't see C$, D$ or other local drives
  9. Done!

Friday, September 25, 2009

Can't Ping Wireless Laptop?

Yesterday I encountered problem where 2 of my Laptops can't ping each other. The laptops are running Windows XP SP2 and Vista Home Basic SP2. I did remember my laptops can ping each other before but suddenly they give error message "Destination host unreachable". NOTE: Both laptops can ping the router and surf internet with no problem.

At first I thought it was firewall issue and so I turned it off for both laptops. To no luck the problem still there. I then googled for answer and still it didn't get me anywhere, even though others also encountered it and asking for help.

Finally I tried out my own debugging of the matter. Hey, I'm also an I.T. and Engineer guy. So, I should be able to find out the problem. :) In fact I did find the problem and solution to it. It's pretty simple. Problem occured at the router side. Because wireless of both laptops are using DHCP to get its IP address, the router itself needs to keep track of which IP being assigned to which MAC. You need to check your router DHCP table of a list of IP leases. Find which entry in the DHCP table that has "unknown" IP but has MAC address as its correspondent. This is the root of the problem. An invalid entry in DHCP table.

The solution is easy, disconnect wireless connection of the laptop that has "unknown" entry in the DHCP table. Issue command "ipconfig /all" to check your MAC address. Re-connect your wireless, refresh your DHCP table in the router and ensure there is no "unknown" entry anymore in the table. That's it, your problem solved. Happy pinging!

NOTE: your firewall is not an issue. You don't have to turn it off but ensure you allow ping/ICMP as part of your firewall exceptions.

Tuesday, August 11, 2009

Firefox 3.5 on Kubuntu 9.04


I was using Firefox 3.0 this morning and decided to upgrade to Firefox 3.5. I'm running Kubuntu 9.04. I did a normal Firefox 3.5 package installation via KPackageKit. Everything were installed fine but when I launched a firefox, it still showing Firefox 3.0.

I opened up a console and excuted "which firefox" command. It shows that the firefox I was using is in "/usr/bin/firefox". After a few minutes of tinkering my Kubuntu, I found that to launch Firefox 3.5, the executable is in "/usr/bin/firefox-3.5".

I'm not sure the reason why Firefox 3.5 didn't replace Firefox 3.0 during installation. I can only guessed it has not gone into official Ubuntu supported package or something like that.

Anyway, hopefully the information can help you if you encounter the same situation with me. Cheers!

Wednesday, July 29, 2009

Trading: Interactive Broker


I woke up everyday to login into my Trading Platform from Interactive Broker to enter/exit trades. The Trading Platform provided by Interactive Broker is rich of features and information. I myself haven't figured out all the features you can find in the platform. I guess I won't be needing them at current state. If you are looking for Online Broker, you can try out Interactive Broker. It let you trades a lot of different category like shares, options, forex, futures, etc in one single account.

Sunday, July 26, 2009

Fun Time: Manga


Right, as a person, I deserves a break. I enjoy comic books, whether it's from U.S., Japan, Korea, etc. I like pictures better than words. :) One source of my manga is here or just click the banner above. I can even find manga that I read when I was still in primary school. Well anyway, do pay a visit in their website.

Wednesday, July 22, 2009

Eclipse IDE


For those who are engineers or programmers and looking for IDE for your development, look no further. Use Eclipse. It's an open platform written in Java but suitable for any programming languages. If you understand Java, you can add your own application/plug-in into Eclipse. Hence, it is still useful eventhough you are not an engineer. Give it a try.

I've been using it since a couple of years back and haven't found any replacement that can compete with it. Few main reasons I choose to use it: FREE, plenty of features via plug-in and supports multiple programming languages in one IDE.

I'm an Embedded System Engineer and found Eclipse allows me to cross-compile an application into my embedded system (ARM, PIC, FreeScale, TSTIK, Tiny) and quickly switch the development environment for PC application in the same IDE. This greatly reduce my time to develop complete system from Embedded System to High End Application without having to use several IDEs.