<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX Processors中的主题 Re: TCP Socket API over ethernet for imxrt1176</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1683832#M208862</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using iMXRT1176 (imxrt 1170 EVK board). I have attached the socket function modified and also the python server code. Please find the attachment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Devaharsha&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jul 2023 09:04:03 GMT</pubDate>
    <dc:creator>Devaharsha</dc:creator>
    <dc:date>2023-07-07T09:04:03Z</dc:date>
    <item>
      <title>TCP Socket API over ethernet for imxrt1176</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1681960#M208700</link>
      <description>&lt;P&gt;Hi&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://community.nxp.com/t5/user/viewprofilepage/user-id/21410" target="_blank"&gt;@kerry&lt;/A&gt;zhou&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Continuation to this thread:&amp;nbsp;&lt;A href="https://community.nxp.com/t5/i-MX-Processors/Using-Socket-API-in-imxrt1176/m-p/1681959#M208699" target="_blank"&gt;https://community.nxp.com/t5/i-MX-Processors/Using-Socket-API-in-imxrt1176/m-p/1681959#M208699&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for late reply.&lt;/P&gt;&lt;P&gt;Thanks for the files. I have written the client socket code as you mentioned in the attached file. And I am running a server on my laptop written using python. Everything is working fine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I am facing is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;1) When I am trying to receive data over socket, its not receiving correctly. Like if I am sending "Hello", its receiving as "Hell" or "llo", etc.&amp;nbsp;Though its receiving correctly also sometimes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Correct me if I am wrong, I suspect a problem is in:&lt;/P&gt;&lt;P&gt;1) Send socket is done using server which is executing send function in an infinite for loop without delay.&lt;/P&gt;&lt;P&gt;2) Recv function is executing on imxrt1176 with 1ms task delay.&lt;/P&gt;&lt;P&gt;3) Is the issue related to timing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;and also if I want to set socket in non-blocking state, I can't see any non-blocking option under setsockopt() function. But in send and recv function, under flags parameters it can be given. Is it correct or I am missing something?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2023 10:35:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1681960#M208700</guid>
      <dc:creator>Devaharsha</dc:creator>
      <dc:date>2023-07-05T10:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: TCP Socket API over ethernet for imxrt1176</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1683628#M208838</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/201385"&gt;@Devaharsha&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Thanks for your cooperation for the new question post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Now, your test platform is NXP MIMXT1170-EVK? Or EVKB, please let me know your board.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Please also attach your modified socket project for the RT1170, I will find time to test it, I will also use the 3rd part tool to transfer the data to the board socket recevie, in the previous time which I am testing the RT1060, I didn't meet the receive issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; So, for the RT1170 socket, I also need to find time to test it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You also can share your &lt;SPAN&gt;python testing tool to me for testing.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 05:06:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1683628#M208838</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2023-07-07T05:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: TCP Socket API over ethernet for imxrt1176</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1683832#M208862</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using iMXRT1176 (imxrt 1170 EVK board). I have attached the socket function modified and also the python server code. Please find the attachment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Devaharsha&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 09:04:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1683832#M208862</guid>
      <dc:creator>Devaharsha</dc:creator>
      <dc:date>2023-07-07T09:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: TCP Socket API over ethernet for imxrt1176</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1683908#M208871</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/201385"&gt;@Devaharsha&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; So sorry for my later reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Talk about your issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You already can receive the data, and just can't receive it complete, it means your socket already works, I think it is related to the time, you mentioned task is 1ms delay, I think it is not enough, please use long time, eg, 1s, then test it again.&lt;/P&gt;
&lt;P&gt;In the previous time, I have even test the socket to receive a lot of data, it also works, you can check my post:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/i-MX-RT-Knowledge-Base/The-RT-speech-recognition-system-based-on-VIT-to-obtain-weather/ta-p/1513203" target="_blank"&gt;https://community.nxp.com/t5/i-MX-RT-Knowledge-Base/The-RT-speech-recognition-system-based-on-VIT-to-obtain-weather/ta-p/1513203&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The related function is:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;static void
weather_thread(void *arg)
{
	  int sock = -1,rece;
	  struct sockaddr_in client_addr;

	  char* host_ip;
	  ip4_addr_t dns_ip;
	  err_t err;

	  uint32_t *pSDRAM= pvPortMalloc(BUF_LEN);//
//==============
//DNS resolving have issues
#if 0
	    if (ipaddr_aton(HOST_NAME, &amp;amp;dns_ip) &amp;amp;&amp;amp; IP_IS_V4(&amp;amp;dns_ip))
	    {
	        /* Already an IP address */
	        err = ERR_OK;
	    }
	    else
	    {
	        /* Resolve MQTT broker's host name to an IP address */
	        PRINTF("Resolving \"%s\"...\r\n", HOST_NAME);
	        err = netconn_gethostbyname(HOST_NAME, &amp;amp;dns_ip);
	    }
	    PRINTF("host name : %s , host_ip : %s\r\n",HOST_NAME,host_ip);
#endif
//===================
	#ifdef  LWIP_DNS
	    ip4_addr_t dns_ip;
	    netconn_gethostbyname(HOST_NAME, &amp;amp;dns_ip);
	    host_ip = ip_ntoa(&amp;amp;dns_ip); //DSN get IP
	    // host_ip = IP_ADDR;
	    PRINTF("host name : %s , host_ip : %s\r\n",HOST_NAME,host_ip);
	#else
	    host_ip = HOST_NAME;
	    PRINTF("host name : %s , host_ip : %s\r\n",HOST_NAME,host_ip);
	#endif

	  while(1)
	  {
	  //add the command request, only cmd == weather flag, then call it.
        if((weather_data.ww_flag ==  1))
        {
    	 if(weather_data.vc_index &amp;gt;= 3)
    	 {

		   // create connection
	       sock = socket(AF_INET, SOCK_STREAM, 0);
	       if (sock &amp;lt; 0)
	       {
	         PRINTF("Socket error\n");
	         vTaskDelay(10);
	         continue;
	        }
	       client_addr.sin_family = AF_INET;
	       client_addr.sin_port = htons(PORT);
	       client_addr.sin_addr.s_addr = inet_addr(host_ip);
	       memset(&amp;amp;(client_addr.sin_zero), 0, sizeof(client_addr.sin_zero));


	       if (connect(sock, (struct sockaddr *)&amp;amp;client_addr,  sizeof(struct sockaddr)) == -1)
	       {
	          PRINTF("Connect failed!\n");
	          closesocket(sock);
	          vTaskDelay(10);
	          continue;
	       }

	       PRINTF("Connect to server successful!\r\n");

	       //  PRINTF("\r\n************************************************************\n\r");
	       //  PRINTF("\r\n Begin write\n\r");
	       write(sock,get_weather,sizeof(get_weather));
	       while (1)
	       {
		      //receive data
	          rece = recv(sock, (uint8_t*)pSDRAM, BUF_LEN, 0);//BUF_LEN
	          if (rece &amp;lt;= 0)
	            break;

	           //  PRINTF("%s\n",(uint8_t*)pSDRAM);
               memcpy(weather_data.weather_info, pSDRAM,1500);//max 1457
	           //   PRINTF("---rece=%d\n",rece);
	           //   PRINTF("\r\n*******************receive data*******************************\n\r");

	       }
	      //   PRINTF("\r\n***************************end*******************************\n\r");

	       //weather process
	       Weather_process();

	       memset(pSDRAM,0,BUF_LEN);
	       closesocket(sock);
    	 }
         //clean data
	     memset(weather_data.weather_info, 0, sizeof(weather_data.weather_info));
 	     weather_data.ww_flag = 0;
 	     weather_data.vc_index = 0;
        }

	    vTaskDelay(10000);//about 10s //10000
	  }


}&lt;/LI-CODE&gt;
&lt;P&gt;You can see, I even use 10s, as my data is large.&lt;/P&gt;
&lt;P&gt;I also test the RT1170 socket on my side, but seems recently, our IT limit the ENET cable, so my office PC even connection have issues, but I am sure my code is the correct one, as I have tested previously when the PC have no enet limit.&lt;/P&gt;
&lt;P&gt;So, you can refer to my above code, use long delay, and try it again.&lt;/P&gt;
&lt;P&gt;Wish it helps you!&lt;BR /&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 05:35:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1683908#M208871</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2023-07-14T05:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: TCP Socket API over ethernet for imxrt1176</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1690126#M209480</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/201385"&gt;@Devaharsha&lt;/a&gt;&amp;nbsp;，&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Good news to you, I write a socket client project and document, which can resolved your mentioned issues:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/i-MX-RT-Knowledge-Base/RT1170-LWIP-socket-client-demo/ta-p/1690055" target="_blank"&gt;https://community.nxp.com/t5/i-MX-RT-Knowledge-Base/RT1170-LWIP-socket-client-demo/ta-p/1690055&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wish it helps you!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;kerry&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 07:24:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1690126#M209480</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2023-07-21T07:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: TCP Socket API over ethernet for imxrt1176</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1691002#M209562</link>
      <description>&lt;P&gt;Thank you. The code is modified as you have sent before and it's working totally fine, even with delay of 1ms.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 05:18:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1691002#M209562</guid>
      <dc:creator>Devaharsha</dc:creator>
      <dc:date>2023-07-24T05:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: TCP Socket API over ethernet for imxrt1176</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1691007#M209564</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/201385"&gt;@Devaharsha&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Cool! Thanks for your positive feedback, that also gives me more confidence to write more documents with my own experience in the community.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;If you meet any issues in the future, welcome to create the new questions post, thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 05:26:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/TCP-Socket-API-over-ethernet-for-imxrt1176/m-p/1691007#M209564</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2023-07-24T05:26:31Z</dc:date>
    </item>
  </channel>
</rss>

