Sponsored Content
Full Discussion: multithreads and IO ports
Top Forums Programming multithreads and IO ports Post 93772 by dartarrow on Thursday 22nd of December 2005 03:25:21 AM
Old 12-22-2005
multithreads and IO ports

I am using GTK 2.0 to write a program to control two IO ports; ttyS0 and ttyUSB0. If i were to open two different copies of the same program then it's all fine, but i need to be able to control two ports from one interface and that seems to be the problem.

my code for connection is:
Code:
	//open the device(com port /usb port) to be non-blocking
      	fd1 = open(gtk_entry_get_text(GTK_ENTRY(entDev1)), O_RDWR | O_NOCTTY | O_NONBLOCK);
      	if (fd1>0)
      	{
	   //install the serial handler before making the device asynchronous
	   saio1.sa_handler = IOhandler1;
      	   sigemptyset(&saio1.sa_mask);   //saio1.sa_mask = 0;
      	   saio1.sa_flags = 0;
      	   saio1.sa_restorer = NULL;
      	   sigaction(SIGIO,&saio1,NULL);

      	   // allow the process to receive SIGIO
      	   fcntl(fd1, F_SETOWN, getpid())	;
      	   fcntl(fd1, F_SETFL, FASYNC)	; //0 || FASYNC

           tcgetattr(fd1,&oldtio1); // save current port settings 

           // set new port settings for canonical input processing 
      	   newtio1.c_cflag = BAUD | CRTSCTS | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL | CREAD;
      	   newtio1.c_iflag = IGNPAR;
      	   newtio1.c_oflag = 0;
      	   newtio1.c_lflag = 0;       //should be ICANON but dont seem possible;
      	   newtio1.c_cc[VMIN]=1;
      	   newtio1.c_cc[VTIME]=0;
	   //tcflush(fd1, TCIFLUSH); //clears lines
      	   tcsetattr(fd1,TCSANOW,&newtio1);
	   gtk_button_set_label(GTK_BUTTON(btnConnect1), "Disconnect");
      	   gtk_widget_show(btnSend1);
      	   gtk_widget_show(btnClear1);
      	   isconnected1 = TRUE;
	   sleep(1); //wait one sec so can properly establish connection
      	} //if fd>0
      }//if isconnected == false


and i guess the problem is that it binds to the pid. But this means that threads will not work either as the pid will be the same. Perhaps fork()? but i have to say i do not have the faintest idea how to do it. Any help appreciated.

Last edited by zazzybob; 12-22-2005 at 08:38 PM.. Reason: code tags added
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ports

How To Close ports,for example finger port 79?? :confused: :confused: :confused: 10x (6 Replies)
Discussion started by: Yaki
6 Replies

2. UNIX for Dummies Questions & Answers

Ports

I know i can look in the /etc/services file to look at referenced port numbers, but is there a command that will list the current ports being used? (i.e. what is the application does not have an entry in the services files :confused: ) (2 Replies)
Discussion started by: Ralf
2 Replies

3. IP Networking

ports???

Ok, I've been working in the IT field for about 3 years now and I never fully understood the concept of ip ports. I just started a new job that uses Solaris and today it kinda clicked in my head and I want to know if I'm right or wrong. Does each ip address have multiple ports. because we... (4 Replies)
Discussion started by: eloquent99
4 Replies

4. IP Networking

Ports

What are some good sites that list all TPC/UDP ports? ~thanks (3 Replies)
Discussion started by: ireeneek
3 Replies

5. UNIX for Dummies Questions & Answers

Ports...

Hello UNIX people... This is my first foray into the UNIX world so go easy on me... I have a client who has hired me to do some work on his windows stuff, BUT it just so happens his UNIX server started giving him problems... He is running SCO Open Server 5.0.6 The TTY ports won't... (5 Replies)
Discussion started by: TechKnow
5 Replies

6. HP-UX

Ports

Can any one tell the command for which process are running on a perticular port (1 Reply)
Discussion started by: zsujith
1 Replies

7. Solaris

regarding ports

Hi , I need one help... Is there any command on solaris 10 to free the ports. For e.g I used netstat -na| grep 8080 it displays either it is listening or established.. i want to free the ports... Anyone please help me on this... Thanks, Shanmuga (2 Replies)
Discussion started by: shanshine
2 Replies

8. Solaris

ports

Hi, If for example i try to start tomcat in a solaris server and get errors related to address already in use, how can I know if this port is really used for another process? If someone can point any documentation it will be very helpfull. Thanks! :rolleyes: (9 Replies)
Discussion started by: ffpradella
9 Replies

9. UNIX for Dummies Questions & Answers

ports

When the netstat -an command is run on current unix machine, it seems that there's an excessive amount of ports established (roughly 600). How can I tell what each of these ports are being used for? (1 Reply)
Discussion started by: lastchance551
1 Replies

10. UNIX for Advanced & Expert Users

Ports

** forum admins: Before you come down on my like a wrath of something, I can get no decent answers so I have to come to these Gurus' court *** I am by no means Unix expert. However, none of our unix admin (aix & hpux) can give me an answer that makes sense. My Issue: Assigned ports in 8601,... (7 Replies)
Discussion started by: rsheikh
7 Replies
starplot(1)						      General Commands Manual						       starplot(1)

NAME
starplot - view 3d perspective maps of stars SYNOPSIS
starplot [ GTK+ opts ] [ datafile1 [ datafile2 [...] ] ] DESCRIPTION
StarPlot is a GTK+ based program, written in C++, that can be used interactively to view three-dimensional perspective charts of stars. It is licensed under the GNU General Public License. Currently StarPlot does not have any command-line flags other than those built into all GTK+ applications. One or more data files to open can be specified at the command line. If none are specified, and this is the first time using StarPlot, the program will open the default file, /usr/share/starplot/examples/sample.stars. StarPlot saves its settings on exit to an rc file, ~/.starplotrc. For detailed informa- tion on how to use the program, see the HTML documentation. FILES
/usr/share/starplot/ - Contains StarPlot data files /usr/share/doc/starplot/ - Contains documentation ~/.starplotrc - Saved program settings for each user SEE ALSO
starconvert(1), starpkg(1) AUTHOR
Copyright (C) 2000-2002 under the GNU GPL by Kevin B. McCarty <starplot@starplot.org>. The StarPlot web page is at www.starplot.org. Nov 2002 starplot(1)
All times are GMT -4. The time now is 08:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy