LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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
 
LinkBack Search this Thread
Old 01-25-2012, 12:22 AM   #1
quandJe
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Rep: Reputation: Disabled
Interfacing Web with CGI script for parallel port control (program)


I am a newbie here.

I try to control parallel port with php. I wrote C code to control parallel port and using system function of php to run that c program.
I am using winXP pro, running Apache.

When I try to run my C program in cmd, it works perfectly. But when I run that program from webpage, it run that C program, but nothing happen to parallel port.

Here is my C program test2.exe:
Code:

#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include<stdlib.h>

/********************************************/
/*This program set the parallel port outputs*/
/********************************************/

int main (int argc, char *argv[])
{
int value;

value=atoi(argv[1]);
outportb(0x378,value); /* output the data to parallel port */
printf(" this is what %s",argv[1]);
printf("this is value %d",value);
return 123; /* wait for keypress before exiting */
}

And here is my php program:
PHP Code:
<?php

if (isset($_POST['up']))
{
system("test2 255");
system("test2 255");

}
if (isset($_POST['right']))
{
system("test2 128");
system("test2 128");
}
if (isset($_POST['down']))
{
system("test2 64");
system("test2 64");
system("test2 64");
system("test2 64");
}
if (isset($_POST['left']))
{
system("test1 0");

}
?>
<HTML>
<HEAD><TITLE>webcam controls</TITLE></HEAD>
<BODY>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<INPUT type='submit' name='up' value="up">

<INPUT type='submit' name='right' value='Right'>

<INPUT type='submit' name='left' value='Left'>

<INPUT type='submit' name='down' value='Down'>

</form></body></html>
For any button i press, it just show this is what 255, this is value 255 (for up button ). But parallel port output don't change anything. If i go to that path from cmd prompt and run test2 255, parallel port output changed.

Last edited by quandJe; 01-25-2012 at 01:19 AM.
 
Old 01-25-2012, 01:20 AM   #2
quandJe
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
I would love to know how I could make my program also output to the PHP script any book, video
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parallel port interfacing ochienged Programming 1 02-06-2009 12:34 PM
Interfacing parallel port with Gambas fos Programming 6 06-17-2008 10:14 AM
interfacing using parallel port divu Programming 1 04-13-2006 08:39 AM
Parallel port/i2c interfacing question Mike Davies Linux - Hardware 0 10-01-2005 08:45 AM
interfacing using perl(parallel port) teao Programming 1 07-29-2003 03:47 AM


All times are GMT -5. The time now is 03:43 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration