Sponsored Content
Top Forums Programming Problem regarding serial port and multithreading Post 302144943 by porter on Monday 12th of November 2007 03:58:28 AM
Old 11-12-2007
The most reliable way to used a file descriptor is not to have some functions handled in different threads, but use the same thread to do all IO for a file descriptor, use select or poll and non-blocking IO just like in a single threaded application.

If you take the multithreaded approach having one thread to read, and one to write, how do you stop the reading, how do you close the file descriptor?

And yes, if writing multithreaded code you must take precautions, eg mutexs, condition variables as appropriate.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Serial port communication

We're running SCO Unix Openserver 5.05 and I'm having trouble with serial communication between the com2 serial port and a handheld device. Downloading data from Unix to the handheld works perfectly, but the other way around creates a major problem. I don't know whether it's a buffer overflow or... (1 Reply)
Discussion started by: Aretha
1 Replies

2. Programming

problem while having a communication with serial port?????

hello, I am gettin problem while sending and recieving data through seial port... when I am sending Data then the reciever end is not able to recieve that data ..... Reciever end is running in infinite loop just polling after some time to check that there is data on the port and then again... (9 Replies)
Discussion started by: arunchaudhary19
9 Replies

3. Programming

Serial port programming

I am developing an application in c with Linux OS, where a radio modem working at baud rate 9600 will be attached to PC on serial port. More than four such units will be communicating at one time, so there may be jamming or data corruption. Each module will be transmitting Data packets less than... (2 Replies)
Discussion started by: raj8109
2 Replies

4. UNIX for Dummies Questions & Answers

problem with serial port BSD

Hello all , i have change my system debian linux to freebsd( pcBSD) all working as well , but the serial does not work correctly. Under linux the problem does not appears. my problem is than my serial port does work . the first step than i have make is look with dmesg if my serial are... (0 Replies)
Discussion started by: pitbac23
0 Replies

5. Solaris

Serial port problem

I am working with solaris 9 sparc and I want to connect physical device in serial port but when I am connecting it,It is showing the error window saying-- So can any1 tell me the reason or is there any package I have to add to work with serial port??? (2 Replies)
Discussion started by: smartgupta
2 Replies

6. Programming

problem in coding for GSM interfacing using serial port

i am having some coding problem in c for interfacing the GSM module through serial port. i want to send/receive sms. i have done all the setting for the port and know the AT command to use in this but i am actually having problem in reading and writing from serial port how to handle the signal when... (1 Reply)
Discussion started by: harsh_it
1 Replies

7. Shell Programming and Scripting

Need help with serial port

Hi, I have a external board connected to my serial port. I need to execute "shutdown -r now" command when system boot up. When system boots up it requires a username ans password. Then I need to run my command. I can use rc script but that is rebooting system before it asks for username and... (0 Replies)
Discussion started by: charlie.arya
0 Replies

8. Solaris

How to enable Serial port on ILOM, when Network Port is enabled in parallel

Hi Everyone, In my environment, I have few T5220. On the iLOM Management Card, I have both Network and Serial port are cabled, I don't have any issues while I try to connect using Network Management port, but when I try to connect the serial port for the same server which is actually connected... (3 Replies)
Discussion started by: bobby320
3 Replies

9. SCO

Problem finding what is using a serial port

How can I determine what process is currently using a serial port? A good bit of google searching hasn't turned up anything useful, but it seems like there has to be a way to do this without too much difficulty. When I first started looking into this problem, I assumed that when a port was in... (2 Replies)
Discussion started by: jdsnatl
2 Replies

10. Solaris

Cabling and adapters to communicate to service processor serial port from Windows PC with USB port.

Hello, I have an unloaded T5140 machine and want to access the ILOM for the first time and subsequently the network port after that., and then load Solaris 10 the final January 2011 build. The first part is what confuses me -the cabling. I am coming from a Windows machine (w/appropriate... (5 Replies)
Discussion started by: joboy
5 Replies
ost::SerialService(3)					     Library Functions Manual					     ost::SerialService(3)

NAME
ost::SerialService - The SerialService is a thead service object that is meant to service attached serial ports. SYNOPSIS
#include <serial.h> Inherits ost::Thread, and ost::Mutex. Public Member Functions void update (unsigned char flag=0xff) Notify service thread that a port has been added or removed, or a timer changed, so that a new schedule can be computed for expiring attached ports. SerialService (int pri=0, size_t stack=0, const char *id=NULL) Create a service thread for attaching serial ports. virtual ~SerialService () Terminate the service thread and update attached objects. int getCount (void) Get current reference count. Protected Member Functions virtual void onUpdate (unsigned char flag) A virtual handler for processing user defined update requests (1-254) which have been posted through Update. virtual void onEvent (void) A virtual handler for event loop calls. virtual void onCallback (SerialPort *port) A virtual handler for adding support for additional callback events into SerialPort. Friends class SerialPort Additional Inherited Members Detailed Description The SerialService is a thead service object that is meant to service attached serial ports. Multiple pool objects may be created and multiple serial ports may be attached to the same thread of of execution. This allows one to balance threads and the serial ports they service. The TTYPort and TTYService classes are used to form thread-pool serviced serial I/O protocol sets. These can be used when one has a large number of serial devices to manage, and a single (or limited number of) thread(s) can then be used to service the tty port objects present. Each tty port supports a timer control and several virtual methods that the service thread can call when events occur. This model provides for 'callback' event management, whereby the service thread performs a 'callback' into the port object when events occur. Specific events supported include the expiration of a TTYPort timer, pending input data waiting to be read, and 'sighup' connection breaks. Author: David Sugar dyfet@ostel.com Thread pool service for serial ports. Constructor &; Destructor Documentation ost::SerialService::SerialService (intpri = 0, size_tstack = 0, const char *id = NULL) Create a service thread for attaching serial ports. The thread begins execution with the first attached port. Parameters: pri of this thread to run under. stack stack size. id stack ID. virtual ost::SerialService::~SerialService () [virtual] Terminate the service thread and update attached objects. Member Function Documentation int ost::SerialService::getCount (void) [inline] Get current reference count. This can be used when selecting the lead used service handler from a pool. Returns: count of active ports. virtual void ost::SerialService::onCallback (SerialPort *port) [protected], [virtual] A virtual handler for adding support for additional callback events into SerialPort. Parameters: port serial port currently being evaluated. virtual void ost::SerialService::onEvent (void) [protected], [virtual] A virtual handler for event loop calls. This can be used to extend event loop processing. virtual void ost::SerialService::onUpdate (unsigned charflag) [protected], [virtual] A virtual handler for processing user defined update requests (1-254) which have been posted through Update. Parameters: flag of update request. void ost::SerialService::update (unsigned charflag = 0xff) Notify service thread that a port has been added or removed, or a timer changed, so that a new schedule can be computed for expiring attached ports. This can also be used to pass requests to the OnUpdate() event handler. Parameters: flag event for OnUpdate, termination, or reschedule. Friends And Related Function Documentation friend class SerialPort [friend] Author Generated automatically by Doxygen for GNU CommonC++ from the source code. GNU CommonC++ Sat Jun 23 2012 ost::SerialService(3)
All times are GMT -4. The time now is 02:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy