5d
来自Jack's Lab
(版本间的差异)
(→更改上行网络) |
(→校准 RTC) |
||
第78行: | 第78行: | ||
=== 校准 RTC === | === 校准 RTC === | ||
− | + | 原集中器内 RTC 时间不对,根据现在时间校准集线器的 RTC: | |
<source lang=bash> | <source lang=bash> | ||
第87行: | 第87行: | ||
Thu Jan 6 12:38:56 2017 0.000000 seconds | Thu Jan 6 12:38:56 2017 0.000000 seconds | ||
</source> | </source> | ||
+ | |||
+ | 此时间会影响到上行 XML 数据内时间戳 | ||
<br><br> | <br><br> |
2017年1月6日 (五) 11:46的版本
目录 |
1 现场调试操作
1.1 更改上行网络
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;
现场集中器上行使用 RS485 转 Ethernet 组网,因此需将 net_type 改为 1 (RS485):
[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
1.2 校准 RTC
原集中器内 RTC 时间不对,根据现在时间校准集线器的 RTC:
[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
此时间会影响到上行 XML 数据内时间戳
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 ZLAN 5102 Config
5 Uploaded XML Data
From collector:
<?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>
6 NOTES
6.1 Meter Type
- HEATMETER 0x20
- WATERMETER 0x10
- ELECTMETER 0x40
- GASMETER 0x30
- SENSORDEV 0x50 // RTU module of sensors
6.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- };
6.3 Meter Channel
Only support:
- RS485_DOWN_CHANNEL 7
6.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;
7 Hardware
7.1 Serial Console
- CP2102_PIN26 --- ARM9_CORE_J2_32_DRXD
- CP2102_PIN25 --- ARM9_CORE_J2_30_DTXD
7.2 RS485_1
- RS485_1_A+ --- MAX485_PIN6
- RS485_1_B- --- MAX485_PIN7
- MAX485_PIN4 --- ARM9_CORE_J2_68_TXD0
- MAX485_PIN1 --- ARM9_CORE_J2_69_RXD0
- MAX485_PIN2 & 3 --- ARM9_CORE_J1_69_PC30
7.3 RS485_2
- RS485_2_A+ --- MAX485_PIN6
- RS485_2_B- --- MAX485_PIN7
- MAX485_PIN4 --- ARM9_CORE_J2_55_CANTX1
- MAX485_PIN1 --- ARM9_CORE_J2__57_CANRX1
- MAX485_PIN2 & 3 --- ARM9_CORE_J1_68_PC31
8 Drivers
atmel_usart:
atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL atmel_usart.1: ttyS1 at MMIO 0xf801c000 (irq = 5) is a ATMEL_SERIAL atmel_usart.2: ttyS2 at MMIO 0xf8020000 (irq = 6) is a ATMEL_SERIAL atmel_usart.3: ttyS3 at MMIO 0xf8024000 (irq = 7) is a ATMEL_SERIAL atmel_usart.5: ttyS5 at MMIO 0xf8040000 (irq = 15) is a ATMEL_SERIAL atmel_usart.6: ttyS6 at MMIO 0xf8044000 (irq = 16) is a ATMEL_SERIAL
#define DEVICE4851 "/dev/ttyS1" #define DEVICE4852 "/dev/ttyS2" #define DEVICEGPRS "/dev/ttyS3" #define DEVICEMBUS "/dev/ttyS6" #define IO_CONTROL "/dev/CONTROL_IO"
9 Boot log
RomBOOT Start AT91Bootstrap... Init DDR... Done! Loading 1-Wire info... Enumerate all roms: Done, 0x0 1-wire chips found! No 1-Wire chip found on EXID=0x0x2! MCUzone:try to load from preset area... sn: 0xa0284a4; rev: 0x248421 Downloading image... chip id: 0xecda Copy 0x50000 bytes from 0x40000 to 0x26f00000 Done! U-Boot 2010.06 (May 24 2012 - 14:30:50) DRAM: 128 MiB NAND: 256 MiB *** Warning - bad CRC or NAND, using default environment In: serial Out: serial Err: serial Net: macb0 macb0: Starting autonegotiation... macb0: Autonegotiation complete macb0: link up, 100Mbps full-duplex (lpa: 0x4de1) Hit any key to stop autoboot: 0 NAND read: device 0 offset 0x200000, size 0x250000 2424832 bytes read: OK ## Booting kernel from Legacy Image at 22000000 ... Image Name: Linux-2.6.39 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2107352 Bytes = 2 MiB Load Address: 20008000 Entry Point: 20008000 Verifying Checksum ... OK Loading Kernel Image ... OK OK Starting kernel ... Uncompressing Linux... done, booting the kernel. Linux version 2.6.39 (root@mcuzone) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-41) ) #30 Wed Aug 28 10:47:14 CST 2013 CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177 CPU: VIVT data cache, VIVT instruction cache Machine: Atmel AT91SAM9X5-EK Memory policy: ECC disabled, Data cache writeback Clocks: CPU 400 MHz, master 133 MHz, main 12.000 MHz Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512 Kernel command line: mem=128M console=ttyS0,115200 mtdparts=atmel_nand:8M(bootstrap/uboot/kernel)ro,-(rootfs) root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs PID hash table entries: 512 (order: -1, 2048 bytes) Dentry cache hash table entries: 16384 (order: 4, 65536 bytes) Inode-cache hash table entries: 8192 (order: 3, 32768 bytes) Memory: 128MB = 128MB total Memory: 125696k/125696k available, 5376k reserved, 0K highmem Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) DMA : 0xff000000 - 0xffe00000 ( 14 MB) vmalloc : 0xc8800000 - 0xfee00000 ( 870 MB) lowmem : 0xc0000000 - 0xc8000000 ( 128 MB) modules : 0xbf000000 - 0xc0000000 ( 16 MB) .init : 0xc0008000 - 0xc002a000 ( 136 kB) .text : 0xc002a000 - 0xc03e0708 (3802 kB) .data : 0xc03e2000 - 0xc0408a40 ( 155 kB) NR_IRQS:192 AT91: 128 gpio irqs in 4 banks Console: colour dummy device 80x30 console [ttyS0] enabled Calibrating delay loop... 199.06 BogoMIPS (lpj=995328) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 512 CPU: Testing write buffer coherency: ok NET: Registered protocol family 16 AT91: CM rev B and higher AT91: EK rev B and higher AT91: Power Management (with slow clock mode) AT91: Starting after user reset bio: create slab <bio-0> at 0 SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb i2c-gpio i2c-gpio.0: using pins 62 (SDA) and 63 (SCL) at_hdmac at_hdmac.0: Atmel AHB DMA Controller ( cpy slave ), 8 channels at_hdmac at_hdmac.1: Atmel AHB DMA Controller ( cpy slave ), 8 channels cfg80211: Calling CRDA to update world regulatory domain Switching to clocksource tcb_clksrc NET: Registered protocol family 2 IP route cache hash table entries: 1024 (order: 0, 4096 bytes) TCP established hash table entries: 4096 (order: 3, 32768 bytes) TCP bind hash table entries: 4096 (order: 2, 16384 bytes) TCP: Hash tables configured (established 4096 bind 4096) TCP reno registered UDP hash table entries: 256 (order: 0, 4096 bytes) UDP-Lite hash table entries: 256 (order: 0, 4096 bytes) NET: Registered protocol family 1 RPC: Registered udp transport module. RPC: Registered tcp transport module. RPC: Registered tcp NFSv4.1 backchannel transport module. NetWinder Floating Point Emulator V0.97 (double precision) JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc. msgmni has been set to 245 io scheduler noop registered (default) atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL atmel_usart.1: ttyS1 at MMIO 0xf801c000 (irq = 5) is a ATMEL_SERIAL atmel_usart.2: ttyS2 at MMIO 0xf8020000 (irq = 6) is a ATMEL_SERIAL atmel_usart.3: ttyS3 at MMIO 0xf8024000 (irq = 7) is a ATMEL_SERIAL atmel_usart.5: ttyS5 at MMIO 0xf8040000 (irq = 15) is a ATMEL_SERIAL atmel_usart.6: ttyS6 at MMIO 0xf8044000 (irq = 16) is a ATMEL_SERIAL pioa_baseaddr is ok pioc_baseaddr is ok CONTROL_IO initialized brd: module loaded loop: module loaded ssc ssc.0: Atmel SSC device at 0xc8898000 (irq 28) atmel_nand atmel_nand: Using dma0chan0 for DMA transfers. NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit) atmel_pmecc_init_params Scanning device for bad blocks Bad eraseblock 220 at 0x000001b80000 Bad eraseblock 590 at 0x0000049c0000 Bad eraseblock 1126 at 0x000008cc0000 Bad eraseblock 1268 at 0x000009e80000 Bad eraseblock 1313 at 0x00000a420000 2 cmdlinepart partitions found on MTD device atmel_nand Creating 2 MTD partitions on "atmel_nand": 0x000000000000-0x000000800000 : "bootstrap/uboot/kernel" 0x000000800000-0x000010000000 : "rootfs" UBI: attaching mtd1 to ubi0 UBI: physical eraseblock size: 131072 bytes (128 KiB) UBI: logical eraseblock size: 126976 bytes UBI: smallest flash I/O unit: 2048 UBI: VID header offset: 2048 (aligned 2048) UBI: data offset: 4096 UBI: max. sequence number: 88 UBI: attached mtd1 to ubi0 UBI: MTD device name: "rootfs" UBI: MTD device size: 248 MiB UBI: number of good PEBs: 1979 UBI: number of bad PEBs: 5 UBI: number of corrupted PEBs: 0 UBI: max. allowed volumes: 128 UBI: wear-leveling threshold: 4096 UBI: number of internal volumes: 1 UBI: number of user volumes: 1 UBI: available PEBs: 0 UBI: total number of reserved PEBs: 1979 UBI: number of PEBs reserved for bad PEB handling: 19 UBI: max/mean erase counter: 2/0 UBI: image sequence number: 216742870 UBI: background thread "ubi_bgt0d" started, PID 360 macb macb.0: invalid hw address, using random macb macb.0: eth0: Features changed: 0x00004800 -> 0x00004000 MACB_mii_bus: probed eth0: Atmel MACB at 0xf802c000 irq 24 (52:ac:b8:80:5f:b2) eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:00, irq=-1) ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver atmel-ehci atmel-ehci: Atmel EHCI UHP HS atmel-ehci atmel-ehci: new USB bus registered, assigned bus number 1 atmel-ehci atmel-ehci: irq 22, io mem 0x00700000 atmel-ehci atmel-ehci: USB 2.0 started, EHCI 1.00 hub 1-0:1.0: USB hub found hub 1-0:1.0: 3 ports detected ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver at91_ohci at91_ohci: AT91 OHCI at91_ohci at91_ohci: new USB bus registered, assigned bus number 2 at91_ohci at91_ohci: irq 22, io mem 0x00600000 hub 2-0:1.0: USB hub found hub 2-0:1.0: 3 ports detected Initializing USB Mass Storage driver... usbcore: registered new interface driver usb-storage USB Mass Storage support registered. usbcore: registered new interface driver libusual atmel_usba_udc atmel_usba_udc: MMIO registers at 0xf803c000 mapped at c88fe000 atmel_usba_udc atmel_usba_udc: FIFO at 0x00500000 mapped at d9100000 atmel_tsadcc atmel_tsadcc: Master clock is set at: 133333333 Hz atmel_tsadcc atmel_tsadcc: Prescaler is set at: 221 input: atmel touch screen controller as /devices/platform/atmel_tsadcc/input/input0 rtc-rx8025 0-0032: rtc core: registered rx8025 as rtc0 i2c /dev entries driver usbcore: registered new interface driver usbhid usbhid: USB HID core driver nf_conntrack version 0.5.0 (1964 buckets, 7856 max) ip_tables: (C) 2000-2006 Netfilter Core Team TCP cubic registered NET: Registered protocol family 17 lib80211: common routines for IEEE802.11 drivers Registering the dns_resolver key type rtc-rx8025 0-0032: setting system clock to 2017-01-06 00:38:50 UTC (1483634330) atmel_mci atmel_mci.0: Using dma0chan1 for DMA transfers atmel_mci atmel_mci.0: Atmel MCI controller at 0xf0008000 irq 12, 1 slots atmel_mci atmel_mci.1: Using dma1chan0 for DMA transfers atmel_mci atmel_mci.1: Atmel MCI controller at 0xf000c000 irq 26, 1 slots UBIFS: recovery needed UBIFS: recovery completed UBIFS: mounted UBI device 0, volume 0, name "rootfs" UBIFS: file system size: 58662912 bytes (57288 KiB, 55 MiB, 462 LEBs) UBIFS: journal size: 7872512 bytes (7688 KiB, 7 MiB, 62 LEBs) UBIFS: media format: w4/r0 (latest is w4/r0) UBIFS: default compressor: lzo UBIFS: reserved for root: 0 bytes (0 KiB) VFS: Mounted root (ubifs filesystem) on device 0:12. Freeing init memory: 136K ******************************** Exec rcS ******************************** ********mount all******** mount: according to /proc/mounts, porc is already mounted on /proc mount: mounting usbfs on /proc/bus/usb failed: No such file or directory ********Starting mdev******** This may take some time ... --------Start Local Services-------- ********Starting telnetd******** *********alsa restore*********** alsactl: load_state:1625: No soundcards found... *********touchscreen************ ******************************** 513 xi'an R&D Center Linux For Energy Monitor ******************************** ******************************************** program restart! ******************************************** mcuzone login: Creat QMSG_FILE OK. g_uiQmsgFd = 0. XMLBuf_Init OK. QueuesInit OK! open_IOControl OK! [db.c][read_meter_info][996]read meter info: select f_meter_address, f_meter_type, f_meter_channel, f_id, f_install_pos, f_device_id, f_meter_proto_type from t_meter_info order by f_meter_channel, f_id desc; [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 Create RS485Up_Rec_pthreadID OK! Create UartGprs_Rec_pthreadID OK! Create UartMbus_Rec_pthreadID OK! Create UartDown485_Rec_pthreadID OK! Create pthread_GPRS_Mana OK! Create pthread_GPRS_IPD OK! Create pthread_GprsDataDeal OK! Create pthread_RS485UpDeal OK! Create pthread_ReadAllMeters OK! Create pthread_up_long_data OK! RS485Down com parameter set OK. MBUS com parameter set OK. GPRS com parameter set OK. ... ...
10 Reference
- DTSD106-M100 三相电子式电能表用户使用手册: http://www.go-gddq.com/down/2011-10/11102117032297.pdf
- ZLAN5102-3 用户使用手册l: http://www.zlmcu.com/download/ZLAN5102-3.pdf