#!/bin/sh
# 查询-所有设备列表 包括串口设备、扩展设备、网口设备
echo -en "Content-type: text/html; charset=utf-8\n\n"
#*****************************************************
source ../bin/env.sh

jsoner="../bin/jsoner"


read json

echo $json > log

arg=`echo "$json" |tr -d ' '`

#echo $arg >> log

debug=`$jsoner $arg debug`

type=`$jsoner $arg type`
ip=`$jsoner $arg ip`
port=`$jsoner $arg port`
ver=`$jsoner $arg ver`
addr=`$jsoner $arg addr`
funCode=`$jsoner $arg funCode`
starReg=`$jsoner $arg starReg`
regCnt=`$jsoner $arg regCnt`
cid1=`$jsoner $arg cid1`
cid2=`$jsoner $arg cid2`
data=`$jsoner $arg data`
oid=`$jsoner $arg oid`
community=`$jsoner $arg community`


case "$debug" in 
modbus)
content=`msg modbus $type $ip $port $addr $funCode $starReg $regCnt`;;
powerbus)
content=`msg powerbus $type $ip $port $ver $addr $cid1 $cid2 $data`;;
string)
content=`msg string $type $ip $port $data`;;
snmp)
content=`msg snmp $ver $ip $oid $port $community`;;
esac

#echo $content

tmp=${content##*'{'}

echo "{$tmp" |tr -d '\n'
