my company puts RFID chips into our guitars, and i wrote a php script to read from the serial port when the guitar is scanned in the RFID and toss it into a database.
but the strangest thing is happening...
here's the code:
$set_mode = "MODE COM1 BAUD=4800 PARITY=N DATA=8 STOP=1 TO=OFF";
$output = array();
exec($set_mode, $output, $result);
print_r($output);
switch ($result) {
case 0 :
break;
default :
print("error setting parameters");
exit;
}
$filehandle = fopen("COM1", "rb");
if(!$filehandle) {
print("error opening com1");
exit;
} else {
$ch = fgetc($filehandle);
print($ch);
}
exit;
This code works, but only after I open hyperterminal and connect, then disconnect, to com1 with the term.
after I've done so, it remains working every time I load the
script.
When the computer is rebooted, it will reset and the script will not
work again... however "error opening com1" never prints...
neither does "error setting parameters"
so it seems to be opening the port ok.. just not reading from it.
then I'll open hyperterm, connect to com1, then disconnect,
and the script works great and reads the data....
same thing again... when i reboot... the script can't be used
until i hyperterm first.
is there some sort of initialization that hyperterm does... or that
i can do to be able to run this without connecting with hyperterm first? I tried this on several different machines and found the
same problem on all of them.
please help.
thanks.