LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 02-05-2010, 11:49 PM   #1
rajmohan_tricom
LQ Newbie
 
Registered: Oct 2008
Posts: 3

Rep: Reputation: 0
Thumbs up how to identify the status of serial port ("Port Already Opened") from a C program


Dear All,

I am writing some application in C, which will access a serial port device (RS232). My application is working good. But if any other application is already opened the port, I couldn't able to identify that.


In windows VB program, while accessing comport through mscomm control, i am receiving an error as "Port Already Opened". But in Linux environment, through C program how can i get that?

I am accessing comport 1 as follows
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_SYNC);

Thanks in advance for your valuable suggestions.

Regards,
Rajmohan.
 
Old 02-05-2010, 11:55 PM   #2
Anisha Kaul
Senior Member
 
Registered: Dec 2008
Location: Gurgaon, India
Distribution: Slackware 13.37, OpenSuse 11.3
Posts: 4,373
Blog Entries: 21

Rep: Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706
Have u tried identifying whether the port is already open or not by using the various return values of open() system call ?

Last edited by Anisha Kaul; 02-06-2010 at 12:19 AM.
 
Old 02-07-2010, 10:11 PM   #3
rajmohan_tricom
LQ Newbie
 
Registered: Oct 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Dear Anisha, Thanks. I tried this. But i got positive values which is file descriptor. I'm not getting error for open() system call.

Rajmohan
 
Old 02-07-2010, 10:27 PM   #4
Anisha Kaul
Senior Member
 
Registered: Dec 2008
Location: Gurgaon, India
Distribution: Slackware 13.37, OpenSuse 11.3
Posts: 4,373
Blog Entries: 21

Rep: Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706
See the following links, may be they can help u someway !

http://stackoverflow.com/questions/1694144?tab=oldest

http://www.linux-noob.com/forums/ind...o-open-a-port/

Last edited by Anisha Kaul; 02-07-2010 at 10:39 PM.
 
  


Reply

Tags
already, port


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial Port Access Denied using open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY); morty346 Programming 11 01-02-2011 05:23 PM
Serial Port Access Denied using open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY); morty346 Linux - Newbie 4 02-11-2009 08:13 AM
How to read "identify" button press event, or state of "identify" blue led with IPMI? iav Linux - Server 0 01-28-2009 09:45 PM
serial port "not found" on RHEL4 Dell 690s jdonigan Red Hat 0 05-31-2007 01:40 PM
serial port I/O? what is "\r" in printf blackzone Programming 2 08-16-2004 05:24 AM


All times are GMT -5. The time now is 05:45 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
Open Source Consulting | Domain Registration