Modem Line Signal


The command to check the modem line signal is modem.

There are 6 signals, which can be checked at once or individually.

Simultaneous checking

"get modem"

In this case, the return value is a string of 6 digits in binary form, with the following meanings for each digit:

(RI)(CTS)(RTS)(DSR)(DTR)(CD)

A value of 0 indicates an active state, and a value of 1 indicates an inactive state.

<?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);
?>

Individual checking

"get modem (signal)"

In this case, specify the name of the signal to check on signal.

Signal Description
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
?>