Tagged: Parallel Port Toggle Comment Threads | Keyboard Shortcuts

  • Akarsh Simha 9:19 pm on June 16, 2008 Permalink
    Tags: ADSL Router, , Parallel Port, SSH   

    Switching on a lightbulb from 360km away! 

    Yes, my friend Prasanna just did the same. He SSHed into my system from Chennai and switched on the CFL in my room ๐Ÿ˜€
    Feels like the Big Bang Theory, except that it isn’t from all over the world ๐Ÿ˜€

    I opened SSH access on my ADSL router. A lot of articles on the net helped me, but let me write this out, so that it is clear and in one place. And before any brilliant bruteforcers decide to track me down, yes, I have the openSSH fix and run Debian, which means all vulnerable keys have been eliminated.

    Most routers support telnet:


    [13:akarsh@PENGUIN$ www]$ telnet
    telnet> o
    (to) 192.168.1.1
    Trying 192.168.1.1...
    Connected to 192.168.1.1.
    Escape character is '^]'.
    BCM96338 ADSL Router
    Login: admin
    Password:

    Once I login, I get this main menu on my router. Most routers have a very similar main menu if I amn’t mistaken.


    Note: If you have problem with Backspace key, please make sure you configure your terminal emulator settings. For instance, from HyperTerminal you would need to use File->Properties->Setting->Back Space key sends.

    Main Menu

    1. ADSL Link State
    2. LAN
    3. WAN
    4. DNS Server
    5. Route Setup
    6. NAT
    7. Firewall
    8. Quality Of Service
    9. Management
    10. Passwords
    11. Reset to Default
    12. Save and Reboot
    13. Exit
    ->

    If you want to setup a virtual server (which is like a proxy server running on the router that hands over all requests for a particular port on the router to a particular port on a particular system on the local subnet), choose option 6, Followed by 1.


    Note: If you have problem with Backspace key, please make sure you configure your terminal emulator settings. For instance, from HyperTerminal you would need to use File->Properties->Setting->Back Space key sends.

    Virtual Server Menu

    1. Add
    2. Remove
    3. Show
    4. Exit
    / NAT/Virtual Server ->

    You can now setup virtual servers. This is my configuration (I hit option 3 to get this). The internal IP of my system on our local subnet is 192.168.1.5. The config basically tells the router to forward all requests on port 80 (http) and port 22 (ssh) to 192.168.1.5:80 and 192.168.1.5:22 respectively on the local subnet.


    Virtual Server Show

    Server Name Proto. External Start External End Internal Start Internal End Server
    Port Port Port Port IP Address
    http TCP 80 80 80 80 192.168.1.5
    ssh TCP 22 22 22 22 192.168.1.5

    You will also have to set up the firewall to allow incoming packets on these ports. That’s option 7 (Firewall) on my router’s main menu, followed by option 1 (IP Filtering), followed by option 2 (Incoming).

    Prasanna and I also played ‘alsamixer’ on his system. It’s real fun to be able to do what we were once doing within the local intranet of the institute with a 360km gap in between!!

     
    • Prasanna 10:11 pm on June 16, 2008 Permalink | Log in to Reply

      Yay us! ๐Ÿ˜€

    • Kumar Appaiah 12:25 pm on June 17, 2008 Permalink | Log in to Reply

      Great work, guys! This is fun, and definitely useful to test out things. It’d be nice for one of you to run a stress test and find out how many HTTP requests or FTP requests your machine can handle per second. Also, it would be interesting to see if the performance improves with a scripted page with caching, ala Drupal. Game for this?

    • Akarsh Simha 1:52 am on July 1, 2008 Permalink | Log in to Reply

      I suppose we could do that Kumar. We’ll work out a time when we’re all free to do that. Why aren’t you seen on #iitm-linux nowadays?

    • wan acceleration 2:52 pm on November 12, 2008 Permalink | Log in to Reply

      I’ve found that in our network WAN accelerators have made a big difference

  • Akarsh Simha 1:48 am on March 22, 2008 Permalink
    Tags: ioctl, , , Parallel Port   

    Computer controlled tubelights! 

    A few months back, I implemented an interface using the Parallel Port to control my room’s tubelight and bulb. Such circuits that interface electrical devices to the computer through parallel port are extremely popular on the internet. My version uses one optocoupler (MCT2E), one transistor, a pair of resistors and a relay for every device I wish to control. So I’ve got some two implementations of this as of now.

    A simple C program can help control the bits on the parallel port (and thereby the devices). Again, there are examples all over the internet like this one, that help you do that. I wanted something more flexible and easy to use, so I wrote a rather long program (maybe it is an overkill). Forgive me for the unclean and dirty code. Here it is. You can kick me for writing dirty C++ – I hardly learnt any C++. (I learnt that it is dumb to use stdio.h, fprintf etc in C++ code, and that all C++ code must be encapsulated, but who cares! I wrote this for my own use, and am graciously releasing it, so take it if you must, and if you do write better and cleaner versions, please link them in the comments to this post! :-D). What this code does is to implement something that can toggle the state of a specified device.

    In this code, I read a configfile that defines the values of the bits that need to be switched on to control each of the devices. I implemented this so that it remains extensible – I’m planning to extend this to control my fan as well :-D. Once you’ve defined values in the configfile, you can then do things like:

    sudo lpdevctl bulb

    You can also specify a default device that’ll get toggled if you just say sudo lpdevctl (without an argument).

    Once you have such a program, you can do lots of interesting things. The simplest of them would be to switch on your tubelight after 10 seconds delay, say:

    sleep 10; sudo lpdevctl tubelight

    Something slightly more interesting:

    for i in `seq 1 5`; do sleep 0.5; sudo lpdevctl bulb; sleep 0.5; sudo lpdevctl bulb; done;

    That flashes the lamp 5 times. Even more interesting – switching on your tubelight every day automatically at 1830 hours is like setting up a cronjob at 1830 hours to execute sudo lpdevctl tubelight.

    I use a Jabber client called mcabber which has external action triggers, that can call an external action when something happens. So if somebody pings me on IM, I am notified of it through the flashing of my bulb (which I seldom use otherwise) instead of some ding sound that interrupts the beautiful music I’m playing. Besides, this alert is easy to switch off – because I can go and turn off the light bulb switch – and the relay is in series with that!

    Once you get a command on your Linux system to do something, the ways in which you can extend it are infinite and are only (un)bounded by your creativity!

    I like the idea of switching on my room light while sitting in my department computing facility using SSH ๐Ÿ˜€

     
    • Prasanna 10:10 pm on March 22, 2008 Permalink | Log in to Reply

      That was really a nice idea.

      @Other readers
      Try this out. Lots of fun. I tried it out too. Its very exciting ๐Ÿ˜›

    • Vajahat Ali 7:51 pm on October 5, 2009 Permalink | Log in to Reply

      Please let me know how to make that Electric Circuit, can you provide some diagram ๐Ÿ™‚

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel