"Device busy" When Reopening Serial Port


 
Thread Tools Search this Thread
Operating Systems Solaris "Device busy" When Reopening Serial Port
# 8  
Old 12-11-2011
Thank you. Will the lock file appear in the same directory as the port?

---------- Post updated at 08:26 PM ---------- Previous update was at 08:21 PM ----------

The machine has two RS 45 jacks used as serial ports. I plug in RS-45-to-serial (9-pin serial) adapter cables. These are indeed the names of the ports. I will find out the card and driver. I'm using the Java Communications library ("Java Comm") as an interface between my Java code and the ports.

I appreciate the help, all.

---------- Post updated at 09:00 PM ---------- Previous update was at 08:26 PM ----------

Instead of downloading lsof, I used fuser.

When the app is running, the command fuser /dev/cua/comf1a yeilds the result:

/dev/cua/comf1a: 18011o

...or a similar string. The name of a thread or a process? When I run the command for /dev/cua/comf1b, I get the same string. So, the same process is associated with both ports. When the app closes one of the ports and continues to run I get the same results. So, closing the port does not stop the port from being associated with this process, if that's what the fuser result means.

When I shut down the app, I get the following result with the command:

/dev/cua/comf1a:

i.e., nothing at all. So, if I'm interpreting fuser correctly, the results are unfortunately that the device is marked busy when the app is running and has opened the device, such that even the app itself cannot open it again.

I do not see any lock file appear in /dev/cua when the app connects to the ports.

I only see one reference to /dev/cua/comf1a (or b) other than mine on the Web: a pdf document on the perle.com site. Perhaps I have an inferior port driver/card? To disallow the very process that is using a device from reopening the device seems unreasonable. Or is there some reconfiguration I can do in Solaris?

---------- Post updated at 09:12 PM ---------- Previous update was at 09:00 PM ----------

Using com.sun.comm.SolarisDriver
# 9  
Old 12-11-2011
Quote:
Originally Posted by Jim Ryan
Thank you. I can only vaguely understand that.
I'm not too sure of it myself. Its behavior is fairly system-dependent. All I can suggest is checking the man pages for termios and open on your system.
# 10  
Old 12-11-2011
I just ran a special test. I created a simple, single-thread Java app that just opens, closes, reopens, closes, and for a third time reopens and closes one of the ports, all in a single thread in one block of code. The port was able to be reopened. No issues. No "Device busy".

Therefore, two possibilities arise. One, perhaps I was mistaken in saying that I'm sure that my original application was releasing the port completely upon closing it. But I am sure this isn't so. The Java port object has no handle to my app and my app has no handle to the port object. Two, perhaps the thread which opens a port may reopen it, while other threads may not. Indeed, my app, at launch time, opens the ports in one thread which dies after opening them. The thread which closes and reopens them is a different thread. If Solaris disallows this whereas Windows does not, and no configuration change is possible, then I can perhaps redesign my Java code to accommodate Solaris. I will have to verify this with further testing.

If any of you have any insight on this, I will be very grateful.
# 11  
Old 12-12-2011
Windows is the OS where I'd expect to have problems reopening the port, as it's pointlessly strict about two things having the same device...

Perhaps the garbage-collector hasn't rolled over it yet? Is there a way to explicitly make collection happen?
# 12  
Old 12-13-2011
Thanks for the idea. I suppose the GC is a possibility to consider and it's easy with one simple line of code to ask the GC to collect the garbage (though it isn't deterministic whether it will comply with this request in a timely fashion.) But the references between my Java variables and the port objects, when severed, are severed immediately. The references between my app being immediately gone, "Device busy" should not occur. But I'll try your idea and see.

My next test will be similar to the simple test I mentioned above but will use two threads: one to open the port and one to close and reopen it, thus mocking up my actual app's logic. If this test shows it impossible for the second thread to do the reopen because of "Device busy," then it becomes clear that in Solaris, only the thread that opens the port can reopen it while that thread's containing app is running, other threads being disallowed.

---------- Post updated 12-13-11 at 10:09 AM ---------- Previous update was 12-12-11 at 10:50 AM ----------

