By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Serial Port Problems

P: n/a
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
Jul 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Thanks for the idea. I would appreciate it if you could post your
changes (or email them to me at blaineATblainehilton.com). I was
reading the documentatiion and see that you can turn on or off
hardware handshaking, but didn't see mention of software handshaking,
which I require. Also does your version then interface with PHP? I
didn't see mention of PHP in the docs.

--
Thanks again
Blaine Hilton
http://www.webcalc.net/
On Mon, 04 Aug 2003 08:08:36 +1200, Jochen Daum
<jo*********@cans.co.nz> wrote:
On Fri, 01 Aug 2003 22:46:03 GMT, Blaine HIlton
<bl***************@verizon.net> wrote:
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.


Hmm. I spent a lot of time with serproxy and fopen in the last two
weeks and I'm greatly dissappointed. I couldn't manage to let it run
in the background (which might be a lack of unix skills), but the main
problem were the php socket functions. They don't seem to be very
reliable (also have a look at bug reports) and there seems to be no
function, that polls the serial port and doesn't hang, if there's no
data. Ergo, you're buggered.

Instead I stripped down SMSTools

http://www.isis.de/members/~s.frings/

to a tool that sends only an AT command to the serial port with a
timeout. That worked much better. I can post it to you, if you want.

HTH, Jochen


Jul 16 '05 #2

P: n/a
Hi Blaine!

On Sun, 03 Aug 2003 22:20:20 GMT, Blaine HIlton
<bl***************@verizon.net> wrote:
Thanks for the idea. I would appreciate it if you could post your
changes (or email them to me at blaineATblainehilton.com). I was
reading the documentatiion and see that you can turn on or off
hardware handshaking, but didn't see mention of software handshaking,
which I require. Also does your version then interface with PHP? I
didn't see mention of PHP in the docs.


I just call the program I build with shell_exec(), works fine. I'll
send the zip to you and anyone who's interested.

Jochen

--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 16 '05 #3

P: 1

This discussion thread is closed

Replies have been disabled for this discussion.