[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ncurses, pthreads, and serial port
From: |
Thomas Dickey |
Subject: |
Re: ncurses, pthreads, and serial port |
Date: |
Wed, 29 May 2002 21:01:35 -0400 |
User-agent: |
Mutt/1.2.5i |
On Wed, May 29, 2002 at 05:15:59PM -0500, Troy Davis wrote:
> I start by doing initscr(), init_colors(), noecho(), cbreak(), clear().
> I
> set up the main window (stdscr). I then create a new window as a menu. I
> make simple list, put it on screen, with a very simple scroll handler to
> arrow through the list. Then I create a 3rd window (upon the appropriate
> menu choice) using newwin. I then call pthread_create. This creates a
> thread that initializes a serial port, and then arrives at a while(1) loop.
> The while loop does a read of the serial port (non-blocking) and upon a
> return of 1 (a single character), does a waddch() to the appropriate window
> followed by a wrefresh().
ncurses isn't thread-safe, so you can only use it like that if there's
only one thread that calls ncurses.
--
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net