Solved

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

Posted on 2003-11-26
11
1,798 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
  • 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
 

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now