LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-02-2004, 07:42 AM   #1
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Rep: Reputation: 15
Unhappy Programming using digital I/O connector


Hello.
I have a simple question in LINUX programming.
I am programming in C under LINUX and I need to send a signal to digital I/O
connector to turn on or off (1 or 0). I have never programmed using hardware
and have no idea how to send such signals.
After some searchings I have found some similar commands ioperm and outb, they work well but their range of ports doesnot include the ports I need (0x442 for instance).
Could You please suggest me a direction, or maybe piece of code?
If the only option is to make assembler code and include it in my program, please give me example of code in assembler and how to include it in c because I have never worked with it.
Thanks in Advance,
Leonid
 
Old 12-02-2004, 11:45 AM   #2
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
basically i think you use the API provided by the cards driver
 
Old 12-02-2004, 07:23 PM   #3
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Rep: Reputation: 31
So if y our saying the port is mapped at address 0x442, then you should write to that address a byte with the approiate bit set.
 
Old 12-05-2004, 01:24 AM   #4
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Original Poster
Rep: Reputation: 15
Dave,
You are right,
The question is that I have never done it, not in C nor assembler, so what I need is just a simple advise or piece of code how can I write to that address,
Thanks
 
Old 12-05-2004, 10:26 AM   #5
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
Sir,
I haven't done inp/outp since DOS days, however I'm seriously interested in your digital IO project board for something I want to do. Could you please tell us what digital IO board you are using and where to buy it so I can get one. I'll certainly be able to help you with the software part when I get my own and try it out.

Thanks in advance for the info.
 
Old 12-05-2004, 10:45 AM   #6
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Rep: Reputation: 31
This is totally untested on my linux box but is something I did several years ago on a unix like OS.

I had bought a card that would allow me to utilize the unused printer port on my computer. It did this by turning on a hardware switch that would run a motor.

Psudo code might look something like this
Code:
#define	bit0	0
#define bit1	1
#define bit2	2
#define bit3	4
#define etc	xxxx

	path = open("printer"); //path to device
	write(path, bit3;       //turn on device

	sleep(4);               //wait til device does something
	write(path, bit0);      //turn off device
In essence you are turning on and off bits.
 
Old 12-06-2004, 12:57 AM   #7
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Original Poster
Rep: Reputation: 15
Dave,
The code You propose is right and should work in case You know the device and it is in /dev directory. I need to run a command similar to open(...) but instead the devise to write port address (0x442 like I mentioned) which I want to open and to right bits in it.
Thanks
 
Old 12-06-2004, 01:06 AM   #8
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Original Poster
Rep: Reputation: 15
Dear randyding,
I am not sure which information do You need, I will give You all I know about my motherboard. It is MB820, Socket 478 Pentium4, Intel 875P Chipset, Industrial Motherboard. The motherboard has digital I/O which includes 4 in 4 out ports.
Please tell me If You need more information I can look for it in users manual of the MB.
Anyway thanks in advance for any help
 
Old 12-06-2004, 01:13 AM   #9
shy
Member
 
Registered: Dec 2002
Location: Russia
Distribution: ASP linux
Posts: 94

Rep: Reputation: 15
Leonid,
If your digital I/O device doesn't have a kernel module supporting it, I think you have to write your own. I think it wouldn't be an easy task if you have never done it before. Anyway, it you decide to do it, try to read the great book Linux device drivers.
 
Old 12-06-2004, 01:56 AM   #10
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Original Poster
Rep: Reputation: 15
Shy,
It sounds pretty strange, the problem is that I am a programmer with specializations in image processing, working for a small start-up, and there is only one issue connected to hardware. We have a lamp connected to digital I/O and during the run of my program I should to tell the lamp when to turn on or off. It is really a bad idea that for such small task I will have to read books about drivers.
I know the port number of the I/O. Shouldn't it be just sending signal to the port?
Maybe You have a simpler idea, like a command, assembly code, connecting the lamp to another place (or even lighting it manually ) but not spending days (or even weeks) on a task that I believe should be nothing for hardware people.
Thanks
 
Old 12-06-2004, 02:00 AM   #11
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Original Poster
Rep: Reputation: 15
Shy,
How can I check whether my I/O has a kernel module?
Should it be in the /dev directory and with what name?
Thanks
 
Old 12-06-2004, 02:29 AM   #12
shy
Member
 
Registered: Dec 2002
Location: Russia
Distribution: ASP linux
Posts: 94

Rep: Reputation: 15
Well, what is this 'digital I/O'? Does it use some standard interface (say, like serial port)? If so, kernel should defenitely have some piece of code to handle this, but I can not say right now what exactly because I have never had an experience working with 'digital I/O' if it's a separate (possibly new?) standard (like, say, usb or serial/parallel ports).
 
Old 12-06-2004, 02:45 AM   #13
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Original Poster
Rep: Reputation: 15
Shy,
It is like parallel port for printer for example. I have succeeded to connect the printer port using commands ioperm, inb, outb and the direct port number. The problem is that that commands don't support port addresses more than 0x3ff and my digital I/O address is 0x442, so I wonder if there is a command that is similar to outb() and will support that address. Regarding the interfaces I am not sure what does it use, but if You could tell me how to check it I would be glad to understand it more. All I have is motherboard manual that says the addresses of the digital I/O and a lamp connected to, that was never lighted there. As I mentioned if I connect it to 0x378 (which is printer port) everything works fine, but it is a really bad idea to use printer's port.
 
Old 12-06-2004, 04:34 PM   #14
Dave Kelly
Member
 
Registered: Aug 2004
Location: Todd Mission Texas
Distribution: Linspire
Posts: 215

Rep: Reputation: 31
Quote:
Originally posted by leonidg
Dave,
The code You propose is right and should work in case You know the device and it is in /dev directory. I need to run a command similar to open(...) but instead the devise to write port address (0x442 like I mentioned) which I want to open and to right bits in it.
Thanks
I'm not sure what you are saying. What is stopping you from writing to address 0x442?

Also what tells you that it is mapped to that address?
 
Old 12-07-2004, 01:31 AM   #15
leonidg
Member
 
Registered: Dec 2004
Posts: 73

Original Poster
Rep: Reputation: 15
Dave,
The problem is that I don't know commands to write to desired address except the outb() command, which works well for 0x378 but doesn't work for 0x442. The 0x442 comes from MB manual I believe, my boss found it.
Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
jk connector nasht Linux - Software 2 08-18-2005 07:33 PM
Enable digital output for digital speakers? alphster Linux - Hardware 5 12-26-2004 10:56 PM
Programming using digital I/O connector leonidg Programming 0 12-02-2004 08:43 AM
Digital Camera and usb connector on Mandrake 10 kobica Linux - Hardware 1 08-03-2004 01:56 AM
SIS7012 with a 5.1 dolby digital (Surround) connector Thoas Linux - Hardware 3 04-03-2003 05:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration