4271 views|7 replies

1412

Posts

3

Resources
The OP
 

About LWIP (LAN8720) network data transmission problem [Copy link]

When doing system testing, I found that when LWIP (LAN8720) sends hexadecimal data, when there is 0x00 in the sent data, the network determines that a string of data has ended.
For example, the sent data is: aa 55 05 00 00 00 03 00 05 00 12 55 aa. Through debugging, the network only sends aa 55 05, and the following data is not sent.
This means that when encountering 0x00, the network considers it to be empty data.


Now the question is, what if I want to send data 0?
If a two-byte number is sent, for example, the number 3, the hexadecimal is 00 03, how to send it?


I hope to get an answer, urgent~~

This post is from stm32/stm8

Latest reply

This post was last edited by Ansersion on 2019-8-29 11:45 annysky2012 posted on 2019-8-29 09:58 The strlen function is indeed used, but the number I sent is 0, not '\0'! ! ! Why is this? '\0' == 0 That's not the number 0. The ASCII code for the number 0 is 48. Another common mistake is to use strcpy as memcpy, which will also cause truncation.   Details Published on 2019-8-29 11:43
Personal signature

没有什么不可以,我就是我,不一样的烟火! 

 

98

Posts

0

Resources
2
 

Are you really using the native interface of LWIP (write/send)? The native interface must have the size of the data to be sent, such as write (int fd, const void * buf, size_t count); It seems that you are using an encapsulated interface, and there are string processing functions such as strlen in the interface that truncate the sent data.

This post is from stm32/stm8

Comments

The strlen function is indeed used, but I sent the number 0, not '\0'! ! ! Why is that?  Details Published on 2019-8-29 09:58
 
 

140

Posts

0

Resources
3
 

The above situation will not occur when using the write function.

This post is from stm32/stm8

Comments

I haven't tried it, I'll try it  Details Published on 2019-8-29 10:15
I haven't tried it, I'll try it  Details Published on 2019-8-29 09:59
 
 

1412

Posts

3

Resources
4
 
Ansersion Published on 2019-8-28 09:38 Are you really using the native interface of LWIP (write/send)? The native interface must have the size of the data to be sent, such as write (int fd, const v ...

The strlen function is indeed used, but I sent the number 0, not '\0'! ! ! Why is that?

This post is from stm32/stm8

Comments

'\0' == 0 Another common mistake is to use strcpy as memcpy, which will also cause truncation.  Details Published on 2019-8-29 11:43
 
Personal signature

没有什么不可以,我就是我,不一样的烟火! 

 
 

1412

Posts

3

Resources
5
 
Pirates of the Caribbean published on 2019-8-28 10:38 The above situation will not occur when using the write function.

I haven't tried it, I'll try it

This post is from stm32/stm8
 
Personal signature

没有什么不可以,我就是我,不一样的烟火! 

 
 

1412

Posts

3

Resources
6
 
Pirates of the Caribbean published on 2019-8-28 10:38 The above situation will not occur when using the write function.

I haven't tried this yet, I'll try it

This post is from stm32/stm8
 
Personal signature

没有什么不可以,我就是我,不一样的烟火! 

 
 

98

Posts

0

Resources
7
 
This post was last edited by Ansersion on 2019-8-29 11:45
annysky2012 posted on 2019-8-29 09:58 The strlen function is indeed used, but the number I sent is 0, not '\0'! ! ! Why is this?

'\0' == 0

That's not the number 0. The ASCII code for the number 0 is 48.

Another common mistake is to use strcpy as memcpy, which will also cause truncation.

This post is from stm32/stm8

Comments

That makes a lot of sense. When I sent data, I used strlen to determine the length of the data to be sent and to apply for memory. Logically, it should be applied by bytes. I confused strlen and sizeof. Now the problem has been solved, thank you!  Details Published on 2019-8-30 11:25
 
 
 

1412

Posts

3

Resources
8
 
Ansersion posted on 2019-8-29 11:43 annysky2012 posted on 2019-8-29 09:58 The strlen function is indeed used, but the number I sent is 0, not '\0&rsqu ...

That makes a lot of sense. When I sent data, I used strlen to determine the length of the data to be sent and to apply for memory. Logically, it should be applied by bytes. I confused strlen and sizeof. Now the problem has been solved, thank you!

This post is from stm32/stm8
 
Personal signature

没有什么不可以,我就是我,不一样的烟火! 

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list