Link to home
Start Free TrialLog in
Avatar of geordieporker
geordieporker

asked on

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
Avatar of Gns
Gns

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

-- Glenn
Avatar of geordieporker

ASKER

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
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
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
ASKER CERTIFIED SOLUTION
Avatar of pjedmond
pjedmond
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great sites pjedmond. Thanks.

-- Glenn
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
Points to pjedmond.

-- Glenn
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
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