I'm trying to send data over the serial port using PHP and Serproxy.
I downloaded Serproxy from
http://www.lspace.nildram.co.uk/freeware.html. From the manual page at
http://www.php.net/function.fopen I was able to find sample code using
Serproxy and directly opening the serial port. My application
requires the use of multiple serial ports on other computers so I'm
left with only Serproxy.
The code I am using is"
$fp = fsockopen ("192.168.0.20" , 5331, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)";
} else {
$e = chr(27);
$string = 'string text here';
echo $string;
fputs ($fp, $string );
fclose ($fp);
}
I am able to run the program fine and I see the connection being
displayed on the Serproxy display, however then it fills the buffer on
the RS232 link and the whole string is not transferred over. I
believe what is missing is some type of code that sets the xon to on.
For instance using fopens the line is:
`mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
$fp = fopen ("COM1:", "w+");
Is there anyway to turn xon ON using PHP and Serproxy, or another
solution?
Another thought that just came to me is in the sample code they put $e
throughout the string, which is an escape character, perhaps using
that before the buffer fills up?
--
Thanks in advance
Blaine Hilton
I downloaded Serproxy from
http://www.lspace.nildram.co.uk/freeware.html. From the manual page at
http://www.php.net/function.fopen I was able to find sample code using
Serproxy and directly opening the serial port. My application
requires the use of multiple serial ports on other computers so I'm
left with only Serproxy.
The code I am using is"
$fp = fsockopen ("192.168.0.20" , 5331, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)";
} else {
$e = chr(27);
$string = 'string text here';
echo $string;
fputs ($fp, $string );
fclose ($fp);
}
I am able to run the program fine and I see the connection being
displayed on the Serproxy display, however then it fills the buffer on
the RS232 link and the whole string is not transferred over. I
believe what is missing is some type of code that sets the xon to on.
For instance using fopens the line is:
`mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
$fp = fopen ("COM1:", "w+");
Is there anyway to turn xon ON using PHP and Serproxy, or another
solution?
Another thought that just came to me is in the sample code they put $e
throughout the string, which is an escape character, perhaps using
that before the buffer fills up?
--
Thanks in advance
Blaine Hilton
Comment