A baffling end to my week! I open my serial port on my Debian PC (Debian version 5.0.1) I have a decent Null Modem lead going to another PC (I'll call it PC#2), with its port open with the same parameters. I send a series of bytes from the Debian PC which comes through, no problem.
I reply from PC#2, but the read buffer of the Debian PC's port shows nothing. What's more, the message gets sent directly back to the PC#2, with certain bytes getting changed. (I'm guessing its just invalid ascii codes that get changed, e.g. 0x02 always gets changed to 0x5e 0x42, which is ^B. Displayable bytes don't get changed.)
I've tried changing the Flow control method but that hasn't helped.
I'm using php_serial.class.php, from
http://www.phpclasses.org/browse/package/3679.html. It is a highly rated class and I'm guessing its not to blame.
My code is a very slight modification of the example that comes with the class (modifying just so it keeps reading any messages for a number of seconds):
-
include "php_serial.class.php";
-
$serial = new phpSerial;
-
-
$serial->deviceSet("COM1");
-
-
// We can change the baud rate
-
$serial->confBaudRate(9600);
-
$serial->confCharacterLength(8);
-
$serial->confStopBits(1);
-
$serial->confParity("none");
-
-
//$serial->confFlowControl ("none");
-
// Then we need to open it
-
$serial->deviceOpen();
-
-
$serial->sendMessage(chr(0xff).chr(0x02).chr(0x4B)); // Sends with no problem
-
-
do{
-
// Or to read from
-
$read = $serial->readPort();
-
echo $read;
-
$pause1 += 0.01;
-
} while (empty($read) && $pause1 < 99999);
-
// Read never becomes non-empty whatever I send back from other PC within this time
-
-
$serial->deviceClose();
-
If anyone has a strong hunch about why I'm getting this problem, or any thing helpful to say, thank you very much.