471,354 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Serial Port Problems

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
3 16330
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
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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Swatcat | last post: by
13 posts views Thread by Al the programmer | last post: by
1 post views Thread by David | last post: by
38 posts views Thread by shussai2 | last post: by
7 posts views Thread by davetelling | last post: by
2 posts views Thread by joaquimfpinto | last post: by
3 posts views Thread by naveen.sabapathy | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.