I am able to generate a similar issue (PortInUseException) when running on Windows with certain unit tests. So, although the issue varies with OS, it is not isolated to Solaris. Moreover, I have been using Java Comm's library for serial ports. But now that I have switched to the RXTX library (which implements the same classes and method, so one only needs to change the namespace in one's code), then the problem goes away in Windows. I do not have an RXTX library for Solaris x86 yet, so I cannot report that result yet. Also, if I do not add an event listener to the serial port in my code (with SerialPort.addEventListener()), then I do not get the issue with either Java Comm or RXTX. Therefore, it seems that SerialPort.removeEventListener() does not work in JavaComm's implementation but does work in RXTX. This fellow found the issue, too: Day after day

I'll need to use a compilation of RXTX for my Solaris x86 machine now.

I do not see this as an OS issue per se, though it does vary in severity between Solaris and Windows. If I find that RXTX resolves the issue in Windows but not in Solaris then I will report that.
This User Gave Thanks to Jim Ryan For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Solaris

How to remove a LUN in "Online Busy" state?

Hi all, I have a LUN that is in "Online Busy" when I issue the dev_gestate subcommand of luxadm: root@es088wb6:~# luxadm -v -e dev_getstate /dev/rdsk/c21t50050763090887FEd4s2 phys path = "/devices/pci@6c0/pci@1/pci@0/pci@4/SUNW,qlc@0/fp@0,0/ssd@w50050763090887fe,4:c,raw" ... (5 Replies)
Discussion started by: ludiegu
5 Replies

3. SCO

NFS umount shows the "Device busy (Error 16)"

Hi there After making a backup copy of it sometimes happens that when I want to unmount an NFS indicates the error:umount: /path_mount busy: Device busy (Error 16) if I run lsoff, I can not find the process that is blocking the application. I'm using OpenServer 5.0.2c as one NFS server ... (14 Replies)
Discussion started by: flako
14 Replies

4. Red Hat

Find out which eth or device belongs to interface "port 1 PCI 4"

Hi, I´ve given only this info to configure a network interface : "port 1 PCI 4" I´ve been searching for any kind of relationship in the system which allow me to find the etc that must be configured... Please, could anybody help me? rhxx:#/root# lspci |grep -i "PCI BRIDGE" 00:01.0 PCI... (0 Replies)
Discussion started by: pabloli150
0 Replies

5. UNIX for Dummies Questions & Answers

UNIX rm -rf error "rm: cannot remove `filename' : Device or resource busy"

Hi Everyone, I am trying to remove a directory: $ rm -rf directory_name/ rm: cannot remove `directory_name/filename': Device or resource busy What does this mean, and why can't I remove these files? I already tried moving into the directory, and removing the files individually, but I... (7 Replies)
Discussion started by: Anna_Z
7 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Linux

Umount of a "busy" disk

A product I am working on manages storage. We are currently porting it from Solaris to Linux. The product allows its user, among other things, to add and remove file server volumes, where these volumes are exported using the NFS or the CIFS protocol. The problem is that when the user requests to... (5 Replies)
Discussion started by: dhzdh
5 Replies

8. Emergency UNIX and Linux Support

Mapping between "Pseudo name" and "Logical device ID" in powerpath with SVM changed....

Dear All, I was having powerpath 5.2 on SUN server with SVM connected to CLARIION box.Please find the following output : root # powermt display dev=all Pseudo name=emcpower3a CLARiiON ID=CK200073400372 Logical device ID=60060160685D1E004DD97FB647BFDC11 state=alive; policy=CLAROpt;... (1 Reply)
Discussion started by: Reboot
1 Replies

9. UNIX for Dummies Questions & Answers

serial port device path

hi. Im trying to install a switch. And the manual says i should type a command including a SerialPortDevicePath. which is the filepath to serial port used for connection. However.. nothing about how to find this info. Could anyone help me where to find this path? thx mr.T (6 Replies)
Discussion started by: tyskertøs
6 Replies
Login or Register to Ask a Question