Parallel and Serial Port access using Cygwin ontop of Windows XP.

Hi,

I am currently doing research to find out if it is possible to write a porgram allowing me to output ASCII text (either a txt file or single typed characters) to the serial and parrallel ports of a computer running WinXP and the Cygwin UNIX emulation layer.

I cannot find examples of how this would be done (at least not commented ones which I can make sense of).  I need to be able to recieve the data as well, but this is much less important, since for now I would simply like to be able to activate LED's on a board which I have.  I cannot provide any more information I'm afraid, and I can only hope that you will be able to assist me.

Many thanks in advance,


Mike King
pencil.dot@ntlworld.com
geordieporkerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GnsCommented:
Have you tried reading/writing from/to LPT1:, COM1: etc?

-- Glenn
0
geordieporkerAuthor Commented:
This is the problem - I am new to programming, and although I have a small amount of knowledge, I need advice on:
1) this problem (which is urgent)
2) which books to read to help me.

I do not know the C/C++ code to implement input/output to/from LPT/COM ports.  Also, I do know that WinXP has... difficulty allowing anyone to write to/read from a port unless it is for standard useage (printing, modem use etc), so I am going to have to write code which executes in Real mode, not Protected mode, and this (I suspect) will require more detailed code.  If not, where would I find examples of how to output to COM/LPT which I could digest?

Many thanks for the swift reply.

Mike
0
GnsCommented:
In a normal unix/linux environment this would all be solved by viewing even device drivers as files.... You would simply open(...); read(..) etc a file (usually called a "device handle"´, since the pseudo-file gives you a "handle" to manage the device by). You would also have ioctls to "manage" things (like monitoring lines etc... The downside is that it can be rather icky to try to manipulate a device in some way the driver would prohibit (Usually a good thing:-)... serial/parallell devices would likely support what you'd want to do though).

No such luck with cygwin. It is after all just an emulation layer that make windows barely bearable for us unix huffs:-).
So instead you need manipulate the windows device drivers more or less exactly the same way from a cygwin perspective as you would from windows, through the same set of "device handles" and paradigms.
The definitive, rambling and sometomes less than clearly structured source for how to do such things would (of course) be microsoft.

I'm afraid it's been several years since last I laid hands on a book on programming, so others will probably have a very much more updated view on what constitutes "good books" on the subject... I found Bjarne Stroustrups C++ book to be one of the best books written ... on the C programming language! It's very ... non-windows though.
And I've always have had good use for most anything from O'Rielly... You could get the Camel book and write it in Perl:-).
And of course there are a lot of sources on the net (There's some unix/linux specific guides and manpages on http://www.tldp.org for example)... Google is your friend here:).

I'm afraid this isn't much help, but it is unfortunately all I have time with ATM (busy with Real Paying Work (tm)).

-- Glenn
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

geordieporkerAuthor Commented:
That's great for a start, thanks.

I have the O'Reilly Practical C++ Programming book, and access to the C version.  Now I just need to find out what the name of the array for COM and LPT are so I can try your fisrt suggestion.  I'll be posting more when I have the results of my tests.

Cheers again,

Mike
0
pjedmondCommented:
Probably the best place to start would be here:

http://www.lvr.com/parport.htm

as it appears that you are in need of a very general concept of how it all works.

Although it would be preferable to use the interfaces provided by windows, you can access the ports directly as described and documented in a number of the links from this page. It also has a serial page:

http://www.lvr.com/serport.htm

The links also have plenty of code examples in C and other languages.

HTH:)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GnsCommented:
Great sites pjedmond. Thanks.

-- Glenn
0
geordieporkerAuthor Commented:
Just been to that site - brilliant.  It seems to tell me most of what I'm missing. (everything!).

Thanks again.

I'm going away for 5weeks now (due to university exams), but will leave the question open for now, and will ask some (hopefully more pertinent) questions then.

Cheers
Mike
0
GnsCommented:
Points to pjedmond.

-- Glenn
0
geordieporkerAuthor Commented:
Thanks for all your help guys.

I'll follow glenn's suggestion as I'm (obviously) a newbie here, but as I said, thanks to all.

Mike
0
GnsCommented:
Thanks Mike, and thank you for finalizing this.
"CleanupPing" is an automated thing... so the recommendations we experts leave are for the use by a Mod or Admin to close the question in (what we feel is) aa correct a manner as possible... Obviously for the questions where the "questioner" never does.
I felt that pjedmonds advice was very much better than mine, so... :-)
I'm very comfortable with him getting the points (or her... I really don't know:-).
As I (and most experts) do this for fun and education (our own as well), the points don't matter that much ... The good feeling of having helped in some small way does though, so thanks for that gesture too.

-- Glenn
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.