|
faraznasim (Electrical)
28 Mar 04 14:57
Hi, I m relatively a beginner in C, but after covering some major topics, i want to learn something abt interfacing hardware like printer parallel port or some LED etc thru C. can anyone guide me, or refer to any online material..
Thanks, FaRaZ.
Jyuuken (Electrical)
1 Apr 04 3:35
Perhaps u can try this site ... http://www.beyondlogic.org/spp/parallel.htm
nbucska (Electrical)
1 Apr 04 12:26
Under DOS it is simple -- under WINDOWS -- well I don't do windows. <nbucska@pcperipherals.com>
claganga (Computer)
1 Apr 04 16:03
Windows is just as simple, just need to know the tricks ;) ... Actually you can't direct interface to the hardware via an application (ring 3 code). However you can treat any port like a stream device.
字串2
nbucska (Electrical)
1 Apr 04 16:12
claganga: Reading Chinese is simple, too, after you learn a few thousand symbols...
<nbucska@pcperipherals.com>
claganga (Computer)
2 Apr 04 11:26
nbucska: I guess I can't argue with that.
faraznasim: Humm what exactly would like to write to a serial port, I'll give you a windows example if you want.
Yster (Computer)
20 Aug 04 4:36
Opening a serial port is done in a very illogical way: you have to make a call to CreateFile(), ReadFile(), and WriteFile() functions with the COM port specified as a string value, i.e. "COM1" or "COM2", etc. You can find good code examples on how to do this on www.codeproject.com. I think it should have been functions with names such as OpenDevice(), SendDeviceData(), and ReadDeviceData(), but what do I know. 字串1
Once you have opened the port, it's as simple as transmitting (WriteFile()) and receiving (ReadFile()) bytes.
Also take a look at the SetCommTimeouts() and SetCommState() functions, with the relevant COMMTIMEOUTS and DCB data structures as input. The MSDN library gives you all the help you'll need on these topics, and its available online as well.
Hope this helped.
richs (Computer)
20 Aug 04 18:04
Hi-
The C programming enviornment for a 'nix machine is much easier than going through much rigamarole in the windows enviornment.
If you feel comfortable going into say the Linux land, you will find all sorts of tools that will assist you in playing with I/O.
I might recommend the following link:
http://www.linuxdocs.org/HOWTOs/mini/IO-Port-Programming-6.html#ss6.1
as a rather painless introduction to the subject.
Cheers, 字串5
Rich S.
hdingman (Computer)
24 Aug 04 0:43
Since you mention "an LED," and a parallel port, I assume you're tinkering with physical hardware. As of NT4 and 98SE, Windows added a Virtual Device Manager layer in the executive between programs and hardware. It's much more difficult to bit-bang to physical hardware than before. I/O instructions like "in" and "out" no longer write directly to the port. It WAS a lot easier in the DOS days.
Some things are fairly straightforward, like getting to RTS/CTS and DSR/DTR bits on a serial port via the MSCOMM.DLL package. Just don't expect reliable real-time performance when you do. You can blink and read Morse Code, for example, but don't think you'll be able to bit-blast a 100kHz burst pattern for X10 emulation accurately at zero-crossing through most Windows tools.
If you're just trying to print something to a parallel port, just open the printer as a stream i/o device and "printf" to it. If you want to light a couple of LED's, I'd suggest putting them on the serial port (or just watch the lights on an external modem.) For much beyond that, get an I/O board with a Mfgr's driver interface to C, or get ready to write your own replacement port driver, a task NOT for newbies. 字串1
Howrd
purpen (Computer)
3 Dec 04 9:06
A very useful page for this kind of thing is http://www.lvr.com/
The direct page for parallel ports is http://www.lvr.com/parport.htm
See the section on windows drivers that can be used to allow direct IO on windows, some are free, some are commercial, but it may help your problem.
Cheers
B
(Click:)
|