Solved

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

Posted on 2003-11-26
11
1,812 Views
Last Modified: 2013-11-15
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
0
Comment
Question by:geordieporker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
11 Comments
 
LVL 20

Expert Comment

by:Gns
ID: 9825964
Have you tried reading/writing from/to LPT1:, COM1: etc?

-- Glenn
0
 

Author Comment

by:geordieporker
ID: 9826378
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
 
LVL 20

Expert Comment

by:Gns
ID: 9830503
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:geordieporker
ID: 9831370
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
 
LVL 22

Accepted Solution

by:
pjedmond earned 500 total points
ID: 9878878
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
 
LVL 20

Expert Comment

by:Gns
ID: 9882335
Great sites pjedmond. Thanks.

-- Glenn
0
 

Author Comment

by:geordieporker
ID: 9883286
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
 
LVL 20

Expert Comment

by:Gns
ID: 10182370
Points to pjedmond.

-- Glenn
0
 

Author Comment

by:geordieporker
ID: 10185945
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
 
LVL 20

Expert Comment

by:Gns
ID: 10190536
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

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
Fine Tune your automatic Updates for Ubuntu / Debian
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.
Viewers will learn how to use the Hootsuite Dashboard.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question