Hi Edward,
It has just occured to me that the value system returns is the status of the
call, not the actual count output of grep, which is written to the terminal. So
to be able to access that value should I be able to scanf the output or
something?
Thanks,
Tim
Edward wrote:
> Hello Tim,
>
> Sure, you could for example issue the following from your C-program to look
> for your device DeviceName:
>
> #include <stdlib.h>
> ...
> x = system("grep -c \'^S:.*DeviceName\' /proc/bus/usb/devices");
>
> and check if x >= 1.
>
> I don't know if there are any other methods, there might be, and most likely
> there are. No doubt the /proc/bus/usb/devices is created by one.
>
> Best regards,
> Edward
>
> ----- Original Message -----
> From: "Tim Arney" <[EMAIL PROTECTED]>
> To: "Edward" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, November 18, 2004 14:57
> Subject: Re: [Linux-usb-users] Detecting unplugged device
>
> > Hi Edward,
> >
> > Thanks for your quick reply. So can I execute grep from within a C
> program? Is
> > there no way you know of using the usb library directly?
> >
> > Cheers,
> > Tim
> >
> > Quoting Edward <[EMAIL PROTECTED]>:
> >
> > > Hello Tim,
> > >
> > > My best bet would be to grep the /proc/bus/usb/devices file for your
> > > joystick device.
> > >
> > > HTH
> > > Edward
> > >
> > > ----- Original Message -----
> > > From: "Tim Arney" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Thursday, November 18, 2004 13:51
> > > Subject: [Linux-usb-users] Detecting unplugged device
> > >
> > >
> > > > Hi all,
> > > >
> > > > I've written a C/C++ program for controlling a robot with a USB
> joystick
> > > > under linux. For this I'm using the joydev module. Some of our
> robots
> > > > are quite large and fast, and a safety concern is with the joystick
> > > > being unplugged, then the robot should stop. As it stands, when the
> > > > joystick is disconnected the "read" call blocks as though there is no
> > > > new data. I could open the joystick port as non-blocking, but then
> > > > "read" just returns like there's no new data. What I really need to
> be
> > > > able to do is determine whether the joystick is still attached, and I
> > > > figure somewhere along the chain (kernel->usb->input->joystick)
> someone
> > > > knows whether it's there, and my best guess would be the linux usb
> > > > driver. So anyway, I'm essentially looking for a point in the right
> > > > direction as to how I might test to see if the joystick is connected
> > > > from my C/C++ program?
> > > >
> > > > If it helps I'm using Debian Sarge with Linux kernel 2.4.26 on an i686
> > > > system.
> > > >
> > > > Thanks a lot,
> > > > Tim
> > > >
> > > >
> > > > --
> > > > UTS CRICOS Provider Code: 00099F
> > > > DISCLAIMER: This email message and any accompanying attachments may
> > > contain
> > > > confidential information. If you are not the intended recipient, do
> not
> > > > read, use, disseminate, distribute or copy this message or
> attachments.
> > > If
> > > > you have received this message in error, please notify the sender
> > > > immediately and delete this message. Any views expressed in this
> message
> > > > are those of the individual sender, except where the sender expressly,
> and
> > > > with authority, states them to be the views the University of
> Technology,
> > > > Sydney. Before opening any attachments, please check them for viruses
> and
> > > > defects.
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > This SF.Net email is sponsored by: InterSystems CACHE
> > > > FREE OODBMS DOWNLOAD - A multidimensional database that combines
> > > > robust object and relational technologies, making it a perfect match
> > > > for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
> > > > _______________________________________________
> > > > [EMAIL PROTECTED]
> > > > To unsubscribe, use the last form field at:
> > > > https://lists.sourceforge.net/lists/listinfo/linux-usb-users
> > > >
> > >
> >
> >
> >
> > --
> > UTS CRICOS Provider Code: 00099F
> > DISCLAIMER: This email message and any accompanying attachments may
> contain
> > confidential information. If you are not the intended recipient, do not
> > read, use, disseminate, distribute or copy this message or attachments.
> If
> > you have received this message in error, please notify the sender
> > immediately and delete this message. Any views expressed in this message
> > are those of the individual sender, except where the sender expressly, and
> > with authority, states them to be the views the University of Technology,
> > Sydney. Before opening any attachments, please check them for viruses and
> > defects.
> >
--
UTS CRICOS Provider Code: 00099F
DISCLAIMER: This email message and any accompanying attachments may contain
confidential information. If you are not the intended recipient, do not
read, use, disseminate, distribute or copy this message or attachments. If
you have received this message in error, please notify the sender
immediately and delete this message. Any views expressed in this message
are those of the individual sender, except where the sender expressly, and
with authority, states them to be the views the University of Technology,
Sydney. Before opening any attachments, please check them for viruses and
defects.
-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users