lkml.org 
[lkml]   [1999]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Device deadlock.
"Richard B. Johnson" wrote:

> On Tue, 24 Aug 1999, Peter Enderborg wrote:
>
> > I have a program that sends midi events to the /dev/midi0 device.
> >
> > It open the device with open() for read/write. Sometimes it sends a lot of events
> >
> > and the device stops send. (Nonblocking) Then the device is dead. I stop the process and
> >
> > trying open the device and it is stil busy. The hardware is SB16 or SB128 PCI.
> >
> > Im thinking of sending some IOCTL to give it a reset signal, but I cant send IOCTL
> >
> > the device is busy. Ugly deadlock...
> >
> include <fcntl.h>
>
> fd = open("/dev/midi0", O_RWDR|O_NONBLOCK);
>
> Doesn't this work?
>
> Cheers,
> Dick Johnson
> **** FILE SYSTEM WAS MODIFIED ****
> Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
> Warning : It's hard to remain at the trailing edge of technology.

You can try play with this:

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>

int main()
{
int fd1;
int result;

fd1 = open("/dev/midi00",O_RDWR|O_NONBLOCK);
if (fd1 == -1)
{
printf("Error open %s [%d]\n",strerror(errno),errno);
exit(1);
}
printf("Device ready. Lock it!\n");
do
{
result = write(fd1,"ABC",3);
}
while (result == 3);
printf("Result:%d\n",result);
result = write(fd1,"ABC",3);
if (result == -1)
{
printf("Error open %s [%d]\n",strerror(errno),errno);
}
return 0;
}


--
foo!


begin:vcard
n:Enderborg;Peter
x-mozilla-html:FALSE
org:;
adr:;;;;;;
version:2.1
email;internet:pme@ufh.se
x-mozilla-cpt:;0
fn:Peter Enderborg
end:vcard
[unhandled content-type:application/x-pkcs7-signature]
\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.089 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site