tcp_server.txt 13.7 KB
; generated by Component: ARM Compiler 5.06 update 6 (build 750) Tool: ArmCC [4d3637]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave -o.\flash\obj\tcp_server.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\tcp_server.d --cpu=Cortex-M4.fp --apcs=interwork -O1 --diag_suppress=9931,870 -I..\..\Libraries\CMSIS\Include -I..\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include -I..\..\Libraries\STM32F4xx_StdPeriph_Driver\inc -I..\..\uCOS-III\uC-CPU -I..\..\uCOS-III\uC-LIB -I..\..\uCOS-III\uCOS-III\Ports -I..\..\uCOS-III\uCOS-III\Source -I..\..\uCOS-III\uC-CPU\ARM-Cortex-M4\RealView -I..\..\uCOS-III\uC-LIB\Ports\ARM-Cortex-M4\RealView -I..\..\uCOS-III\uCOS-III\Ports\ARM-Cortex-M4\Generic\RealView -I..\..\User -I..\..\User\bsp -I..\..\User\bsp\inc -I..\..\User\libapp -I..\..\RL-ARM\Config -I..\..\RL-ARM\Driver -I..\..\RL-ARM\RL-RTX\inc -I..\..\User\bsp\BSP -I..\..\RL-ARM\RL-CAN -I..\..\Libraries\DSP_LIB\Include -I..\..\MODBUS\modbus\rtu -I..\..\MODBUS\BARE\port -I..\..\MODBUS\modbus\include -I..\..\User\bsp\BSP -I..\..\PLC -I..\..\Avoid -I..\..\User\parameter -I..\..\User\LaserMotionCtr -I..\..\User\W5100S -I..\..\User\bsp -I..\..\User\CHASSIS -I..\..\User\CONTROLFUNCTION -I..\..\User\DATAUPDATE -I..\..\User\HARAWARE -I..\..\User\MOTORDRIVER -I..\..\User\NAVAGATION -I..\..\User\PLATFORM -I..\..\User\SENSOR -I.\RTE\_Flash -IC:\Users\YDJ\AppData\Local\Arm\Packs\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Users\YDJ\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.13.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -D__UVISION_VERSION=527 -D_RTE_ -DSTM32F407xx -DUSE_STDPERIPH_DRIVER -DSTM32F40_41xxx -D__RTX -D__FPU_USED=1 --omf_browse=.\flash\obj\tcp_server.crf ..\..\User\W5100S\tcp_server.c]
                          THUMB

                          AREA ||i.CopyShort||, CODE, READONLY, ALIGN=1

                  CopyShort PROC
