Skip to content

Commit 8c22065

Browse files
committed
2017.06.02. psp_2.1.1
- sn_smtp.php > line : include_once "/lib/sn_dns.php"; - sn_esmtp.php > line : include_once "/lib/sn_dns.php"; - sn_mysql.php > line : include_once "/lib/sn_dns.php"; - sd_spc.php : new function > spc_request_sys(int $sid, string $cmd) > spc_request_dev(int $sid, string $cmd)
1 parent 448f3df commit 8c22065

File tree

6 files changed

+60
-14
lines changed

6 files changed

+60
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PHPoC source codes for basic libraries and examples
88
* sd_104.php
99
* sd_204.php
1010
* sd_340.php
11-
* sd_spc.php (*NEW*)
11+
* sd_spc.php
1212
* sn_dns.php
1313
* sn_esmtp.php
1414
* sn_mysql.php

lib/sd_340.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
// $psp_id sd_340.php date 20170214
3+
// $psp_id sd_340.php date 20170314
44
// P4S-340/342 basic library
55

66
define("LOW", 0);
@@ -496,13 +496,13 @@ function i2c_setup($i2c_id, $saddr, $mode = "sm")
496496
function i2c_scan($i2c_id, $rw_bit = 1, $len = 0)
497497
{
498498
if($i2c_id != 0)
499-
exit("i2c_setup: i2c_id out of range $i2c_id\r\n");
499+
exit("i2c_scan: i2c_id out of range $i2c_id\r\n");
500500

501-
$pid = pid_open_nodie("/mmap/i2c$i2c_id", "i2c_setup");
501+
$pid = pid_open_nodie("/mmap/i2c$i2c_id", "i2c_scan");
502502

503503
pid_ioctl($pid, "req reset");
504504

505-
echo "i2c_scan found : ";
505+
echo "i2c_scan: ";
506506

507507
$found = 0;
508508

lib/sd_spc.php

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
// $psp_id sd_spc.php date 20170216
3+
// $psp_id sd_spc.php date 20170421
44

55
function sd_spc_pid_open_nodie($name, $from)
66
{
@@ -111,7 +111,7 @@ function spc_scan($start = 1, $end = 14, $verbose = false)
111111
if(pid_ioctl($pid, "get error sto"))
112112
continue; // slave timeout
113113

114-
printf("sid%02d : ", $sid);
114+
printf("sid%02d: ", $sid);
115115

116116
if(pid_ioctl($pid, "get error mbit"))
117117
echo "Mbit error ";
@@ -163,20 +163,20 @@ function spc_scan($start = 1, $end = 14, $verbose = false)
163163
$resp = explode(",", $rbuf);
164164

165165
if($verbose)
166-
printf("sid%02d : %s %12x\r\n", $sid, $resp[2], bin2int($uid_bin, 5, 6, true));
166+
printf("sid%02d: %s %12x\r\n", $sid, $resp[2], bin2int($uid_bin, 5, 6, true));
167167

168168
$found++;
169169
}
170170
else
171171
{
172172
if($verbose)
173-
printf("sid%02d : invalid uid\r\n", $sid);
173+
printf("sid%02d: invalid uid\r\n", $sid);
174174
}
175175
}
176176
else
177177
{
178178
if($verbose)
179-
printf("sid%02d : invalid 'get uid' response\r\n", $sid);
179+
printf("sid%02d: invalid 'get uid' response\r\n", $sid);
180180
}
181181
}
182182
}
@@ -211,7 +211,7 @@ function spc_request($sid, $addr, $msg, $opt = "")
211211

212212
if(pid_ioctl($pid, "get error"))
213213
{
214-
echo "spc_request : $msg - $sid/$addr ";
214+
echo "spc_request: $msg - $sid/$addr ";
215215

216216
if(pid_ioctl($pid, "get error sto"))
217217
echo "slave timeout ";
@@ -256,4 +256,44 @@ function spc_request_csv($sid, $addr, $msg)
256256
return false;
257257
}
258258

259+
function spc_request_sys($sid, $cmd)
260+
{
261+
$resp = spc_request($sid, 0, $cmd);
262+
263+
if($resp)
264+
{
265+
$resp = explode(",", $resp);
266+
267+
if((int)$resp[0] != 200)
268+
echo "spc_request_sys: '$cmd' request error ", $resp[0], "\r\n";
269+
270+
if(count($resp) > 1)
271+
return $resp[1];
272+
else
273+
return "";
274+
}
275+
else
276+
return "";
277+
}
278+
279+
function spc_request_dev($sid, $cmd)
280+
{
281+
$resp = spc_request($sid, 4, $cmd);
282+
283+
if($resp)
284+
{
285+
$resp = explode(",", $resp);
286+
287+
if((int)$resp[0] != 200)
288+
echo "spc_request_dev: '$cmd' request error ", $resp[0], "\r\n";
289+
290+
if(count($resp) > 1)
291+
return $resp[1];
292+
else
293+
return "";
294+
}
295+
else
296+
return "";
297+
}
298+
259299
?>

lib/sn_esmtp.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
// $psp_id sn_esmtp.php date 20170214
3+
// $psp_id sn_esmtp.php date 20170329
4+
5+
include_once "/lib/sn_dns.php";
46

57
define("ESMTP_STATE_IDLE", 0);
68
define("ESMTP_STATE_RR_MX", 1);

lib/sn_mysql.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
// $psp_id sn_mysql.php date 20170216
3+
// $psp_id sn_mysql.php date 20170601
4+
5+
include_once "/lib/sn_dns.php";
46

57
define("MYSQL_STATE_IDLE", 0);
68
define("MYSQL_STATE_RR", 1);

lib/sn_smtp.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
// $psp_id sn_smtp.php date 20160415
3+
// $psp_id sn_smtp.php date 20170329
4+
5+
include_once "/lib/sn_dns.php";
46

57
define("SMTP_STATE_IDLE", 0);
68
define("SMTP_STATE_RR_MX", 1);

0 commit comments

Comments
 (0)