« Home | Diagnosing "Serious Errors" with Windows Memory Di... » | SQL Replication and Renamed Imaged Servers » | IE7: Flickr tag search in the Search bar » | Embedding a Google Map » | New Application/User Settings Interface in VS2005 » | Using HttpListener Asynchronously » | Using HttpListener For X10 Web Interface » | Might We Suggest the Enemy? » | Rebooting the Cable Modem Programmatically Using X... » | VB.NET CM17A X10 Library From Scratch » 

Thursday, November 24, 2005 

Rebooting the Cable Modem Programmatically Using X10

I mentioned that I used my .NET X10 library to reboot my cable modem every week or so when it appears to have locked up, and now here's the simple code. I created a new VB.NET app, put this code in the Load method of a basic form with a single label object, and created a shortcut to it on the desktop for all users. Now everyone can reboot the cable modem directly from the workstation without going down to the interface room or knowing how to pull the correct plug. Plus, this code knows how long to wait before the connection should be back up, and even does a simple web request to test the connection after the reboot.
        Dim FC As New X10.CM17A(1)

        Label1.Text = "Sending Off Command ..."
        Me.Show()
        Me.Refresh()

        FC.SendCommand(X10.CM17A.HouseA, 1, X10.CM17A.CommandOff)
        Label1.Text = "Sent Off Command, Waiting 3 Seconds ..."
        Me.Refresh()
        System.Threading.Thread.Sleep(3000)
        Label1.Text = "Sending On Command ..."
        Me.Refresh()
        FC.SendCommand(X10.CM17A.HouseA, 1, X10.CM17A.CommandOn)
        Label1.Text = "Sent On Command, Waiting 30 Seconds ..."
        Me.Refresh()
        System.Threading.Thread.Sleep(30000)
        Label1.Text = "Testing Connection ..."
        Me.Refresh()

        Dim objHTTP As New System.Net.WebClient
        Dim objIn As IO.Stream

        Try
            objIn = objHTTP.OpenRead("http://www.microsoft.com")
            Label1.Text = "Success! Exiting ..."
        Catch ex As Exception
            MsgBox("Error Testing Connection! Click OK and Try Again.")
        End Try

        Me.Refresh()
        System.Threading.Thread.Sleep(3000)
        Me.Close()

I am having a similar problem with my cable modem. Today I manually bounced it and within 3 hours it was already down. I read your post with some interest and I had a couple of questions for you.

1) What is the make/model of the device your cable modem is physically plugged into? All I really want to be able to do is to turn the modem on and off, so I'm not sure what I need.

2) The X10 .NET library you used ... where did you get that? Was it something you purchased? Or were you able to download it for free off of an Internet site?

3) Is your computer connected to this device over the serial cable?

Thanks again for any help you can provide.

Post a Comment
    Add to Google

    This page is powered by Blogger.



Photostream

    www.flickr.com
    justinhenry's photos More of justinhenry's photos