The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX Desktop for Dummies Questions & Answers
.
google unix.com



UNIX Desktop for Dummies Questions & Answers Discuss UNIX and Linux user interfaces like GNOME, KDE, CDE, and Open Office here. All UNIX and Linux Newbies Welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
/dev/ttyS2 device or resource busy blianna UNIX and Linux Applications 1 08-21-2009 05:50 AM
cygwin /dev/ttyS2: Device or resource busy blianna UNIX Desktop for Dummies Questions & Answers 0 08-21-2009 05:35 AM
Device or resource busy?? orahi001 UNIX for Dummies Questions & Answers 2 04-07-2009 08:22 AM
rmdev - device is busy Livio AIX 2 05-17-2006 03:58 AM
umount, device busy, but.. sTorm UNIX for Dummies Questions & Answers 10 08-20-2002 06:49 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-21-2009
blianna blianna is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 12
cygwin error device or resource busy

Hello!!!
My problem is: i'm trying to send At commands from Pc to mobile phone using bluetooth and cygwin and i would like to read the device's answers on the shell bash. And so, i open two terminals in this way:

xterm &

In the first i write:

cat /dev/ttyS2

because the device is connected at com3.
In the second one i write the instruction with the AT commands:

echo "AT">/dev/ttyS2

However i'm facing with this error:

/dev/ttyS2: Device or resource busy

Is there anyone that can help me??HELPPPPPP
SORRY FOR MY BAD ENGLISH!!!!!!!!!
  #2 (permalink)  
Old 09-15-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
Remember, Cygwin is still subject to silly Windows limitations like two programs not being able to open one port. bash can't open a file for reading and writing simultaneously, so bash can't do it by itself. I'm trying to think of a common shell utility to do this or some way to trick bash into it but so far I'm coming up empty... There's things like minicom, but I'm guessing you want to automate something.

You could use putty if just typing in raw commands is what you want. It's what I use for raw serial port communication in UNIX, and there's a native Windows version with precisely the same functionality.

Or... It's entirely possible your phone doesn't have the control signals to tell it when the connection's broken, so that closing the device file doesn't lose anything. You might be able to
Code:
echo "AT" > /dev/ttyS0
cat /dev/ttyS0
if you set it up with stty correctly first. There's a setting in stty somewhere to define the amount of time to wait before closing the connection. Set it to zero(or just something small) and it gives you only what's in the buffer, which lets you just keep reopening and reclosing it whenever you want to read or write. I've used this feature in actual UNIX, but I don't know if Windows will do this properly -- it might just discard everything while the file's closed.

---------- Post updated at 02:41 PM ---------- Previous update was at 02:11 PM ----------

I finally figured it out, maybe. Try this:

Code:
# Open ttyS2 for reading and writing as FD 5
exec 5<>/dev/ttyS2
# Leave this running in the background
cat <&5 &
# Write a command to FD 5
echo "AT" >&5
Windows may still complain. I'm not sure.

Last edited by Corona688; 09-15-2009 at 04:19 PM..
  #3 (permalink)  
Old 09-17-2009
blianna blianna is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 12
Using puTTy it works but my aim was to automate the process.
So I try:

# Open ttyS2 for reading and writing as FD 5
exec 5<>/dev/ttyS2
# Leave this running in the background
cat <&5 &
# Write a command to FD 5
echo "AT" >&5

and I think that it's a good idea!! But now, there is another problem: when I try to send an SMS through At commands I have to communicate the control character [ctrl+z] ^Z to serial port...and I have some troubles to do this.

echo "\032">&5
echo "^Z" >&5

They don't work probably because I had to set up some features with stty but when I try:

stty -F /dev/ttyS2 isig

I face with this error:
stty: /dev/ttyS3: unable to perform all requested operations

Any idea to send control char??
Thank you!!!
  #4 (permalink)  
Old 09-17-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
echo doesn't try to translate anything unless you tell it to. You can send arbitrary ASCII characters with echo like

Code:
# ctrl-Z
echo -en "\x1a" >&5
The -e part tells it to convert \x codes into ASCII characters. -n tells it not to apppend a newline.

I also have a suspicion this fd-opening thing is only working because 'echo' is a bash builtin so doesn't need to launch a new process. Try to avoid pipes and such to avoid unexpected problems writing to the serial device..

---------- Post updated at 02:06 PM ---------- Previous update was at 01:59 PM ----------

Code:
stty: /dev/ttyS3: unable to perform all requested operations
Did you make a typo? That's not the device you were using before.
  #5 (permalink)  
Old 09-18-2009
blianna blianna is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 12
Yes I have made a mistake...the error was:

stty: /dev/ttyS2: unable to perform all requested operations

I have a doubt: ^Z in ASCII code is \032 so I have to write echo -en "\0321a">&5 or echo -en "\032">&5?

Thank you so much for your advices!!!
  #6 (permalink)  
Old 09-18-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
...or you could do what I suggested, \x1a. That defines it in hex. For octal, \032 will do it.
  #7 (permalink)  
Old 09-18-2009
blianna blianna is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 12
Thank you...I still have some problems.. i try this code:

#!/usr/bin/env bash
stty -F /dev/ttyS2 speed 9600
sleep 3
echo "AT">/dev/ttyS2
sleep 3
echo "AT+CMGF=1">/dev/ttyS2
sleep 3
echo "AT+CMGS=\"333xxxxxxx\"">/dev/ttyS2
sleep 3
echo -n "ciao">/dev/ttyS2
sleep 3
echo -en "\1A">/dev/ttyS2

on my pc it doesn't work...if you have some idea I'm very glad to read it..thanks for your help!!!!
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0