[. Net MF network development board research-01] IP Address Setting and simple web demonstration

Source: Internet
Author: User
Tags stringreplace

The Development Board launched earlier does not have a network port. Therefore, many network-based functions of the. NET micro framework cannot be studied. In the IOT era, network functions are king.

In addition to the Ethernet module, the New Development Board also adds the USB Host module and other related interfaces. For details, see:

Because the Development Board is based on the Cortex-M3 kernel, MF Kernel Program (tinyclr) is deployed on the flash in the chip, but the flash in the chip is generally limited in capacity, so there is no port tinybooter, in this way, the network configuration function of mfdeploy is unavailable. Therefore, I added the code module for network configuration to the tinyclr code, and upgraded the yfaccessflash tool for synchronization, this allows you to easily configure the IP address of the Development Board and other related parameters.

The configuration method is as follows:

Click network config to go to the IP configuration page, as shown in:

After the configuration is successful, the Development Board restarts automatically to make the new configuration take effect.

1. the firmware version must be later than v0.9.05 to support IP configuration.

Http://www.sky-walker.com.cn/MFRelease/firmware/mfv41_firmware_hy_redbull.rar

2. The yfaccessflash tool must be later than v2.0.2.1 to support IP configuration.

Http://www.sky-walker.com.cn/MFRelease/Tools/YFAccessFlash.rar

3. You must use er_config in the yfaccessflash Deployment Tool. Otherwise, the Development Board encounters an exception when configuring the IP address.

See http://www.sky-walker.com.cn/MFRelease/document/MFManual_V2.0.pdf

This manual describes how to deploy er_config.

 

After the Development Board runs, we use a PC to ping the test. The effect is as follows:

When the network is ready, we perform simple programming to create a simple and practical Web server.

The modified code is as follows:

Private void processrequest ()

{

Const int32 c_microsecondspersecond = 1000000;

// 'Using' ensures that the client's socket gets closed.

Using (m_clientsocket)

{

// Wait for the client request to start to arrive.

Byte [] buffer = new byte [1024];

If (m_clientsocket.poll (5 * c_microsecondspersecond,

Selectmode. selectread ))

{

// If 0 bytes in buffer, then the connection has been closed,

// Reset, or terminated.

If (m_clientsocket.available = 0) return;

// Read the first chunk of the request (we don't actually do

// Anything with it ).

Int32 bytesread = m_clientsocket.receive (buffer,

M_clientsocket.available, socketflags. None );

 

// Return a static HTML document to the client.

String scrhtml = resource1.getstring (resource1.stringresources. webpage );

String [] scrhtml_lines = scrhtml. Split ('\ R ');

String objhtml = "", strtemp = "";

 

ADC. Start (0); // adc0

ADC. Read (14, out mysocketserver. ad8, 2, 0 );

ADC. Stop (0 );

 

Mysocketserver. AD7 = mysocketserver. ad8 * 490/4096;

Mysocketserver. AD1 + = 1;

If (mysocketserver. AD1> 10) mysocketserver. AD1 = 0;

Foreach (string line in scrhtml_lines)

{

If (line. length> 0)

{

Strtemp = line;

If (line. indexof ("ad8 %")> 0) strtemp = stringreplace (line, "ad8 %", mysocketserver. ad8.tostring ());

If (line. indexof ("AD7 %")> 0) strtemp = stringreplace (line, "AD7 %", mysocketserver. ad7.tostring ());

If (line. indexof ("AD1 %")> 0) strtemp = stringreplace (line, "AD1 %", mysocketserver. ad1.tostring ());

Objhtml + = strtemp + "\ r ";

}

}

M_clientsocket.send (encoding. utf8.getbytes (objhtml ));

}

}

}

Enter http: // 192.168.0.100/In the IE browser to display the following interface:

Select the analog input button on the Development Board, and the progress bar will change dynamically.

In the next article, we will introduce HTTP server-related content.

Bytes -------------------------------------------------------------------------------------------------------------------------

Source code/Documentation: http://www.sky-walker.com.cn/MFRelease/Sample/YFSocketServer.rar

Mf Forum: http://space.cnblogs.com/group/MFSoft/

Mf Development Board: http://item.taobao.com/item.htm? Id = 7117999726

Network Board: http://item.taobao.com/item.htm? Id = 10919470266

QQ group: 127465602 (full) 146524112

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.