0
\$\begingroup\$

I have USB to 25pin Logilink cable. I connect it with computer with Linux and get a port in /dev/usb/lp0. When I connect LED with pin 1 and 25 as +/- of LED it lights. Now I move + pin of LED to pin2 (data0) pin. I want to send byte so that if can switch on it. I wrote a simple program where I use outb(0xff,port) being port 0x378. Program compiles and runs first time but LED does not light. Next time program even does not execute and seems to be halted.

Can I find some C program in Linux to do that?

\$\endgroup\$
  • \$\begingroup\$ This is more of a linux question. If you're on ubuntu, try askubuntu.com. \$\endgroup\$ – user17592 Jan 7 '13 at 12:33
  • 2
    \$\begingroup\$ askubuntu is not going to help you with an advanced question like this. My guess is unix.stackexchange.com or stackoverflow.com. \$\endgroup\$ – jippie Jan 7 '13 at 12:48
  • \$\begingroup\$ What user is running the program? \$\endgroup\$ – jippie Jan 7 '13 at 12:48
  • \$\begingroup\$ I use c in linux. code chunk is as:main(){ int port=0x378; outb(0xff,port);sleep(1); printf("End");} I compiles and run successfully and I get text "End" at console but LED does not light even though I change + pin of LED. \$\endgroup\$ – user17651 Jan 7 '13 at 13:21
  • \$\begingroup\$ This is not really a linux question, since the problem would be there on any OS. Rather, it's a computer architecture question - modern "express train" I/O architectures don't work well when asked to shuttle between "local" sidings. While the question as asked might have been borderline, a working answer would be squarely in the territory of what we do here. \$\endgroup\$ – Chris Stratton Jan 7 '13 at 16:38
3
\$\begingroup\$

You are trying to use a direct I/O write with something that is not an I/O mapped device. This would be completely unworkable, except when trapped by operating system protection (or virtualization) mechanisms and proxied to the more distantly connected hardware. However, that is not the real problem which you face.

More problematically, most USB-printer adapters are not statically addressable as GPIOs in the manner that local bus parallel ports were, even if you write a custom USB driver for them. You may be able to gain control of the control signals, but probably not set values on the data pins the way many became used to doing.

You'd be better off with a more generic USB I/O device, either based on a general purpose microcontroller or something intended for GPIO usage such as an FT245.

However, this will have higher latency, so for anything timing critical your options generally are either switching to an "old computer" with a real parallel port, or else offloading the entire timing critical subsystem to an external microcontroller, and making higher level requests over the USB for it to accomplish complete tasks, rather than simply to set this line or that line to a level.

\$\endgroup\$
1
\$\begingroup\$

The port 0x378 refers to the old style printer port(DOS era). I expect your program is driving the old printer port. This sort of low level driving is not applicable when using USB.

I can understand why you tried this, However (printer) drivers do the redirection and handle this type of "Historic" interface.

For this to work you need an old PC with a printer port or a plug in printer port card (ISA / EISA / PCI)... I would not recormend this going forward but would use USB to Digital I/O instead (for example FTDI )

\$\endgroup\$
  • \$\begingroup\$ I am using Linux. When I connect USB to 25 Parallel port cable D-SUB cable, I get a port /dev/sub/lp0 I open it for reading writing. Can you please tell me then what address I can use for this lp0 port in Linux in a program like above? That would be great instead of switching to old computer. \$\endgroup\$ – user17651 Jan 7 '13 at 13:50
  • \$\begingroup\$ See @Chris Stratton answer as it expresses the details of ports and USB related IO better . \$\endgroup\$ – Spoon Jan 7 '13 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.