查看Bim的源代码
←
Bim
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== 现场调试操作 == * http://192.168.1.2:3000/ * http://192.168.1.2:18083/ * http://192.168.1.2:8000/device/yard * http://192.168.1.2:8000/device/yard2 * http://192.168.1.2:8000/device/temp * http://192.168.1.2:8000/device/temp2 * pull elect data: http://192.168.1.2:8000/dev/data?meter_id=1B&way_id=3 * push data: http://192.168.1.2:8000/dev/temp?building_id=110101B001&devid=MKD393830497658&temp=19.2 * pull data: http://192.168.1.2:8000/tempdata?devid=MKD118581004672 [[文件:5d-collector.jpg]] 以下所有操作都在 USB 连接集中器后获取的串口终端里操作,参见《集中器本地调试指南》 <source lang=bash> [root@mcuzone root]# [root@mcuzone root]#[gprs.c][ModelIdentify][671] ps ax PID USER TIME COMMAND 1 root 0:00 init 2 root 0:00 [kthreadd] 3 root 0:00 [ksoftirqd/0] 4 root 0:00 [kworker/0:0] 5 root 0:00 [kworker/u:0] 6 root 0:00 [rcu_kthread] 7 root 0:00 [khelper] 8 root 0:00 [kworker/u:1] 136 root 0:00 [sync_supers] 138 root 0:00 [bdi-default] 140 root 0:00 [kblockd] 152 root 0:00 [khubd] 186 root 0:00 [cfg80211] 187 root 0:00 [kworker/0:1] 270 root 0:00 [rpciod] 277 root 0:00 [kswapd0] 278 root 0:00 [fsnotify_mark] 279 root 0:00 [nfsiod] 280 root 0:00 [crypto] 347 root 0:00 [mtdblock0] 352 root 0:00 [mtdblock1] 360 root 0:00 [ubi_bgt0d] 402 root 0:00 [ubifs_bgt0_0] 416 root 0:00 telnetd 421 root 0:00 {runapp.sh} /bin/sh ./runapp.sh 422 root 0:00 -sh 423 root 0:00 /sbin/getty 115200 tty1 vt100 429 root 0:00 ./gather_V0 446 root 0:00 [flush-ubifs_0_0] 452 root 0:00 sleep 10 455 root 0:00 ps ax [root@mcuzone root]#kill -9 421 [root@mcuzone root]#kill -9 429 </source> <br> === 更改上行网络 === net_type 网络类型: * 0 - GPRS * 1 - RS485 * 2 - Ethernet (NOT SUPPORT) * 3 - Zigbee (NOT SUPPORT) <source lang=c> typedef enum em_net_mod { em_net_gprs = 0, em_net_rs485, em_net_eth, em_net_zigbee } net_mod; </source> 现场集中器上行使用 RS485 转 Ethernet 组网,因此需将 net_type 改为 1 (RS485): <source lang=bash> [root@mcuzone root]#cd /app [root@mcuzone /app]#sqlite3 ./gatherdb.db SQLite version 3.10.0 2016-01-06 11:01:07 Enter ".help" for usage hints. sqlite> select * from t_base_define; sqlite> .head on sqlite> .mode column sqlite> select * from t_base_define; f_id f_config_name f_config_value ---------- -------------- -------------- 1 primary_server 122.5.18.174 2 primary_dns 219.146.0.130 3 primary_port 9011 4 second_server 219.146.0.130 5 second_dns 219.146.0.130 6 second_port 9027 7 gateway_id 37060001 8 net_type 0 9 md5_key 863CA654 10 aes_key d41d8cd98f00b2 11 collect_mode 0 12 collect_cycle 15 13 report_mode 0 14 beat_cycle 2 15 svr_num 0001 16 appmd5 28a011de19210e sqlite> update t_base_define set f_config_value='1' where f_config_name='net_type'; sqlite> sqlite> select * from t_base_define; f_id f_config_name f_config_value ---------- -------------- -------------- 1 primary_server 122.5.18.174 2 primary_dns 219.146.0.130 3 primary_port 9011 4 second_server 219.146.0.130 5 second_dns 219.146.0.130 6 second_port 9027 7 gateway_id 37060001 8 net_type 1 9 md5_key 863CA654 10 aes_key d41d8cd98f00b2 11 collect_mode 0 12 collect_cycle 15 13 report_mode 0 14 beat_cycle 2 15 svr_num 0001 16 appmd5 28a011de19210e </source> <br><br> === 校准 RTC === 确认集中器内 RTC 时间: <source lang=bash> [root@mcuzone root]#hwclock -r Thu Jan 1 12:38:56 1970 0.000000 seconds </source> 此时间会影响到上行 XML 数据内时间戳,时间不正确,需要根据现在时间校准集线器的 RTC: <source lang=bash> [root@mcuzone root]#date -s 2017.01.06-12:38:48 Thu Jan 6 12:38:48 CST 2017 [root@mcuzone root]#hwclock -w # write RTC to store the time [root@mcuzone root]#hwclock -r Thu Jan 6 12:38:56 2017 0.000000 seconds </source> <br><br> === 集中器联网 === 集中器联网,旨在更新集中器内部抄表核心程序。更新完毕网络即可拔除 打开集中器外壳,插上网线使其可访问外网 集中器 IP: <source lang=bash> [root@mcuzone root]#ifconfig eth0 192.168.1.251 [root@mcuzone root]#ifconfig eth0 up eth0 Link encap:Ethernet HWaddr 4E:FC:21:ED:70:7A inet addr:192.168.1.251 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1344 (1.3 KiB) TX bytes:0 (0.0 B) Interrupt:24 Base address:0xc000 </source> Gateway: <source lang=bash> [root@mcuzone root]#route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 [root@mcuzone root]#ping 42.121.85.30 PING 42.121.85.30 (42.121.85.30): 56 data bytes ping: sendto: Network is unreachable [root@mcuzone root]#route add default gw 192.168.1.1 [root@mcuzone root]#route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 </source> Ping testing: <source lang=bash> [root@mcuzone root]#ping 42.121.85.30 PING 42.121.85.30 (42.121.85.30): 56 data bytes 64 bytes from 42.121.85.30: seq=0 ttl=51 time=27.494 ms 64 bytes from 42.121.85.30: seq=1 ttl=51 time=28.665 ms 64 bytes from 42.121.85.30: seq=2 ttl=51 time=28.041 ms Ctrl+C --- 42.121.85.30 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 27.494/28.066/28.665 ms </source> <br><br> === 更新集中器核心程序 === 确认集中器可访问外网后,先备份原有抄表核心程序: <source lang=bash> [root@mcuzone root]#cd /app [root@mcuzone /app]#ls buff1.xml buff3.xml gatherdb.db rcS x buff2.xml gather_V0 log.txt runapp.sh [root@mcuzone /app]#mv gather_V0 gather_V0.old [root@mcuzone /app]#ls buff1.xml buff3.xml gatherdb.db rcS x buff2.xml gather_V0.old log.txt runapp.sh </source> 获取修正后的抄表核心程序: <source lang=bash> [root@mcuzone /app]#wget http://42.121.85.30/gather_V0 Connecting to 42.121.85.30 (42.121.85.30:80) gather_V0 100% |*******************************| 316k 0:00:00 ETA [root@mcuzone /app]#ls buff1.xml buff3.xml gather_V0.old log.txt runapp.sh buff2.xml gather_V0 gatherdb.db rcS [root@mcuzone /app]#ls -l gather* -rw-r--r-- 1 root root 324430 Jan 6 12:25 gather_V0 -rwxr-xr-x 1 root root 294111 Jan 5 23:43 gather_V0.old -rw-r--r-- 1 1002 1002 51200 Jan 6 12:13 gatherdb.db [root@mcuzone /app]#chmod +x gather_V0 [root@mcuzone /app]#ls -l gather* -rwxr-xr-x 1 root root 324430 Jan 6 12:25 gather_V0 -rwxr-xr-x 1 root root 294111 Jan 5 23:43 gather_V0.old -rw-r--r-- 1 1002 1002 51200 Jan 6 12:13 gatherdb.db </source> 试运行: <source lang=bash> [root@mcuzone /app]#./gather_V0 Creat QMSG_FILE OK. g_uiQmsgFd = 0. XMLBuf_Init OK. QueuesInit OK! open_IOControl OK! ...... ...... [db.c][each_meter_info][1027] meter_type length : 2 [db.c][each_meter_info][1030] meter_type: 40 [db.c][each_meter_info][1052]135000000 ...... ...... </source> 重启集中器: <source lang=bash> [root@mcuzone /app]#reboot </source> Or press the SW1 button to reset the Collector <br><br> === ZLAN 5102 设置 === ZLAN 配置工作在 TCP Client 模式,这样集中器通过 RS485 上行的 XML 数据自动被 ZLAN 转发到: * Dest IP 为 122.5.18.172 的服务器(调试目的此 IP 为调试人员 PC) * Dest Port 为 9011 因此运行于 122.5.18.172 上的上位机程序服务端口为 9011,上位服务器通过此端口获取集中器主动上发的 XML 数据,解析后需向集中器发包响应 没有响应数据包,集中器会认为发送失败,会重复发送上行数据 [[文件:Zlan5130-config.png]] <br><br> === 验证 === 到此,在调试人员 PC 122.5.18.172 上,开一个 TCP Server 端口在 9011,就能收到,集中器定时上传的 XML 数据: <source lang=bash> comcat@jackslab:/work/5d/src/src-x$ sudo nc -l -p 9011 <?xml version="1.0" encoding="utf-8"?> <root><common><sadd>37060001</sadd><oadd></oadd><func_type>6</func_type><oper_type>3</oper_type></common><trans><total_meter_num>1</total_meter_num><frame_idx>1</frame_idx><meter_num>1</meter_num><time_node>2017-01-05 22:38:00</time_node></trans><row id="1"><f_id>2375</f_id><f_meter_type>40</f_meter_type><f_device_id>3</f_device_id><f_meter_address>00000000000087</f_meter_address><f_timestamp>2017-01-05 22:38:43</f_timestamp><f_time>2017-01-05 22:38:00</f_time><f_pact_tot_elec>null</f_pact_tot_elec><f_nact_tot_elec>null</f_nact_tot_elec><f_preact_tot_elec>null</f_preact_tot_elec><f_nreact_tot_elec>null</f_nreact_tot_elec><f_act_tot_elec>null</f_act_tot_elec><f_react_tot_elec>null</f_react_tot_elec></row></root> <?xml version="1.0" encoding="utf-8"?> <root><common><sadd>37060001</sadd><oadd></oadd><func_type>6</func_type><oper_type>3</oper_type></common><trans><total_meter_num>1</total_meter_num><frame_idx>1</frame_idx><meter_num>1</meter_num><time_node>2017-01-05 22:38:00</time_node></trans><row id="1"><f_id>2375</f_id><f_meter_type>40</f_meter_type><f_device_id>3</f_device_id><f_meter_address>00000000000087</f_meter_address><f_timestamp>2017-01-05 22:38:43</f_timestamp><f_time>2017-01-05 22:38:00</f_time><f_pact_tot_elec>null</f_pact_tot_elec><f_nact_tot_elec>null</f_nact_tot_elec><f_preact_tot_elec>null</f_preact_tot_elec><f_nreact_tot_elec>null</f_nreact_tot_elec><f_act_tot_elec>null</f_act_tot_elec><f_react_tot_elec>null</f_react_tot_elec></row></root> ...... ...... </source> 集中器默认抄表时间间隔为 15 分钟,调试目的,可将时间间隔调整为 2 分钟: <source lang=bash> [root@mcuzone root]#cd /app [root@mcuzone /app]#sqlite3 ./gatherdb.db SQLite version 3.10.0 2016-01-06 11:01:07 Enter ".help" for usage hints. sqlite> select * from t_base_define where f_config_name='collect_cycle'; f_id f_config_name f_config_value ---------- -------------- -------------- 12 collect_cycle 15 sqlite> update t_base_define set f_config_value='2' where f_config_name='collect_cycle'; sqlite> .exit </source> 重启集中器,即可生效: <source lang=bash> [root@mcuzone /app]#reboot </source> <br><br>
返回到
Bim
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面