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
QUISK(1)							   User Commands							  QUISK(1)

NAME
quisk - a Software Defined Radio (SDR) DESCRIPTION
QUISK is the software that controls a receiver and transmitter. QUISK rhymes with "brisk", and is QSK plus a few letters to make it easier to pronounce. QSK is a Q signal meaning full breakin CW, and QUISK has been designed for low latency CW operation. It works fine for SSB and AM too. It currently runs under Linux using ALSA sound drivers or PortAudio and offers these capabilities: Quisk can control the HiQSDR. As a receiver it can use the SDR-IQ by RfSpace as a sample source. There are several decimation rates available. The screen shots below were taken using the SDR-IQ. The QUISK receiver will read the sample data, tune it, filter it, demodulate it, and send the audio to the sound card for output to external headphones or speakers. As a receiver it can use your soundcard as a sample source. You supply a complex (I/Q) mixer to convert radio spectrum to a low IF, and send that IF to the left and right inputs of the sound card in your computer. The demodulated audio goes to the same soundcard for output. Quisk can control SoftRock hardware for both receive and transmit. As a transmitter it can control my SSB/CW exciter and my transceiver using Ethernet. As a transmitter it can accept microphone input and send that to your transmitter for SSB operation. For CW, QUISK can mute the audio and substitute a side tone. Quisk can send transmit data to your sound card for use with SoftRock or similar. If you are not using SoftRock hardware and not using Ethernet, then you can modify the C code in microphone.c to connect to your hardware. If you have the SDR-IQ or the Softrock hardware, then QUISK is ready for you to use as a receiver. If you have other receive hard- ware, then you will need to change the file quisk_hardware.py to connect your receiver to QUISK. For example, if you change your VFO frequency with a serial port, then you need to change quisk_hardware.py to send characters to the serial port. The file quisk_hardware.py is written in the Python programming language, a very easy language to learn and use. SETUP
Some deployments of quisk will only need to use sound hardware with ALSA. Other setups will use serial ports (or USB serial ports) and may need permissions set up (perhaps using udev) to allow the quisk program's user access to those ports. See documentation in /usr/share/doc/quisk for more information, as well as configuration file examples. The default configuration file is ~/.quisk_conf.py The configuration file must be customized for the user (see the commented examples) before running quisk. SYNOPSIS
quisk [options] OPTIONS
-h, --help show this help message and exit -c CONFIG_FILE_PATH, --config=CONFIG_FILE_PATH Specify the configuration file path --config2=CONFIG_FILE_PATH2 Specify a second configuration file to read after the first SEE ALSO
http://james.ahlstrom.name/quisk/ Sample config files are in /usr/share/doc/quisk/quisk_conf* copy one, edit and save as ~/.quisk_conf.py For use with a Funcube Dongle see the program qthid in package qthid-fcd-controller. quisk 3.5.11 January 2012 QUISK(1)
All times are GMT -4. The time now is 08:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy