Ping to WCH board

How to ping from WCH board?

By ‘ping’, do you mean a network ‘ping’, i.e. this: https://en.wikipedia.org/wiki/Ping_(networking_utility) ?

Which WCH board are you using?

Do you have an ethernet connection, or maybe a Wifi connection, either on that board or externally connected?

Did you add a network stack to your project?

All of these are necessary to get a network ‘ping’ to work on any board.

Hi thanks for reply @ygramoel … Here are the answers to your queries.
Yes ping means i want to check network connection. (for ex, ping www.google.com). I am using CH32V307VCT6 board i have an ethernet connection and tcp client server code working on it. How can i send ping command to WCH board because there is no command line tool for WCH so how to implement ping on that? I tried to run example IPRaw_ping but not able to create socket it shows timeout

Hi @Namrata,

You are right: you don’t have a command line on your WCH. That is: unless you want to install Linux with something like BusyBox, or similar, which is probably a bit too much code for this MCU …

So you will have to implement ping functionality in C/C++, or find code for it that works with the network stack you are using. ping is implemented on top of the IP protocol (which you already have), and uses ICMP instead of TCP; see for example the Wikipedia link in my previous reply.

There are two distinct things you can two: configure your network stack so that it replies to ping requests, or add code so that it send ping requests to an external server like www.google.com. The details for both will be specific for the network stack (TCP/IP implementation) you are using.

If all you want to do is to check that your TCP/IP implementation is working, you can also try to connect to your desktop/laptop. Just write some application code that establishes a connection to a port with your IP address. If you are using Linux, e.g. run netcat nc on your desktop/laptop.

Hi… @ygrameol thanks for your quick response. I have mainly two queries:-

  1. if(WCHNET_QueryGlobalInt())
    {
    WCHNET_HandleGlobalInt();
    }
    These handler mainly check the connection and return the result weather it is connected, dissconnected or timeout. I dont have function definitions as this function are of WCHNET library. So my question is what actually this function is doing internally to check connection status? Is it waiting for ACK from socket or what. I mean how this function test connection?

  2. How can i check internet connectivity of WCH other than socket method. I am able to get DHCP ip from ethernet but is there any way to check network connectivity for ex, google.com or anyhow i want to confirm internet connectivity?

  3. I tried to run IPRaw_Ping example by configuring network stack but somehow it is not getting handler for connection and shows ping send fail status(checked with DHCP also). Assuming that my network stack is configured properly because i am able to ping to same network from my Pc.In this queryglobalint() called once while it find ethernet.Am i missing any configuration in example?

1 It seems that WCH Network library source code is not provided
WCHNET_QueryGlobalInt only mentioned in documentation

Function Query global interrupt status. For specific status codes, please refer to wchnet.h.

so can’t answer how it works internally.
2 DNS lookout should be enough to tell it you have internet connection.
3 IPRaw_Ping I checked the example and it seems to wait for ping and response to it. Can’t help much further with that.

Hi @Namrata ,
The network functionality on your WCH board will not work, unless you switch to the latest WCH compiler. Please refer to the steps here:
https://embeetle.com/#supported-hardware/wch/compiler

Kind regards,
Kristof

Hi… Thanks @kristof and @roboter your answers helps me a lot.