ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Ok. I need help bad. I am trying to make a program that will receive data through a USB port, and then retransmit it accross TCP/IP, so a client can talk with the device over TCP/IP.
I don't know anything about USB. So how do I talk to a USB device (say I want to get raw input from a keyboard... I know, I can do this simpler ways, but this is just an example, and the only USB device I have at the moment in which I can talk with) in an OS independant way. If there aren't any good libraries for USB that are OSI, I'll just write my code so it is OSI by using native Windows and Linux and Mac drivers.
I must do this. I must do it relitivly soon. I don't know even where to start. Please help me!!!
Sorry, when I re-read your post, I realize I misunderstood what you wanted. If you are talking about a device such as the keyboard or the mouse, then you can do that using x-windows. For example, using the secure shell, you can forward x-windows events.
Also, remember the Unix design philosophy that everything is a file. So you can redirect the output of an audio device for example to a socket. However whatever you do should be going through the secure shell, or one or the other computer will be wide open.
int main(int argc, char **argv)
struct usb_bus *bus;
int c, i, a, c1, i1;
struct usb_bus *busses;
busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next)
struct usb_device *dev;
for (dev = bus->devices; dev; dev = dev->next)
/* Loop through all of the configurations */
for (c = 0; c < dev->descriptor.bNumConfigurations; c++)
/* Loop through all of the interfaces */
for (i = 0; i < dev->config[c].bNumInterfaces; i++)
/* Loop through all of the alternate settings */
for (a = 0; a < dev->config[c].interface[i].num_altsetting; a++)
if (dev->config[c].interface[i].altsetting[a].bInterfaceClass >= 0)
printf("Device class = %d\n", dev->config[c].interface[i].altsetting[a].bInterfaceClass);
if (dev->descriptor.bDeviceClass >= 0)
usb_dev_handle *Handle = usb_open(dev);
printf("Handle opened for device!\n");
c1 = usb_bulk_read(Handle, USB_ENDPOINT_TYPE_BULK, Bytes, 256, 32000);
printf("Failed device read\n");
else printf("Claiming interface failed!\n");
printf("Unable to open handle to device!\n");
When run, it goes through all the devices connected to the USB ports, and tries to open and read data from them. I know the code is messy, and rather, bad... but I am just trying to do some tests so I can better understand how to do USB programming. It fails at printf("Claiming interface failed!\n"); and quits. I tried skipping this step and just reading from the device. But this fails as well. What must I do to read, say, input from a keyboard?