确认调制解调器线路信号的命令是modem.
总共6个信号可同时或分别进行确认。
"get modem"
此情况中返还值是6位2进制形态的字符串,对各个位置的意义如下。
(RI)(CTS)(RTS)(DSR)(DTR)(CD)
0指active的状态,1指inactive状态。
<?php
include "/lib/sd_spc.php";
$sid = 14;
spc_reset();
spc_sync_baud(115200);
spc_request_dev($sid, "set uart 115200N81");
spc_request_dev($sid, "set modem 11"); // RTS & DTR: active
echo spc_request_dev($sid, "get modem"), "\r\n"; // output(e.g.): 111111
sleep(1);
spc_request_dev($sid, "set modem 00"); // RTS & DTR: inactive
echo spc_request_dev($sid, "get modem"), "\r\n"; // output(e.g.): 110101
sleep(1);
?>
"get modem (signal)"
此情况在signal上输入要确认的信号。
信号名称 | 说明 |
---|---|
ri | Ring Indicator |
cts | Clear To Send |
rts | Request To Send |
dsr | Data Set Ready |
dtr | Data Terminal Ready |
cd | Carrier Detect |
<?php
include "/lib/sd_spc.php";
$sid = 14;
spc_reset();
spc_sync_baud(115200);
spc_request_dev($sid, "set uart 115200N81");
spc_request_dev($sid, "set modem rts 1"); // RTS: active
echo spc_request_dev($sid, "get modem rts"), "\r\n"; // output(e.g.): 1
sleep(1);
spc_request_dev($sid, "set modem dtr 1"); // DTR: active
echo spc_request_dev($sid, "get modem dtr"); // output(e.g.): 1
?>