Sphere: Related Content
Don’t waste your afternoon drawing UML Sequence Diagrams
November 18th, 2008 · 1 Comment · news
→ 1 CommentTags:
Five Things People Hate About Their Favorite Language
November 17th, 2008 · No Comments · programming
If they can't find five things to hate about their favorite tool, they don't know it well enough to either advoc ate it or pull in the big dollars using it.Read more on stackoverflow.... Sphere: Related Content
→ No CommentsTags:
Linux Directory to an ISO
November 14th, 2008 · No Comments · linux, linux tips
If you want to backup any of your directories in Linux file system, you can use following command. Replace LABEL and directory to suit your needs.
mkisofs -V LABEL -r directory | gzip > cdrom.iso.gz
In Ubuntu 8.04 mkisofs command is just a symbolic link to genisoimage, the fork of mkisofs. It provides a mkisofs symlink to genisoimage for compatibility purposes. Ubuntu advice users to use genisoimage instead of mkisofs.
Sphere: Related Content→ No CommentsTags:
PulseAudio Flooding LAN with Multicast Packets
November 14th, 2008 · No Comments · linux, linux tips
If you enable Multicast/RTP Sender and set the option 'send audio from local speakers' in above PulseAudio configuration window, it will flood the network with multicast packets when you play music in your computer. This problem has mentioned in this thread in ubuntuforums.org. Yesterday this has happened to me and it took 3 hours to find that PulseAudio has caused this.
Here is a another post by Justin Mason on the same problem with PulseAudio multicasting.
Sphere: Related Content→ No CommentsTags:
Getting Started with libusb on Ubuntu
November 12th, 2008 · No Comments · Uncategorized, linux
What is libusb?
libusb is a library which user level applications can used to access USB devices without worrying about the underlying operating system. Or we can see it as a high-level API which wraps low-level kernel interactions with USB modules and provide developer with the facility to implement device driver for a USB device from the user space.
libusb is easy to use and libusb API provide high level abstraction to the Kernel structures and allows the developers to have access to these structures through the USBFS(USBfilesystem).
libusb supports Linux, FreeBSD, NetBSD, OpenBSD, Darwin, MacOS X and Windows through the libusb-win32 project.
Installing libusb on Ubuntu
libusb-0.1-4 and libusb-dev packages are available in Ubuntu 8.04 repositories. You can use follwing command to install them.
sudo apt-get install libusb-dev libusb-0.1-4
Simple Example
Here is a simple example application which gather all the possible technical/hardware details of a USB devices connected to the computer. Some devices will not contain some details. This example is based on the Developing Linux Device Drivers using Libusb API article. Inline comments will describe the code.
Make sure that you have at least one USB device plugged into your computer.
#include <stdio.h>
#include <usb.h>
void print_endpoint(struct usb_endpoint_descriptor *endpoint) {
printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
printf(" bmAttributes: %02xh\n", endpoint->bmAttributes);
printf(" wMaxPacketSize: %d\n", endpoint->wMaxPacketSize);
printf(" bInterval: %d\n", endpoint->bInterval);
printf(" bRefresh: %d\n", endpoint->bRefresh);
printf(" bSynchAddress: %d\n", endpoint->bSynchAddress);
}
void print_altsetting(struct usb_interface_descriptor *interface) {
int i;
printf(" bInterfaceNumber: %d\n", interface->bInterfaceNumber);
printf(" bAlternateSetting: %d\n", interface->bAlternateSetting);
printf(" bNumEndpoints: %d\n", interface->bNumEndpoints);
printf(" bInterfaceClass: %d\n", interface->bInterfaceClass);
printf(" bInterfaceSubClass: %d\n", interface->bInterfaceSubClass);
printf(" bInterfaceProtocol: %d\n", interface->bInterfaceProtocol);
printf(" iInterface: %d\n", interface->iInterface);
for (i = 0; i < interface->bNumEndpoints; i++)
print_endpoint(&interface->endpoint[i]);
}
void print_interface(struct usb_interface *interface) {
int i;
for (i = 0; i < interface->num_altsetting; i++)
print_altsetting(&interface->altsetting[i]);
}
void print_configuration(struct usb_config_descriptor *config) {
int i;
printf(" wTotalLength: %d\n", config->wTotalLength);
printf(" bNumInterfaces: %d\n", config->bNumInterfaces);
printf(" bConfigurationValue: %d\n", config->bConfigurationValue);
printf(" iConfiguration: %d\n", config->iConfiguration);
printf(" bmAttributes: %02xh\n", config->bmAttributes);
printf(" MaxPower: %d\n", config->MaxPower);
for (i = 0; i < config->bNumInterfaces; i++)
print_interface(&config->interface[i]);
}
int main(void) {
struct usb_bus *bus;
struct usb_device *dev;
/* Initialize libusb */
usb_init();
/* Find all USB busses on system */
usb_find_busses();
/* Find all devices on all USB devices */
usb_find_devices();
printf("bus/device idVendor/idProduct\n");
/* usb_busses is a global variable. */
for (bus = usb_busses; bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
int ret, i;
char string[256];
usb_dev_handle *udev;
printf("%s/%s %04X/%04X\n", bus->dirname, dev->filename,
dev->descriptor.idVendor, dev->descriptor.idProduct);
/* Opens a USB device */
udev = usb_open(dev);
if (udev) {
if (dev->descriptor.iManufacturer) {
/* Retrieves a string descriptor from a device using the first language */
ret = usb_get_string_simple(udev, dev->descriptor.iManufacturer, string, sizeof (string));
if (ret > 0)
printf("- Manufacturer : %s\n", string);
else
printf("- Unable to fetch manufacturer string\n");
}
if (dev->descriptor.iProduct) {
ret = usb_get_string_simple(udev, dev->descriptor.iProduct, string, sizeof (string));
if (ret > 0)
printf("- Product : %s\n", string);
else
printf("- Unable to fetch product string\n");
}
if (dev->descriptor.iSerialNumber) {
ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof (string));
if (ret > 0)
printf("- Serial Number: %s\n", string);
else
printf("- Unable to fetch serial number string\n");
}
/* Closes a USB device */
usb_close(udev);
}
if (!dev->config) {
printf(" Couldn't retrieve descriptors\n");
continue;
}
for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
print_configuration(&dev->config[i]);
}
}
return 0;
}
For further details about the structures please look at the /usr/include/usb.h file.
Sphere: Related Content→ No CommentsTags:
Linux boots in 2.97 seconds
November 12th, 2008 · No Comments · linux, news
Japanese embedded Linux house Lineo has announced a quick-start technology that it claims can boot Linux in 2.97 seconds on a low-powered system. The technology appears similar to but much faster than Linux's existing "suspend-to-disk" capability.
Read more from linuxdevices.com... Sphere: Related Content→ No CommentsTags:
Linux vs. Mac vs. PC
November 11th, 2008 · No Comments · linux, personal
→ No CommentsTags:
inotify - Linux File System Activity Monitoring
November 10th, 2008 · No Comments · c programming, linux, linux tips, php, programming, python, ruby
inotify is a Linux kernel subsystem which monitors Linux file system operations, such as read, write, create and delete. It was included in the mainline kernel from release 2.6.13 (June 18, 2005). It is more efficient than busy polling from a corn job and it's an extensions to Linux file system to capture the file system changes. And it'll report these changes to applications like Desktop Search Utilities(Beagle).
You can use inotify API in your C programs to track the file system changes and 'Monitor file system activity with inotify' article from IBM Developerworks is a good starting point if you need to learn more about inotify.
inotify scripting language bindings available for popular scripting languages like Python, Perl, Ruby and PHP. Also there are bindings for Java and C++ also.
Here is the list of language bindings for inotify.
- Pyinotify
- Low level inotify wrapper using Python
- High level inotify wrapper using Python
- inotify-java
- inotify-cxx
- inotify OCaml
- Hinotify (Haskell)
- PHP inotify
- Ruby-inotify
→ No CommentsTags:
Posting from Gnome Blog Tool
November 10th, 2008 · No Comments · linux
This is my first post from a desktop blog client. I have never used a desktop client for posting before. I used Gnome Blog tool to write this post.
In debian based Linux distributions you can use
sudo apt-get install gnome-blogcommand to install this tool. Sphere: Related Content
→ No CommentsTags:
Improve Your Blog When You Don’t Have Computer Access
November 9th, 2008 · No Comments · blogging
Do you think that you need a computer with internet connection all the time to improve your blog. 'How to Improve Your Blog When You Don’t Have Computer Access' from Problogger.net describes things that can do to improve your blog when you don't have computer access.
Even the most ardent bloggers will occasionally find themselves without computer access. If you’re just lacking an internet connection, you can at least write posts – but what can you do when all you’ve got is a notebook and a pen?Sphere: Related Content
→ No CommentsTags:

