First an update. I have a test program that runs two child threads, one
to write out to the serial port and one to write out the parallel. The
mail thread then just sits there printing out a counter. It works a
treat, I can display a clock on the large LCD display connected to the
serial line and all my relays are firing off in a nice pattern!
Problem I have now is that the inb function on reading the parallel port
does not seam to work. But this could be a hardware issue as my normal
test program is not working 100%. Maybe I need some more sleep before
continuing.
Now onto Barrie's comments.
> Each activity needs to be associated with a Posix file descriptor. As you
> probably know, these can be TCP sockets, UDP sockets, comms ports,
> *anything* which can be opened as a file.
Thats my problem, only 1 out of 3 are file handles.
> In your case, I would have select() wait on incoming comms characters and on
> a tcp socket to/from your database.
Well the socket interface is all hidden. Its just a bunch of calls such
as
SQLExecDirect(hstmt,"SELECT col1,col2 FROM table",SQL_NTS);
which might block for an unknown period of time.
> I suggest you get your hands on two great books by Richard Stevens:
> 1) Advanced Programming in the UNIX environment
> 2) UNIX Network programming
Yep, I did that.
> I would love to see your code for ODBC access to an NT/SQL box from a bit of
> C on a Linux box!!!
Go to http://unixodbc.org/ Under the manual section there is a link to
a tutorial which is not very good, but it has just enough. The code on
http://www.unixodbc.org/doc/ProgrammerManual/Tutorial/conne.html shows
you how easy it is to connect. You write exactly the same C as you would
on a windows machine, its the same API as defined by X/Open. You just
include the headers files and the link it to libodbc.o. It really is as
easy as that. Of course you need to install a server component on the NT
machine and a client component on the Linux box
(http://www.easysoft.com/products/oob/main.phtml). They are quick to
install. You then just edit an .INI file in /etc on the linux box to
tell it what machine and database to connect to, basically a system DNS.
> BTW - What has happened to TEMP.RODOS.NET !!!!!!!!!!!!!!!!!!!!!!
> I used to watch it regularly.
Bugger. The thermometer died and the people who produced them went
under. I need to either fix it or change over to another one. Its on my
to do list to fix but there are soooo many things on the list before it.
I really miss the min and max for each day. It was nice to know that it
was 5.2 at 6:40am. Made it easier to understand why it was so hard to
get out of bed. Maybe a tetris game on the side of some building
somewhere might be more fun.
Rodos
> ----- Original Message -----
> From: Rodos <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, 19 April 2000 15:13
> Subject: [SLUG] All you C/Posix gurus.
>
> > I am writing an application in C on Linux.
> >
> > Here is my problem. There are three things the program does, writes out
> > to a serial port. Reads and writes to the parallel port, and
> > communicates with a database. The thing is that the serial and database
> > stuff might block or timeout for periods of time (say 1 to 10 seconds).
> > However I need to constantly poll the serial port for data.
> >
> > Therefore I am not sure as to the best way to architect my program.
> > First thing that comes to mind is threads, but that sounds to hard for
> > me (not that I have looked at it yet). Other things are forking 3 tasks
> > and getting them to comminute with each other (how I don't know yet).
> >
> > So what do you gals and guys recommend, is there a common way of doing
> > such things? Is there a good C/Unix book that I should get ASAP. I have
> > flipped through my Kernighan "The Unix Programming Environment" and it
> > has a bit on forking but not a lot.
> >
> > Thanks for the advise.
> >
> > Rodos
> >
> > P.S. I have ODBC working straight to an NT machine from my C program.
> > Way cool. I will be able to turf out more NT machines on this projects
> > and future ones when it is mandated that MS SQL is the database
> > platform. I am planning on writing a very small howto type thing on it.
> >
> > --
> > If the box says "Windows 95 or better", it should run on Linux, right?
> > - anon
> > --
> > SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
> > To unsubscribe send email to [EMAIL PROTECTED] with
> > unsubscribe in the text
> >
--
If the box says "Windows 95 or better", it should run on Linux, right?
- anon
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text