UCOS + uctcp/IP protocol usage notes

Source: Internet
Author: User

UCOS + uctcp/IP protocol usage notes

Http://hi.baidu.com/netee/blog/item/54fcca2c438434e58a1399f1.html

Record it for your convenience.

UCOS-TCP/IP protocol

1. Use the PHY dm9161ae, and specify the address for managing the interface interrogation in/bsp/net_bsp.h:

# Define emac_pai_phy_addr 0x13

/* The PHY used on the smartarm2300 Development Board by Zhou ligong is dm9161ae ,*/
/* The dm9161a pin is 29 28 27 26, that is, 29 28 in [0-3] is pulled up ,*/
/* CRS/phyad [4], so the address is 0x13 */

Note: most of other related Ethernet SRAM and PHY configurations are in this file.

2. the maximum length of an Ethernet frame is 1518 bytes.

Target Mac
Source Mac
Type
Data
FCs
6 bytes
6 bytes
2 bytes
46-1500 bytes
4 bytes

Therefore, the minimum value is 6 + 6 + 2 + 46 + 4 = 64, and the maximum value is 6 + 6 + 2 + 1500 + 4 = 1518.

Iii. receive TCP/IP and send buffer data:

The maximum frame size of an Ethernet frame is 1518 bytes, the size of the Ethernet SRAM receiving buffer is 1536 bytes, and the size of the array of the ram receiving RCV buffer is 1536. Therefore, after each receipt, new data comes in the SRAM receiving buffer.

Iv. Solution to compilation errors:

(1) webupgrade \ webupgrade. C (165): Error: #167: argument of type "struct sockaddr_in *" is incompatible with parameter of type "struct sockaddr *"

Solution: In ucos ii-TCP/IP, there are two socket types: struct sockaddr_in and struct sockaddr. You can use sockaddr_in to define the socket type, in the end, it needs to be converted to the sockaddr type. The conversion method is very simple. Add (struct sockaddr *) before sockaddr_in, that is

(Struct sockaddr *) sockaddr, such

Struct sockaddr_in sockaddr_inserv = {0};/* structure of the TCP server and client address */

Sockaddr_inserv.sin_family = 0;

Sockaddr_inserv.sin_port = htons (80);/* HTTP service port 80 */

Sockaddr_inserv.sin_addr.s_addr = inet_addr ("192.168.10.240 ");

BIND (mysockid, (struct sockaddr *) & sockaddr_inserv, sizeof (sockaddr_inserv ))

5. The End Of The lpc2378 chip version is by, which is the new version. in the Code, set the value of new_silicon to 1:

# Define new_silicon 1

/* For lpc2378 silicon revisions ending in AY set to 1 */

/* Previous revisions, ending in-X or-y set to 0 */

/* When 0, rmii gpio work around is enabled for old Silicon */

6. The core principle of ucosii is to put the highest priority ready tasks in the running state.

Due to sub-restrictions, omitted.

7. Modify

# Define net_sock_cfg_block_sel net_sock_block_sel_block

Is

# Define net_sock_cfg_block_sel net_sock_block_sel_no_block

Sets the socket to a non-blocking status.

It is set to a non-blocking status, so that the webpage can achieve better results in real time. If the blocked status is used, browsing the webpage may fail to open normally.

8. Ethernet 16 k ram configuration of the lpc2378: including sending buffer, receiving buffer, etc.

Set in net_nic.h in UC-TCPIP/NIC/ether/lpc2378

9. modified the netnic_txpkt function in net_nic.c.

10. Modify

Netnic_phyregwr (emac_pai_phy_addr, mii_bmcr, reg_val, Perr );

Is

Netnic_phyregwr (emac_pai_phy_addr, mii_bmcr, 0x9200, Perr );

11. Description of the EMAC Access Control phy of the lpc2378 instance:

Void netnic_phyregwr (cpu_int08u phy,

Cpu_int08u Reg,

Cpu_int16u Val,

Net_err * PERR)

This function is a function that uses EMAC to access and control the phy:

Phy: the address of the PHY that is connected to the lpc2378 instance,

Reg: registers on the PHY chip for access control,

VAL: the value that needs to be written to the Register on the PHY chip.

12. The UCOS official TCP/IP Source Code does not provide complete code for free reasons.

In net_inc.c, because the sending function for processing the if layer is not provided with information, it is always in the suspended state and cannot send packets normally. Therefore, you need to modify the function to add an interrupt processing function for it, send the corresponding semaphores to the sending function as follows:

Static void netnic_txisr_handler (void)

{

Netos_nic_txrdysignal ();
/* ISR are previusly read in netnic_isr_handler ().*/

/* ------------- Post TX complete signal -------------*/

}

13. Questions about string definition, array assignment, and address calling:

The following methods are used to define a string:

Unsigned char text1 [] = {"there are strings."}; the address of this array is & text1; or

(Unsigned char *) text1; or & text1 [0], but when & text1 [0] is used, sometimes compilation errors will occur.

Unsigned char * text1 = {"there are strings."}; l the pointer address is & text1;

14. Questions about the task stack in UCOS:

The program runs. When a task runs somewhere, it runs normally, it indicates that the size of the task stack set during initialization may be incorrect for the task running, and the stack size needs to be increased.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.