;;;31     
;;;32     void CopyShort(u16 *Des,u16 *Ptr, u16 Length)
000000  b510              PUSH     {r4,lr}
;;;33     {
;;;34     	u16 i = 0;
000002  2300              MOVS     r3,#0
000004  e005              B        |L1.18|
                  |L1.6|
;;;35     	while(i < Length)
;;;36     	{
;;;37     		Des[i] = Ptr[i]; 
000006  f8314013          LDRH     r4,[r1,r3,LSL #1]
00000a  f8204013          STRH     r4,[r0,r3,LSL #1]
;;;38     		i++;
00000e  1c5b              ADDS     r3,r3,#1
000010  b29b              UXTH     r3,r3
                  |L1.18|
000012  4293              CMP      r3,r2                 ;35
000014  d3f7              BCC      |L1.6|
;;;39     	}
;;;40     }
000016  bd10              POP      {r4,pc}
;;;41     
                          ENDP


                          AREA ||i.do_tcp_server||, CODE, READONLY, ALIGN=2

                  do_tcp_server PROC
;;;41     
;;;42     void do_tcp_server(void)
000000  b510              PUSH     {r4,lr}
;;;43     {  
;;;44     	unsigned short len=0;  
;;;45     	switch(getSn_SR(SOCK_TCPS))                             // 获取socket的状态
000002  f2404003          MOV      r0,#0x403
000006  f7fffffe          BL       WIZCHIP_READ
00000a  b150              CBZ      r0,|L2.34|
00000c  2813              CMP      r0,#0x13
00000e  d015              BEQ      |L2.60|
000010  2817              CMP      r0,#0x17
000012  d01c              BEQ      |L2.78|
000014  281c              CMP      r0,#0x1c
000016  d12a              BNE      |L2.110|
;;;46     	{
;;;47     		case SOCK_CLOSED:                                     // socket处于关闭状态
;;;48     			Uart_Printf(COM1,"Creat\r\n");
;;;49     
;;;50     			socket(SOCK_TCPS ,Sn_MR_TCP,local_port,Sn_MR_ND);   // 打开socket
;;;51     			break;     
;;;52     
;;;53     		case SOCK_INIT:                                       // socket已初始化状态
;;;54     			
;;;55     			Uart_Printf(COM1,"LISTEN\r\n");
;;;56     			listen(SOCK_TCPS);                                  // socket建立监听
;;;57     			break;
;;;58     
;;;59     		case SOCK_ESTABLISHED:                                // socket处于连接建立状态
;;;60     			//Uart_Printf(COM1,"plc已连接\r\n");
;;;61     			if(getSn_IR(SOCK_TCPS) & Sn_IR_CON)
;;;62     			{
;;;63     				setSn_IR(SOCK_TCPS, Sn_IR_CON);                   // 清除接收中断标志位
;;;64     			}
;;;65     			len=getSn_RX_RSR(SOCK_TCPS);                        // 定义len为已接收数据的长度
;;;66     			if(len>0)
;;;67     			{
;;;68     //				recv(SOCK_TCPS,ServerRecvBuff,len);                         // 接收来自Client的数据
;;;69     //				ServerRecvBuff[len]=0x00;                                   // 添加字符串结束符				
;;;70     //				CombineTwoByteToOneShort(DataFromPLC, WORDLENGTH, (char *)ServerRecvBuff);//因为PLC发送short型数据高低位有问题,因此在这里将char按照PLC高低位组成short型
;;;71     //			
;;;72     //				if(pSetup[SETUP_SIEMENS_SCREEN_OPEN])
;;;73     //				{
;;;74     //					CopyShort(&DataToPLC[60],&usRegHoldingBuf[1],100);
;;;75     //					CopyShort(&usRegHoldingBuf[101],&DataFromPLC[60],100);	
;;;76     //				}
;;;77     //				
;;;78     //				UpdateDataFromHolding(&HandlePlcData);//将PLC发送来的数据更新到专门结构体中去
;;;79     //				
;;;80     //				UpdateDataToHolding(&HandlePlcData);//将PLC需要的数据更新到要发送给PLC的数组中去
;;;81     //				
;;;82     //				BreakShortToTwoByte(DataToPLC, WORDLENGTH, (char *)ServerSendBuff);//将要发送给PLC的short型数组拆分成char型数组
;;;83     //				
;;;84     //				send(SOCK_TCPS,ServerSendBuff,BYTELENGTH);   					// 向Client发送数据
;;;85     				
;;;86     //				ServerSendBuff[0] = 1;
;;;87     //				ServerSendBuff[1] = 2;
;;;88     //				ServerSendBuff[2] = 3;
;;;89     //				send(SOCK_TCPS,ServerSendBuff,3);
;;;90     				
;;;91     			}
;;;92     			break;
;;;93         
;;;94     		case SOCK_CLOSE_WAIT:                                 // socket处于等待关闭状态
;;;95     			//Uart_Printf(COM1,"CLOSE\r\n");
;;;96     
;;;97     			close(SOCK_TCPS);
000018  e8bd4010          POP      {r4,lr}
00001c  2000              MOVS     r0,#0
00001e  f7ffbffe          B.W      close
                  |L2.34|
000022  a113              ADR      r1,|L2.112|
000024  2001              MOVS     r0,#1                 ;48
000026  f7fffffe          BL       Uart_Printf
00002a  4813              LDR      r0,|L2.120|
00002c  2320              MOVS     r3,#0x20              ;50
00002e  2101              MOVS     r1,#1                 ;50
000030  8802              LDRH     r2,[r0,#0]            ;50  ; local_port
000032  e8bd4010          POP      {r4,lr}               ;50
000036  2000              MOVS     r0,#0                 ;50
000038  f7ffbffe          B.W      socket
                  |L2.60|
00003c  a10f              ADR      r1,|L2.124|
00003e  2001              MOVS     r0,#1                 ;55
000040  f7fffffe          BL       Uart_Printf
000044  e8bd4010          POP      {r4,lr}               ;56
000048  2000              MOVS     r0,#0                 ;56
00004a  f7ffbffe          B.W      listen
                  |L2.78|
00004e  f2404402          MOV      r4,#0x402             ;61
000052  4620              MOV      r0,r4                 ;61
000054  f7fffffe          BL       WIZCHIP_READ
000058  07c0              LSLS     r0,r0,#31             ;61
00005a  d003              BEQ      |L2.100|
00005c  2101              MOVS     r1,#1                 ;63
00005e  4620              MOV      r0,r4                 ;63
000060  f7fffffe          BL       WIZCHIP_WRITE
                  |L2.100|
000064  e8bd4010          POP      {r4,lr}               ;65
000068  2000              MOVS     r0,#0                 ;65
00006a  f7ffbffe          B.W      getSn_RX_RSR
                  |L2.110|
;;;98     			break;
;;;99     	}
;;;100    }
00006e  bd10              POP      {r4,pc}
;;;101    
                          ENDP

                  |L2.112|
000070  43726561          DCB      "Creat\r\n",0
000074  740d0a00
                  |L2.120|
                          DCD      local_port
                  |L2.124|
00007c  4c495354          DCB      "LISTEN\r\n",0
000080  454e0d0a
000084  00      
000085  00                DCB      0
000086  00                DCB      0
000087  00                DCB      0

                          AREA ||i.do_tcp_serverQT||, CODE, READONLY, ALIGN=2

                  do_tcp_serverQT PROC
;;;107    
;;;108    void do_tcp_serverQT(void)
000000  b510              PUSH     {r4,lr}
;;;109    {  
;;;110    	unsigned short len=0;  
;;;111    	switch(getSn_SR(SOCK_DHCP))                             // 获取socket的状态
000002  f2407003          MOV      r0,#0x703
000006  f7fffffe          BL       WIZCHIP_READ
00000a  b150              CBZ      r0,|L3.34|
00000c  2813              CMP      r0,#0x13
00000e  d015              BEQ      |L3.60|
000010  2817              CMP      r0,#0x17
000012  d01c              BEQ      |L3.78|
000014  281c              CMP      r0,#0x1c
000016  d12f              BNE      |L3.120|
;;;112    	{
;;;113    		case SOCK_CLOSED:                                     // socket处于关闭状态
;;;114    			
;;;115    			Uart_Printf(COM1,"Creat\r\n");
;;;116    
;;;117    			socket(SOCK_DHCP ,Sn_MR_TCP,local_port3,Sn_MR_ND);   // 打开socket
;;;118    			break;     
;;;119    
;;;120    		case SOCK_INIT:                                       // socket已初始化状态
;;;121    			
;;;122    			Uart_Printf(COM1,"Listen\r\n");
;;;123    
;;;124    			listen(SOCK_DHCP);                                  // socket建立监听
;;;125    			break;
;;;126    
;;;127    		case SOCK_ESTABLISHED:                                // socket处于连接建立状态
;;;128    
;;;129    			if(getSn_IR(SOCK_DHCP) & Sn_IR_CON)
;;;130    			{
;;;131    				setSn_IR(SOCK_DHCP, Sn_IR_CON);                   // 清除接收中断标志位
;;;132    			}
;;;133    						
;;;134    			len=getSn_RX_RSR(SOCK_DHCP);                        // 定义len为已接收数据的长度
;;;135    			
;;;136    			Uart_Printf(COM1,"len=%d\r\n",len);
;;;137    			if(len>0)
;;;138    			{
;;;139    //				recv(SOCK_DHCP,ServerRecvBuffQT,len); 
;;;140    //				
;;;141    //				agvPlcToControl();
;;;142    //				agvControlToPlc();
;;;143    //				BreakShortToTwoByte(DataToQt, MonitorWORDLENGTH, (char *)ServerSendBuffQT);
;;;144    //				send(SOCK_DHCP,ServerSendBuffQT,500);   					// 向Client发送数据
;;;145    //				setSn_IR(SOCK_DHCP, Sn_IR_CON);  
;;;146    //				len = 0;
;;;147    			}
;;;148    			break;
;;;149        
;;;150    		case SOCK_CLOSE_WAIT:                                 // socket处于等待关闭状态
;;;151    			close(SOCK_DHCP);
000018  e8bd4010          POP      {r4,lr}
00001c  2003              MOVS     r0,#3
00001e  f7ffbffe          B.W      close
                  |L3.34|
000022  a116              ADR      r1,|L3.124|
000024  2001              MOVS     r0,#1                 ;115
000026  f7fffffe          BL       Uart_Printf
00002a  4816              LDR      r0,|L3.132|
00002c  2320              MOVS     r3,#0x20              ;117
00002e  2101              MOVS     r1,#1                 ;117
000030  8802              LDRH     r2,[r0,#0]            ;117  ; local_port3
000032  e8bd4010          POP      {r4,lr}               ;117
000036  2003              MOVS     r0,#3                 ;117
000038  f7ffbffe          B.W      socket
                  |L3.60|
00003c  a112              ADR      r1,|L3.136|
00003e  2001              MOVS     r0,#1                 ;122
000040  f7fffffe          BL       Uart_Printf
000044  e8bd4010          POP      {r4,lr}               ;124
000048  2003              MOVS     r0,#3                 ;124
00004a  f7ffbffe          B.W      listen
                  |L3.78|
00004e  f2407402          MOV      r4,#0x702             ;129
000052  4620              MOV      r0,r4                 ;129
000054  f7fffffe          BL       WIZCHIP_READ
000058  07c0              LSLS     r0,r0,#31             ;129
00005a  d003              BEQ      |L3.100|
00005c  2101              MOVS     r1,#1                 ;131
00005e  4620              MOV      r0,r4                 ;131
000060  f7fffffe          BL       WIZCHIP_WRITE
                  |L3.100|
000064  2003              MOVS     r0,#3                 ;134
000066  f7fffffe          BL       getSn_RX_RSR
00006a  4602              MOV      r2,r0                 ;134
00006c  e8bd4010          POP      {r4,lr}               ;136
000070  a108              ADR      r1,|L3.148|
000072  2001              MOVS     r0,#1                 ;136
000074  f7ffbffe          B.W      Uart_Printf
                  |L3.120|
;;;152    			break;
;;;153    	}
;;;154    }
000078  bd10              POP      {r4,pc}
;;;155    
                          ENDP

00007a  0000              DCW      0x0000
                  |L3.124|
00007c  43726561          DCB      "Creat\r\n",0
000080  740d0a00
                  |L3.132|
                          DCD      local_port3
                  |L3.136|
000088  4c697374          DCB      "Listen\r\n",0
00008c  656e0d0a
000090  00      
000091  00                DCB      0
000092  00                DCB      0
000093  00                DCB      0
                  |L3.148|
000094  6c656e3d          DCB      "len=%d\r\n",0
000098  25640d0a
00009c  00      
00009d  00                DCB      0
00009e  00                DCB      0
00009f  00                DCB      0

;*** Start embedded assembler ***

#line 1 "..\\..\\User\\W5100S\\tcp_server.c"
	AREA ||.rev16_text||, CODE
	THUMB
	EXPORT |__asm___12_tcp_server_c_40535de2____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___12_tcp_server_c_40535de2____REV16| PROC
#line 130

 rev16 r0, r0
 bx lr
	ENDP
	AREA ||.revsh_text||, CODE
	THUMB
	EXPORT |__asm___12_tcp_server_c_40535de2____REVSH|
#line 144
|__asm___12_tcp_server_c_40535de2____REVSH| PROC
#line 145

 revsh r0, r0
 bx lr
	ENDP
	AREA ||.rrx_text||, CODE
	THUMB
	EXPORT |__asm___12_tcp_server_c_40535de2____RRX|
#line 300
|__asm___12_tcp_server_c_40535de2____RRX| PROC
#line 301

 rrx r0, r0
 bx lr
	ENDP

;*** End   embedded assembler ***