请教一个关于STM32F103和Ethernet Shield W5100的问题
我最近在使用STM32F103和Ethernet Shield W5100模块进行测试,在mbed官网的在线平台上有一个相关例程,https://developer.mbed.org/teams/shields/code/Seeed_Ethernet_Shield/
我连接上两个模块,并编译成功了这个例程。在例程中有很多printf的语句,如
printf(">>> Could not initialise. Halting!\n");
printf(">>> Get IP address...\n");
printf(">>> Got IP address: %s\n", eth.getIPAddress());
但是我不知道该如何查看测试的结果??我看到一些资料说要在浏览器里输入IP地址查看,但是我该输入什么呢?例程中并没有设定是哪个地址?想请教下我该如何查看或者设置?谢谢!
以下是全部例程代码
#include "mbed.h"
#include "WIZ820ioInterface.h"
Serial pc(USBTX, USBRX);
/**
* D11 - MOSI pin
* D12 - MISO pin
* D13 - SCK pin
* D10 - SEL pin
* NC - Reset pin; use D5 otherwise the shield might get into reset loop
*/
WIZ820ioInterface eth(D11, D12, D13, D10, D5);
int main()
{
wait(3);
// Initialize the interface.
// If no param is passed to init() then DHCP will be used on connect()
int s = eth.init();
if (s != NULL) {
printf(">>> Could not initialise. Halting!\n");
exit(0);
}
printf(">>> Get IP address...\n");
while (1) {
s = eth.connect(); // Connect to network
if (s == false || s < 0) {
printf(">>> Could not connect to network! Retrying ...\n");
wait(3);
} else {
break;
}
}
printf(">>> Got IP address: %s\n", eth.getIPAddress());
// Prepare the http request to mbed.org
printf(">>> Open socket to mbed.org:80\n");
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
TCPSocketConnection sock;
while (sock.connect("mbed.org", 80) == -1) {
printf(">>> Unable to open socket! Retrying ...\n");
};
printf(">>> Request %s\n", http_cmd);
sock.send_all(http_cmd, sizeof(http_cmd)-1);
// Read the response
char buffer;
int ret;
while (true) {
ret = sock.receive(buffer, sizeof(buffer)-1);
if (ret <= 0)
break;
buffer = '\0';
printf(">>> Received %d chars from mbed.org:\n%s\n", ret, buffer);
}
printf(">>> Close socket\n");
sock.close();
// Disconnect from network
printf(">>> Disconnect from network\n");
eth.disconnect();
return 0;
}
页:
[1]