Hi,
I am writing information in to packets.
Here is my part of code:
for(ii=0; ii<6; ii++)
{
sprintf(file,"/dev/rtl%d",ii)
fd = open(file,o-RDWR,0)
if(fd >=0) break;
}
if(fd < 0)
{
printf("%s:Failed to open RTL Device\n",rt);
return 0;
}
In my dev directory,there are
rtl0, rtl1, rtl2, rtl3, rtl4, rtl5
My program write device 3 (rtl3) to the packets. It goes to above loop and check if the file can open. If any file can open then it takes device number and writes to the packet.
Actually, I want device 1(rtl1) to write to packet.
I figured out why that loop writes device 3. it starts at 0 and tried to open /dev/rtl0 but couldn't open then /dev/rtl1 then /dev/rtl2 and then /dev/rtl3
/dev/rtl0, /dev/rtl1, and /dev/rtl2 couldn't open.
so I went to /dev directory
and check more rtl0
it gives me error message:
rtl0: Mount device busy
same thing for rtl1 and rtl2.
But when I do more rtl3, It doesn't give me any message.
How can I solve the problem :
rtl1: Mount device busy
I want device 1 to write the packet.
So I can remove the for loop, and write down like:
sprintf(file,"/dev/rtl%d",1)
fd = open(file,o-RDWR,0)
if(fd >=0) break;
if(fd < 0)
{
printf("%s:Failed to open RTL Device\n",rt);
return 0;
}
Since I am geting message
rtl0: Mount device busy, it can't open the file.
So How can I solve my problem?
Any help will be appreciated.
Thanks.