tcp_client.txt
8.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
; 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_client.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\tcp_client.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_client.crf ..\..\User\W5100S\tcp_client.c]
THUMB
AREA ||i.do_tcp_client||, CODE, READONLY, ALIGN=2
do_tcp_client PROC
;;;25
;;;26 void do_tcp_client(void)
000000 b510 PUSH {r4,lr}
;;;27 {
;;;28 uint16 len=0;
;;;29
;;;30 switch(getSn_SR(SOCK_TCPC)) // 获取socket的状态
000002 f2405003 MOV r0,#0x503
000006 f7fffffe BL WIZCHIP_READ
00000a b150 CBZ r0,|L1.34|
00000c 2813 CMP r0,#0x13
00000e d011 BEQ |L1.52|
000010 2817 CMP r0,#0x17
000012 d017 BEQ |L1.68|
000014 281c CMP r0,#0x1c
000016 d142 BNE |L1.158|
;;;31 {
;;;32 case SOCK_CLOSED: // socket处于关闭状态
;;;33 socket(SOCK_TCPC,Sn_MR_TCP,local_port2,Sn_MR_ND);
;;;34 break;
;;;35
;;;36 case SOCK_INIT: // socket处于初始化状态
;;;37 connect(SOCK_TCPC,remote_ip,remote_port); // socket连接服务器
;;;38 break;
;;;39
;;;40 case SOCK_ESTABLISHED: // socket处于连接建立状态
;;;41 if(getSn_IR(SOCK_TCPC) & Sn_IR_CON)
;;;42 {
;;;43 setSn_IR(SOCK_TCPC, Sn_IR_CON); // 清除接收中断标志位
;;;44 }
;;;45
;;;46 len=getSn_RX_RSR(SOCK_TCPC); // 定义len为已接收数据的长度
;;;47 if(len>0)
;;;48 {
;;;49 recv(SOCK_TCPC,ClientRecvBuff,len); // 接收来自Server的数据
;;;50 ClientRecvBuff[len]=0x00; // 添加字符串结束符
;;;51 Uart_Printf(COM1,"来自服务器数据%s\r\n",ClientRecvBuff);
;;;52
;;;53 memcpy(ClientSendBuff,"abcdefge\r\n",10);
;;;54
;;;55 send(SOCK_TCPC,ClientSendBuff,10); // 向Server发送数据
;;;56 }
;;;57 break;
;;;58
;;;59 case SOCK_CLOSE_WAIT: // socket处于等待关闭状态
;;;60 close(SOCK_TCPC);
000018 e8bd4010 POP {r4,lr}
00001c 2001 MOVS r0,#1
00001e f7ffbffe B.W close
|L1.34|
000022 481f LDR r0,|L1.160|
000024 2320 MOVS r3,#0x20 ;33
000026 2101 MOVS r1,#1 ;33
000028 8802 LDRH r2,[r0,#0] ;33 ; local_port2
00002a e8bd4010 POP {r4,lr} ;33
00002e 4608 MOV r0,r1 ;33
000030 f7ffbffe B.W socket
|L1.52|
000034 481b LDR r0,|L1.164|
000036 491c LDR r1,|L1.168|
000038 8802 LDRH r2,[r0,#0] ;37 ; remote_port
00003a e8bd4010 POP {r4,lr} ;37
00003e 2001 MOVS r0,#1 ;37
000040 f7ffbffe B.W connect
|L1.68|
000044 f2405402 MOV r4,#0x502 ;41
000048 4620 MOV r0,r4 ;41
00004a f7fffffe BL WIZCHIP_READ
00004e 07c0 LSLS r0,r0,#31 ;41
000050 d003 BEQ |L1.90|
000052 2101 MOVS r1,#1 ;43
000054 4620 MOV r0,r4 ;43
000056 f7fffffe BL WIZCHIP_WRITE
|L1.90|
00005a 2001 MOVS r0,#1 ;46
00005c f7fffffe BL getSn_RX_RSR
000060 4604 MOV r4,r0 ;46
000062 2c00 CMP r4,#0 ;47
000064 d01b BEQ |L1.158|
000066 4622 MOV r2,r4 ;49
000068 4910 LDR r1,|L1.172|
00006a 2001 MOVS r0,#1 ;49
00006c f7fffffe BL recv
000070 490e LDR r1,|L1.172|
000072 2000 MOVS r0,#0 ;50
000074 5508 STRB r0,[r1,r4] ;50
000076 460a MOV r2,r1 ;51
000078 a10d ADR r1,|L1.176|
00007a 2001 MOVS r0,#1 ;51
00007c f7fffffe BL Uart_Printf
000080 4810 LDR r0,|L1.196|
000082 a111 ADR r1,|L1.200|
000084 680a LDR r2,[r1,#0] ;53
000086 6002 STR r2,[r0,#0] ;53 ; ClientSendBuff
000088 684a LDR r2,[r1,#4] ;53
00008a 6042 STR r2,[r0,#4] ;53 ; ClientSendBuff
00008c 8909 LDRH r1,[r1,#8] ;53
00008e 8101 STRH r1,[r0,#8] ;53
000090 220a MOVS r2,#0xa ;55
000092 4601 MOV r1,r0 ;55
000094 e8bd4010 POP {r4,lr} ;55
000098 2001 MOVS r0,#1 ;55
00009a f7ffbffe B.W send
|L1.158|
;;;61 break;
;;;62 }
;;;63 }
00009e bd10 POP {r4,pc}
ENDP
|L1.160|
DCD local_port2
|L1.164|
DCD remote_port
|L1.168|
DCD remote_ip
|L1.172|
DCD ||.bss||
|L1.176|
0000b0 c0b4d7d4 DCB 192,180,215,212,183,254,206,241,198,247,202,253,190,221,"%"
0000b4 b7fecef1
0000b8 c6f7cafd
0000bc bedd25
0000bf 730d0a00 DCB "s\r\n",0
0000c3 00 DCB 0
|L1.196|
DCD ||.bss||+0x800
|L1.200|
0000c8 61626364 DCB "abcdefge\r\n",0
0000cc 65666765
0000d0 0d0a00
0000d3 00 DCB 0
AREA ||.bss||, DATA, NOINIT, ALIGN=0
ClientRecvBuff
% 2048
ClientSendBuff
% 2048
;*** Start embedded assembler ***
#line 1 "..\\..\\User\\W5100S\\tcp_client.c"
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___12_tcp_client_c_4c1dcf92____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___12_tcp_client_c_4c1dcf92____REV16| PROC
#line 130
rev16 r0, r0
bx lr
ENDP
AREA ||.revsh_text||, CODE
THUMB
EXPORT |__asm___12_tcp_client_c_4c1dcf92____REVSH|
#line 144
|__asm___12_tcp_client_c_4c1dcf92____REVSH| PROC
#line 145
revsh r0, r0
bx lr
ENDP
AREA ||.rrx_text||, CODE
THUMB
EXPORT |__asm___12_tcp_client_c_4c1dcf92____RRX|
#line 300
|__asm___12_tcp_client_c_4c1dcf92____RRX| PROC
#line 301
rrx r0, r0
bx lr
ENDP
;*** End embedded assembler ***