Labels

2009/06/20

Find Huawei interfaces on Linux

After two years of null-activity in the area of Huawei devices I'm resuming the work. Right now I'm in a process of coding a python package, PyHumod, that will talk to Huawei (and compatible) modems. I've just jotted a detection tool for Huawei interfaces on a HAL-enabled Linux.

Run it as follows:
$ python find_huawei_iface.py
It should come up with something like that as response:
5 Huawei interfaces detected.
    E220 HSDPA Modem : /dev/ttyUSB4
    E220 HSDPA Modem : /dev/ttyUSB3
      E620 USB Modem : /dev/ttyUSB1
      E620 USB Modem : /dev/ttyUSB2
      E620 USB Modem : /dev/ttyUSB0
Tested on Huawei E220, K3520 and E270. It's meant to work with all models.
#!/usr/bin/python
# 
# Copyright (c) 2009, Slawek Ligus 
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#    * Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#    * Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in the
#      documentation and/or other materials provided with the distribution.
# 
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS
#  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
#  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
#  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
#  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
#  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 

"""find_huawei_iface.py finds active USB huawei interfaces."""

import dbus

BUS_NAME = 'org.freedesktop.Hal'
MGR_OBJ = '/org/freedesktop/Hal/Manager'
HAL_DEV_IFACE = 'org.freedesktop.Hal.Device'
HAL_MGR_IFACE = 'org.freedesktop.Hal.Manager'

bus = dbus.SystemBus()

def find_huawei_devices():
    """Find Huawei devices."""

    # Huawei vendor ID
    vendor_id = '12d1'
    hal_mgr_obj = bus.get_object(BUS_NAME, MGR_OBJ)
    hal_mgr = dbus.Interface(hal_mgr_obj, HAL_MGR_IFACE)
    all_dev = hal_mgr.FindDeviceByCapability('serial')
    devices = list()
    for device in all_dev:
        if vendor_id in device:
            devices.append(device)
    return devices

def get_hal_info(udi):
    """Return Huawei interface name and short description."""

    hal_dev = bus.get_object(BUS_NAME, udi)
    dev_property = hal_dev.GetProperty
    serial_port = dev_property('serial.device', dbus_interface=HAL_DEV_IFACE)
    info_product = dev_property('info.product', dbus_interface=HAL_DEV_IFACE)

    return info_product, serial_port

def main():
    """Find Serial interfaces for Huawei USB modems on a system."""

    devices = find_huawei_devices()
    if devices:
        l = len(devices)
        print '%s Huawei interface%s detected.' % (l, l > 1 and 's' or '')
        for dev in devices:
            print "%20s : %s" % get_hal_info(dev)
    else:
        print 'No Huawei devices found.'

if __name__ == '__main__':
    main()

2009/06/18

Cloud Computing - Another paper from Sun Microsystems

Sun has an annoying habbit of advertising white papers as "free" and then pointing you to a link with a survey, where they want you to fill out some stuff about your personal situation, current job status (including the company as a *required field) and some other similar pieces of information that you otherwise don't feel like sharing. Once you submit your factual or fictional data you'll discover that it wasn't necessary but Sun failed to inform you about it in time. Anyhow, have an interesting read without giving them your personal data:

https://www.sun.com/offers/docs/CloudComputing.pdf

2009/06/03

Listening to technical presentations.

My reception of technical presentations can vary depending on how well I'm prepared. Things I'm going to list might seem obvious at first, oh yeah you know them all, but the tricky part is to actually do it.

When going to a technical presentation...
  • Make sure you understand the jargon.
    Collect the vocabulary that is related to the subject and might pop up in the talk. Search through related mailing list archives or just lurk on one of them.
  • Have a general understanding of how stuff works.
    Familiarize yourself with the programming language, protocol or product that the presentation is about. Most importantly, look at other languages, protocols and pieces of software designed to do more/less the same thing and try to compare the differences.
  • Try to stay focused during the presentation. If you lose concentration only for a split second you might get out of sync which turns out to be a little discouraging.
  • Take bullet point notes during the presentation, expand them afterwards.
  • Always follow up with some hands-on exercise, e.g. install the software, set up the network configuration, do some coding.