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.
|