Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Parapi libraries usage

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
User avatar
spector
Posts: 21
Joined: 2006-04-17 16:11

Parapi libraries usage

#1 Post by spector »

I'm tying to use the parapin libraries to control my parallel port.

When i try to run this code:

Code: Select all

#include <parapin.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(){

int w,k;

w = pin_init_user(LPT1);

printf("driver init %d  \n",w);

pin_output_mode(LP_PIN14);

clear_pin(LP_PIN14);     /*this should put the pin to 0 */

printf("Pin 14 is %s!\n", pin_is_set(LP_PIN14));  /*this should print the state of the pin*/

scanf("%d",&w);   /*this is just for  mke the system wait a command, for debugging */

change_pin(LP_PIN14,LP_SET); /*this should prot the pin from 0 to 1 */
printf("Pin 14 is %s \n",pin_is_set(LP_PIN14)); 
}
I obtain this output

Code: Select all


driver init 0
Pin 14 is (null)!
d
Pin 14 is (null)

The output of pin_init_user is ok, but the two NULL are not ok.

I've also tried to use a tester to verify the output of the program and effecivly nothing change.

I do not know how to solve this...

Thanks

Spector

greenhat
Posts: 170
Joined: 2006-06-03 17:32

#2 Post by greenhat »

Your post re parapin was of interest because a few years ago I played around with the parallel port interface using QBASIC in windows. Managed to get LEDs to blink on and off :) but that's about it.

I looked into this parapin a bit at sourceforge.net and the section "Polling Pins" says
int pin_is_set(int pins);

Pins may only be queried if:

* They are permanent input pins (Pins 10, 11, 12, 13, and 15), as described in Section 2, or
* They are bidirectional pins previously configured as input pins, as described in Section 6.

Any query to an output pin will always return a value indicating that the pin is clear. In other words, this function can not be used to determine what value was previously asserted to an output pin.
So if i'm reading that right, your printf statements with pin_is_set won't work since Pin 14 is an output pin. Don't know a solution other than toggle the output and sense its state independently with a voltmeter, LED or something.

User avatar
spector
Posts: 21
Joined: 2006-04-17 16:11

#3 Post by spector »

As I knew pin 14 should be a bidirectional pin...

But I have tried now with pin 10 with the same result.

But, probably I did not understand, an output pins means that i can change it's state from the software and see the result on my tester; and an input pin means that if I give a voltage to that pin i can see it on my computer..

I do not know if it is clear =)

I think that input and output are gived from the PC point of view, so input means from "reality" to the PC, and output means from th PC to the "reality"...

Please correct me if it is wrong, and excuse my complicated explanations and incorrect english...

Thanks

greenhat
Posts: 170
Joined: 2006-06-03 17:32

#4 Post by greenhat »

OK, I think I see what you mean. You are changing the state of Pin 14 with the parapin software but your tester shows nothing. In this case it wouldn't matter whether the printf code was correct or not, as the tester should register the change of state.

I searched the debian repos but couldn't find a parapin package so I assume you compiled it from source. If this is a new install, maybe you could verify that it's working by copy/pasting one of the examples on sourceforge.net page and see if results make sense. Like just poll/print-out the state of all the input pins as a kind of sanity check.

There is an email users group here http://sourceforge.net/mailarchive/foru ... m_id=42610 that might help, though the activity there is low :(

Just for info, my port won't even function in linux unless I change in BIOS ECP to EPP in Parallel Port Settings.

Post Reply