473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

read from parallel port

3
Hi all
I need to write a program in C that reads 4 switches from the parallel port and display their status.
All the program does is display:
switch 1 is ON
switch 2 is OFF
switch 3 ...
The program is to run in linux kernel version 2.6

I started writing the program for one switch connected to the pin D0 of the parallel port, but i get a sigmentation failure message.

#include <stdio.h>
#include <stdlib.h>
#include <sys/io.h>

#define base 0x378
#define D0 0x01

int main (void)
{
if (inb(base & D0)
printf("Switch 1: ON");
else
printf("Switch 1: OFF");

return (0);
}


can anyone help me with the code?

thanks
Oct 27 '07 #1
3 2852
weaknessforcats
9,208 Expert Mod 8TB
You are missing a parenthesis in your if statement. What does the inb() function do? I've not seen that before.
Oct 27 '07 #2
Fa6om
3
Inb() function is to read the input from a parallel port

Pin D0 of the parallel port is connected to a switch. When the switch is ON (set to 1) I want the program to read ( 00000001 = 0x01 ) from the parallel port and display a message that switch 1 is on. For the second switch, it's connected to pin D1 and the program will read ( 00000010 = 0x02 ) and display the output message. And so on....

I may not use Inb() function in the right format, as you mentioned it's missing a parameter, can you please correct me?

thanks a lot for you're help.
Oct 27 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Sorry, but I've not used that function. It looks like Linux and I am a Windows person.

I did a Google on inb containing the words parallel and port and got 10,800 web pages. You will have to go it yourself from here.

That is, unless anyone else can help further.
Oct 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Novice Experl | last post by:
I'd like to write a simple application that interfaces with the parallel port, and changes the data on it according to keyboard input. I hope I can get it to run under windows xp and / or windows...
6
by: Peter | last post by:
I'm interested to know what ideas are out there for reading a parallel port at a constant sample rate while still allowing the user to interact with the GUI. That is, reading it every 10ms for...
11
by: Isaac T Alston | last post by:
Basically, I'm thinking about building a robot which can be controlled by programs which I write, I'm going to interface to the robot through the parallel port (like in this tutorial here:...
12
by: david.brown.0 | last post by:
I'm trying to make a Java program access a parallel port. Java's comm API does not provide me with the control I need. I need to be able to write to the data and control pins and read the status...
11
by: Timothy Smith | last post by:
hello people. i've been trying to send an 8 byte string to my parallel port under freebsd. the purpose is it to control a relay board. the board simply responds to the output byte coming from...
6
by: abhi | last post by:
Hello, I want to create a small project which will display scrolling text on LED that will be attached to Parallel port. I want to create this project in C language(possibly in Mingw) on Windows...
1
by: HardySpicer | last post by:
I have a laptop which has no Parallel port so I bought a USB to parallel port convertor. When I write to the virtual parallel port it doesn't respond (I can get a real port to work on a normal pc)....
2
by: hari | last post by:
Hi all, I need to automate printer command testing, prinetr supports parallel/ serial/USB.How can i send the commands from python to printer. I have got pyparallel, as am new to python, no...
4
by: Soren | last post by:
Hi, I want to control some motors using the parallel port.. however, my laptop does not have any parallel ports (very few do). What I do have is a USB->Parallel converter... I thought about...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.