5d

来自Jack's Lab
2017年1月5日 (四) 22:44Comcat (讨论 | 贡献)的版本

跳转到: 导航, 搜索

目录

1 First Tuning

1.1 Change Net Type

net_type 网络类型:

  • 0 - GPRS
  • 1 - RS485
  • 2 - Ethernet (NOT SUPPORT)
  • 3 - Zigbee (NOT SUPPORT)
typedef enum em_net_mod {
    em_net_gprs = 0,
    em_net_rs485,
    em_net_eth,
    em_net_zigbee
} net_mod;


[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        15             
9           md5_key         863CA654      
10          aes_key         d41d8cd98f00b2
11          collect_mode    0             
12          collect_cycle   1             
13          report_mode     0             
14          beat_cycle      2             
15          svr_num         0001          
16          appmd5          28a011de19210e



1.2 Setup RTC

[root@mcuzone root]#date -s 2017.01.05-18:38:48
Thu Jan  5 18:38:48 CST 2017
[root@mcuzone root]#hwclock -w # write RTC to store the time
[root@mcuzone root]#hwclock -r
Thu Jan  5 18:38:56 2017  0.000000 seconds



2 Update APP

Your PC:

$ sudo apt-get install nfs-kernel-server
 
Config the nfs directory:
 
$ sudo mkdir -p /tftpboot/rootfs
$ cat /etc/exports
/work/armv9    *(async,rw,insecure,insecure_locks,no_root_squash)
 
$ sudo /etc/init.d/nfs-kernel-server restart

In collector:

[root@mcuzone /app]#mount -o port=2049,nolock,proto=tcp -t nfs 192.168.1.72:/wor
k/5d/src ./x
[root@mcuzone /app]#ls x
bin       db        include   nfsroot   src       ubi.in
chmod.sh  dbtest.c  lib       sh        src-x
[root@mcuzone /app]#ls x/src-x
Makefile             main.c               sysinit.c
bsp.c                meter_table.c        uart_gprs.c
commap.c             notes.md             uart_mbus_down485.c
db.c                 queue.c              uart_set.c
elect.c              read_heatmeter.c     water.c
gather_V1            readallmeters.c      xml.c
gprs.c               rs485up.c
include              sysfuctions.c

Copy the gather_V1 into collector:

[root@mcuzone /app]#cp x/src-x/gather_V1 .
[root@mcuzone /app]#ls
1runapp.sh   buff2.xml    gather_V0    gatherdb.db  rcS          x
buff1.xml    buff3.xml    gather_V1    log.txt      runapp.sh



3 TODO

"使用485组网,是不允许信息主动上推的,必须等待上位要数, 如果多个集中器都往485总线上推数据, 会引发冲突"

void ReadAllMeters(void)
{
    ......
    ......
    if (RPT_ACTIVE == atoi(sysconfig.f_config_value)) { //如果是主动上报, 则发送上报消息
        lnetMod = g_sysConfigHex.netType;

        if (lnetMod != em_net_rs485) {
            //使用485组网,是不允许信息主动上推的,必须等待上位要数, 如果多个集中器都往485总线上推数据, 会引发冲突
            ......
            ......
        }
    }
    ......
    ......
}



4 NOTES

4.1 Meter Type

  • HEATMETER 0x20
  • WATERMETER 0x10
  • ELECTMETER 0x40
  • GASMETER 0x30
  • SENSORDEV 0x50 // RTU module of sensors


4.2 ElectMeter Protocol

/*
 *  Format:串口设置, 读取电表数据标识符, 前导符个数, 通讯类型 (0:MBUS  1:485), 通讯协议类型(0:MODBUS  1:645)
*/
uint16 gELEC_METER_Table[ELECMETER_PROTO_SUM][5] = {
  {ELEC_COMSET_1, 0x0000, 0, ELEC_RS485, ELEC_PROTO_MODBUS},  //力创电表               -----idx: -0-
  {ELEC_COMSET_1, 0x0000, 0, ELEC_RS485, ELEC_PROTO_MODBUS},  //acrel DDSD1352单相电表 -----idx: -1-
  {ELEC_COMSET_1, 0x0000, 0, ELEC_RS485, ELEC_PROTO_MODBUS},  //acrel DTSF1352三相电表 -----idx: -2-
  {ELEC_COMSET_1, 0x0000, 0, ELEC_RS485, ELEC_PROTO_MODBUS},  //acrel PZ80-E4C三相电表 -----idx: -3-
};


4.3 Meter Channel

Only support:

  • RS485_DOWN_CHANNEL 7


4.4 Meter Config in Database

sqlite> .schema t_meter_info
CREATE TABLE t_meter_info
(
    f_id    integer primary key autoincrement,
    f_meter_type    varchar(2),
    f_device_id varchar(4),
    f_meter_address varchar(14),
    f_meter_channel varchar(2),
    f_meter_proto_type  varchar(2),
    f_install_pos   varchar(50)
);
sqlite> select * from t_meter_info;
18|40|3|00000000000001|7|0|3#地下室
19|20|4|11110020160429|1|0|3#under

sqlite> .dump t_meter_info
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;

INSERT INTO "t_meter_info" VALUES(18,'40','3','00000000000001','7','0','3#地下室');
INSERT INTO "t_meter_info" VALUES(19,'20','4','11110020160429','1','0','3#under');
COMMIT;



















个人工具
名字空间

变换
操作
导航
工具箱