4 * Convert Open Metering System manufacturer codes to acronyms and back
\r
8 * @author Christian Weiske <weiske@mogic.com>
\r
11 echo "Pass manufacturer code or acronym\n";
\r
17 if (strlen($param) == 3) {
\r
20 . str_pad(decbin(ord($param{0}) - 64), 5, '0', STR_PAD_LEFT)
\r
21 . str_pad(decbin(ord($param{1}) - 64), 5, '0', STR_PAD_LEFT)
\r
22 . str_pad(decbin(ord($param{2}) - 64), 5, '0', STR_PAD_LEFT);
\r
23 echo str_pad(strtoupper(dechex(bindec($bin))), 4, '0', STR_PAD_LEFT)
\r
25 } else if (strlen($param) == 4) {
\r
27 $fb = str_pad(decbin(hexdec('5CB0')), 16, '0', STR_PAD_LEFT);
\r
28 echo chr(64 + bindec(substr($fb, 1, 5)))
\r
29 . chr(64 + bindec(substr($fb, 6, 5)))
\r
30 . chr(64 + bindec(substr($fb, 11, 5)))
\r
33 echo "Wrong length; 3 or 4 characters expected\n";
\r