Most people take on new jobs, projects and hobbies for three reasons:
- To learn something new
- To pay the bills
- Because they love doing it
These three things fulfill some of our very basic needs—they give us stability, excitement, ways to contribute and opportunities to grow.
Read more.......
Sphere: Related Content
GCC and Linux are a great pair. Although they are independent pieces of software, Linux is totally dependent on GCC to enable it on new architectures. Linux further exploits features in GCC, called extensions, for greater functionality and optimization.
Read this article from IBM Developer Works to find out more...
Sphere: Related Content
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
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
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
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