delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2012/09/15/12:30:00

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Date: Sat, 15 Sep 2012 11:15:38 -0500
From: "John Wright" <john AT wacontrols DOT com>
To: djgpp AT delorie DOT com
Disposition-Notification-To: "John Wright" <john AT wacontrols DOT com>
Subject: Programming Question - Event Loop
Message-ID: <8a934d3856d2d88ae8fd370711400dc1@wacontrols.com>
X-Mailer: IceWarp Web Mail 5.6.7
X-Originating-IP: 75.110.125.79
MIME-Version: 1.0
Reply-To: "John Wright" <john AT wacontrols DOT com>

Dev platform: Red Hat Linux 5.2, gcc compiler

I'm working on a graphical front end for program that monitors serial port activity. It's really just another terminal program that displays ASCII protocol messages in a window. I'm doing this in XLib for now because I want to have a good understanding how and when to use low-level routines. The example code that I am using to create my own program is a file viewer application that allows you to display a files content, and scrolls text up or down in either direction. I modified the original code to fopen() file stream to the serial port and fgets() 20 lines or so of input before read_lines() function breaks. The read_lines() function creates double linked structures and allocates memory. All of this is setup and done before the event loop. I want to continue to read lines of data inside the event loop and scroll up and off the window as long as the program is running, or I issue a ButtonPress event to stop reading. The program copies and clears Regions to create the scrolling effect
in the display_lines() function.

Anyway, I'm not sure where to inject the reading of lines code into the event loop. I assume it needs to go into the Expose: section of the XAny.event switch statement. Or, do I need to fork() a process outside the event loop that continually reads serial port data into a circular buffer or file, then view it from some event routine. I really don't want to stop reading from the serial port or file before I draw the text to screen. I want to keep that read process alive and keep displaying real-time data as it arrives.

Can someone point me in the right direction? Maybe there is an open source graphical terminal program that I can use as an example. I'll be glad to post or email code. All of this is done in the main.c source file. Setting up the display and all of that good stuff are in their own source files so everything is well organized.

Really, all I need to know is what method do I need to follow. Can I do this without fork()ing a new process.

-jw

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019