spc_request_dev($sid, $cmd);
명령어 구조는 다음과 같습니다.
"get $port output"
정상적인 반환 값은 문자열 형태로써 다음과 같습니다.
반환 값 | 설명 |
---|---|
0 | OFF |
1 | ON |
<?php
include "/lib/sd_spc.php";
spc_reset();
spc_sync_baud();
$sid = 1;
echo "turn all output ports on\r\n";
spc_request_dev($sid, "set 0 output high");
spc_request_dev($sid, "set 1 output high");
spc_request_dev($sid, "set 2 output high");
spc_request_dev($sid, "set 3 output high");
// get status of output ports
echo "Port 0: ", spc_request_dev($sid, "get 0 output"), "\r\n";
echo "Port 1: ", spc_request_dev($sid, "get 1 output"), "\r\n";
echo "Port 2: ", spc_request_dev($sid, "get 2 output"), "\r\n";
echo "Port 3: ", spc_request_dev($sid, "get 3 output"), "\r\n";
sleep(1);
echo "turn all output ports off\r\n";
spc_request_dev($sid, "set 0 output low");
spc_request_dev($sid, "set 1 output low");
spc_request_dev($sid, "set 2 output low");
spc_request_dev($sid, "set 3 output low");
// get status of output ports
echo "Port 0: ", spc_request_dev($sid, "get 0 output"), "\r\n";
echo "Port 1: ", spc_request_dev($sid, "get 1 output"), "\r\n";
echo "Port 2: ", spc_request_dev($sid, "get 2 output"), "\r\n";
echo "Port 3: ", spc_request_dev($sid, "get 3 output"), "\r\n"
?>
turn all output ports on
Port 0: 1
Port 1: 1
Port 2: 1
Port 3: 1
turn all output ports off
Port 0: 0
Port 1: 0
Port 2: 0
Port 3: 0