The command to set modem line signals is modem. The modem line signals that can be controlled by this command are RTS and DTR, and both signals can be set simultaneously or individually.
"set modem (signal)"
Enter a two digit binary number in signal.
The first digit indicates the value of the RTS signal, and the second digit indicates the value of the DTR signal.
A value of 0 indicates an active state, and a value of 1 indicates an inactive state.
Value | RTS state | DTR state |
---|---|---|
00 | active | active |
01 | active | inactive |
10 | inactive | active |
11 | inactive | 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);
?>
"set modem rts (rts signal)"
"set modem dtr (dtr signal)"
Input 1 digit of binary in signal.
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 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
?>
※ Note: The setting modem line signal ("set modem") and hardware flow control (RTS / CTS) can not be used at the same time.