Date: Thu, 6 Mar 2003 21:52:11 +0100 From: "Kjell" <junkmail@sensewave.com> To: "J. Seth Henry" <jshenry@comcast.net> Cc: questions@freebsd.org Subject: Re: Looking for POSIX programming resources Message-ID: <3E67C30B.30138.312575D@localhost> In-Reply-To: <20030306150225.S940-100000@whitetower.gambrl01.md.comcast.net>
next in thread | previous in thread | raw e-mail | index | archive | help
> I realize this isn't exactly on topic, but I figure a bunch of you > guys/gals have probably done stuff like this, and might know where to > point me. > > I am trying to write an automation program in FreeBSD that listens for > commands on a serial port, and responds by issuing commands in response. I > also need to accept commands and data from local users or shell scripts. > > Right now, I poll the serial ports periodically, and this seems to work > OK. I would prefer to put the program to sleep until either a fixed amount of > time has passed ( a timer interrupt ), or data arrives at one of the > serial ports ( a device interrupt ). Unfortunately, I don't know how to do > to this under FreeBSD. (All my C programming so far has been "filters" > and such). Could someone point me to a resource on how to do this? > > Also, this program should run as a daemon, but I don't know how to make it > disconnect from the tty (currently, I just run it using &). bkpupsd is a simple port that demonstrates this. > > How can I call programs, and read their output, from within my program? > > How can I read the system clock? A lot of events need to occur based on > real-time (I presently use cron and shell scripts, but I would like to be > able to calculate future times programmatically, and set my own "alarms") long int unixtid; time(&unixtid); > > Lastly, how can I get data and commands into and out of my program? I Also demonstrated by bkpupsd > figure a file interface would be the simplest, and simply check the file > periodically to see if it has changed. Is there an easier way, or is this > an accepted method? I would eventually like to write a web page and use my > existing web server and CGI scripts to control/monitor the daemon - but > I'm not sure I'm ready to write my own web server code into this app. You will find that PHP scripts lends itself fine for this.. > > In summary, can anyone help me write code that: > 1) puts my daemon to sleep, awaking only when either a timer has expired, > data has arrived one of the controlled serial ports, or the user has > invoked some interface from a script or command line utility. > > 2) Daemonizes my program (dissasociating itself from the terminal) > > 3) Accepts commands and/or data from scripts or command line utilities. > > 4) Call other programs, and pass them parameters. > > 5) Read the system clock. The above should answer your questions? regards from Kjell / LA3SG To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E67C30B.30138.312575D>