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.clas s.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):
Expand|Select|Wrap|Line Numbers
- 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();