Results 1 to 4 of 4
Thread: -
Hybrid View
-
8th September 2007 11:42 #1
-
- .
:
1 - :
DSL Linux, 2.4 , XAMPP "--enable-dio", php.ini e . . /dev/ttyS0 e 666 rw- rw- rw-. :
echo "12345" > /dev/ttyS0
:
cat /proc/tty/drivers/serial
tx 5 rx 5 .
, . , . :
cat /proc/tty/drivers/serial
tx rx .
1 - :
Decian Linux, 2.6 , XAMPP ( ) "--enable-dio", php.ini e . . /dev/ttyS0 e 666 rw- rw- rw-. :
echo "12345" > /dev/ttyS0
:
cat /proc/tty/drivers/serial
tx rx , 0.
, "12" ( ) :
Writing ...
4 bytes written.
Try to read ...Read miss...
Read miss...
Read miss...
Read miss...
Read miss...
Read miss...
, !!! :
cat /proc/tty/drivers/serial
tx rx , 0.
dio. , UPS-. , . .
:
-
-
-
e :
http://www.karatebulgaria.com/alex/
Code:<?php if(!empty($_POST['command_text'])) { $dio_file_name = "/dev/ttyS0"; $dio_file_desc = dio_open($dio_file_name, O_RDWR);//O_CREAT | O_APPEND, O_WRONLY); dio_tcsetattr($dio_file_desc, array("baud" => 9600, "bits" => 7, "stop" => 2, "parity" => 2)); $text = $_POST['command_text']."*".chr(13); $write_num = dio_write($dio_file_desc, $text); echo "Writing ...<br>";echo "".$write_num." bytes written.<br>"; dio_close($dio_file_desc); sleep(1); echo "Try to read ..."; $dio_file_desc = dio_open($dio_file_name, O_RDWR | O_NOCTTY | O_NONBLOCK); # $dio_file_desc = dio_open($dio_file_name, O_NONBLOCK, O_RDONLY); dio_tcsetattr($dio_file_desc, array("baud" => 9600, "bits" => 7, "stop" => 2, "parity" => 2)); $read_miss_counter = 0; while(($dio_read = dio_read($dio_file_desc, 1)) != chr(13)) { if($dio_read == "") { $read_miss_counter++; if($read_miss_counter == 20) { break; } else { echo "Read miss...<br>"; # sleep(1); } } else { echo "Read \"".$dio_read."\"<br>"; } } dio_close($dio_file_desc); } else { ?> <form method = "post"> ( ): <input type = 'text' name = 'command_text' maxlength= '131' value = ""> <input type = "submit" name = "submit_button" value = "Go!"> </form> <?php } ?>Last edited by a_panov; 8th September 2007 at 12:52. Reason:
-
8th September 2007 21:38 #2Registered User
Join Date: Jul:2006
Location:
Posts: 480
PHP ? The wrong tool for the job. .
-
8th September 2007 22:28 #3
C++ - CGI (WEB , ),

@a_panov, , , . dio_tcsetattr() dio, tcsetattr(3) tcflush(3) TCIFLUSH, loopback- dio_read(). dio_close(), dio_open() dio_tcsetattr(). , .. , - , .
(), (IRQ, I/O ..). setserial ( ) , ..Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others
-
9th September 2007 18:49 #4
. .
dio_write dio_read '' Php.net .
- , LF dio_Read :Code:<?php if(!empty($_POST['command_text'])) { $dio_file_name = "/dev/ttyS0"; /* */ exec("stty 9600 parenb -parodd cs7 cstopb cread clocal -crtscts -ixon -ixoff -echo icanon -F /dev/ttyS0"); $dio_file_desc = dio_open($dio_file_name, O_RDWR | O_NDELAY | O_NOCTTY); dio_fcntl($dio_file_desc, F_SETFL, 0); $text = $_POST['command_text']."*".chr(13); $write_num = dio_write($dio_file_desc, $text); echo "Writing ...<br>";echo "".$write_num." bytes written.<br>"; echo "Try to read ...<br>"; $dio_read1 = dio_read($dio_file_desc, 256); echo "Read: ".$dio_read1; dio_close($dio_file_desc); } else { ?> <form method = "post"> Enter Command: <input type = 'text' name = 'command_text' maxlength= '131' value = ""> <input type = "submit" name = "submit_button" value = "Go!"> </form> <?php } ?>
spec. char , 2- , php dio , ... - ... , php .. .Code:<?php if(!empty($_POST['command_text'])) { $dio_file_name = "/dev/ttyS0"; exec("stty 9600 parenb -parodd cs7 cstopb cread clocal -crtscts -ixon -ixoff -echo raw -F /dev/ttyS0"); $dio_file_desc = dio_open($dio_file_name, O_RDWR | O_NDELAY | O_NOCTTY); dio_fcntl($dio_file_desc, F_SETFL, 0); $text = $_POST['command_text']."*".chr(13); $write_num = dio_write($dio_file_desc, $text); echo "Writing ...<br>";echo "".$write_num." bytes written.<br>"; echo "Try to read ...<br>"; /* LF dio_read */ dio_write($dio_file_desc,"\x41",1); $dio_read1 = dio_read($dio_file_desc, 256); echo "Read: ".$dio_read1; dio_close($dio_file_desc); } else { ?> <form method = "post"> Enter Command: <input type = 'text' name = 'command_text' maxlength= '131' value = ""> <input type = "submit" name = "submit_button" value = "Go!"> </form> <?php } ?>
"" -> \0 , , , , , ...

. exec() . , .




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in