LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 12-29-2005, 02:08 PM   #1
MuLaZ
LQ Newbie
 
Registered: Aug 2004
Distribution: Slackware
Posts: 22

Rep: Reputation: 15
serial port stays open after app. closes


I have a VS840 multimeter, and i found some code for PC readouts, through rs232 port

the source: http://pastebin.com/483265
or you can find it at: http://www.lrr.in.tum.de/~acher/vc840/vc840.c (it's the same code)

the program reads out the measurings right, but the problem is that you can only stop it with C-c

after that if you run the prog. again, it doesnt read anything until a reboot.
setserial said that the port was in use

is there a way to manually close an open serial port? or another way to stop the program that would close the port (there is a close_serial function, but it is not used)?

it is boring if I have to make 20 reading to reboot my pc 20 times.

thank you for any help given
 
Old 12-30-2005, 11:28 PM   #2
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
As root type this command to find out which application is using the serial port.

lsof /dev/ttyS0

Here's an example output, my ups daemon is on the first port.
Code:
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
upsd    2668 root    3u   CHR   4,64       681 /dev/ttyS0
There's another possibility, the application may be using some kind of lock file that isn't cleaned up when you ctrl-c it but gets removed when you reboot. Some programs create a file (maybe in /var/lock) and if the file exists it won't reopen the serial port even though no one is actually using the port.
 
Old 12-31-2005, 11:49 AM   #3
MuLaZ
LQ Newbie
 
Registered: Aug 2004
Distribution: Slackware
Posts: 22

Original Poster
Rep: Reputation: 15
lsof /dev/ttyS0 doesnt output anything
there is no lock file specified in the program, and none exists for the serial port on the pc

still.. after a reboot, i start the program and it outputs me data, when i stop it, and then rerun it again, it doesnt do anything. unplugging and replugging the cables doesnt help, so does not turning off/on the meter
 
Old 12-31-2005, 01:16 PM   #4
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
Do you have the source code to the application?
Also, just try runing the lsof command from a different terminal while your application is also running and see if it prints out the name of your application.
Then when you ctrl-C the app does lsof stop listing the application?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
linux serial port to router console port connection? frankie_fix Linux - General 3 02-26-2007 09:32 PM
LXer: Nessus 3.0 Closes the Book on Open Source LXer Syndicated Linux News 0 12-24-2005 10:31 PM
Using serial port card(PCMCIA) with IPAQ running Linux, can't find ttyS0 port d2army Linux - Laptop and Netbook 0 11-12-2005 08:07 PM
Sniffing Serial/IrDA-Communication of Win32-App to create Open Interface PSIplus Programming 0 06-02-2004 07:58 PM
port 80/tcp closes itself? allohakdan Linux - Security 4 01-28-2004 11:14 AM


All times are GMT -5. The time now is 09:50 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration