You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "zhhyu7 (via GitHub)" <gi...@apache.org> on 2024/10/26 21:43:46 UTC
[PR] examples/netpkt: add ethercat test example for robot [nuttx-apps]
zhhyu7 opened a new pull request, #2777:
URL: https://github.com/apache/nuttx-apps/pull/2777
## Summary
add a simple example to test ethercat's sending and receiving.
## Impact
## Testing
x86_64 device
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] examples/netpkt: add ethercat test example for robot [nuttx-apps]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #2777:
URL: https://github.com/apache/nuttx-apps/pull/2777
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] examples/netpkt: add ethercat test example for robot [nuttx-apps]
Posted by "zhhyu7 (via GitHub)" <gi...@apache.org>.
zhhyu7 commented on code in PR #2777:
URL: https://github.com/apache/nuttx-apps/pull/2777#discussion_r1817963273
##########
examples/netpkt/netpkt_ethercat.c:
##########
@@ -0,0 +1,114 @@
+/****************************************************************************
+ * apps/examples/netpkt/netpkt_ethercat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+#include <time.h>
+
+#include <net/if.h>
+#include <netinet/ip.h>
+#include <netpacket/packet.h>
+#include <sys/socket.h>
+
+#include <nuttx/clock.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, FAR const char *argv[])
+{
+ struct timespec send_time;
+ struct timespec recv_time;
+ struct sockaddr_ll addr;
+ uint8_t sendbuff[60] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9c, 0x7f, 0x81, 0x3c, 0x1e, 0x8e,
+ 0x88, 0xa4, 0x0e, 0x10, 0x07, 0x4a, 0x00, 0x00, 0x30, 0x01, 0x02, 0x00,
+ };
+
+ uint8_t recvbuff[100];
+ FAR const char *ifname = "eth0";
+ int repeat = 10;
+ int num_packets = 0;
+ int len;
+ int ifindex;
+ int sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);
+
+ if (sockfd == -1)
+ {
+ perror("ERROR: creating socket failed");
+ return -errno;
+ }
+
+ if (argc >= 2)
+ {
+ ifname = argv[1];
Review Comment:
> assigning variable length input to const char[4] ?
Is it modified like this `int main(int argc, FAR const char *argv[4])`? Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] examples/netpkt: add ethercat test example for robot [nuttx-apps]
Posted by "cederom (via GitHub)" <gi...@apache.org>.
cederom commented on code in PR #2777:
URL: https://github.com/apache/nuttx-apps/pull/2777#discussion_r1817956260
##########
examples/netpkt/netpkt_ethercat.c:
##########
@@ -0,0 +1,114 @@
+/****************************************************************************
+ * apps/examples/netpkt/netpkt_ethercat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+#include <time.h>
+
+#include <net/if.h>
+#include <netinet/ip.h>
+#include <netpacket/packet.h>
+#include <sys/socket.h>
+
+#include <nuttx/clock.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, FAR const char *argv[])
+{
+ struct timespec send_time;
+ struct timespec recv_time;
+ struct sockaddr_ll addr;
+ uint8_t sendbuff[60] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9c, 0x7f, 0x81, 0x3c, 0x1e, 0x8e,
+ 0x88, 0xa4, 0x0e, 0x10, 0x07, 0x4a, 0x00, 0x00, 0x30, 0x01, 0x02, 0x00,
+ };
+
+ uint8_t recvbuff[100];
+ FAR const char *ifname = "eth0";
+ int repeat = 10;
+ int num_packets = 0;
+ int len;
+ int ifindex;
+ int sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);
+
+ if (sockfd == -1)
+ {
+ perror("ERROR: creating socket failed");
+ return -errno;
+ }
+
+ if (argc >= 2)
+ {
+ ifname = argv[1];
Review Comment:
assigning variable length input to const char[4] ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] examples/netpkt: add ethercat test example for robot [nuttx-apps]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #2777:
URL: https://github.com/apache/nuttx-apps/pull/2777#discussion_r1817968373
##########
examples/netpkt/netpkt_ethercat.c:
##########
@@ -0,0 +1,114 @@
+/****************************************************************************
+ * apps/examples/netpkt/netpkt_ethercat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+#include <time.h>
+
+#include <net/if.h>
+#include <netinet/ip.h>
+#include <netpacket/packet.h>
+#include <sys/socket.h>
+
+#include <nuttx/clock.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, FAR const char *argv[])
+{
+ struct timespec send_time;
+ struct timespec recv_time;
+ struct sockaddr_ll addr;
+ uint8_t sendbuff[60] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9c, 0x7f, 0x81, 0x3c, 0x1e, 0x8e,
+ 0x88, 0xa4, 0x0e, 0x10, 0x07, 0x4a, 0x00, 0x00, 0x30, 0x01, 0x02, 0x00,
+ };
+
+ uint8_t recvbuff[100];
+ FAR const char *ifname = "eth0";
+ int repeat = 10;
+ int num_packets = 0;
+ int len;
+ int ifindex;
+ int sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);
+
+ if (sockfd == -1)
+ {
+ perror("ERROR: creating socket failed");
+ return -errno;
+ }
+
+ if (argc >= 2)
+ {
+ ifname = argv[1];
Review Comment:
why make this change? all.main should havr the same prototype
int main(int argc, char *argv[]);
##########
examples/netpkt/netpkt_ethercat.c:
##########
@@ -0,0 +1,114 @@
+/****************************************************************************
+ * apps/examples/netpkt/netpkt_ethercat.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+#include <time.h>
+
+#include <net/if.h>
+#include <netinet/ip.h>
+#include <netpacket/packet.h>
+#include <sys/socket.h>
+
+#include <nuttx/clock.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, FAR const char *argv[])
+{
+ struct timespec send_time;
+ struct timespec recv_time;
+ struct sockaddr_ll addr;
+ uint8_t sendbuff[60] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9c, 0x7f, 0x81, 0x3c, 0x1e, 0x8e,
+ 0x88, 0xa4, 0x0e, 0x10, 0x07, 0x4a, 0x00, 0x00, 0x30, 0x01, 0x02, 0x00,
+ };
+
+ uint8_t recvbuff[100];
+ FAR const char *ifname = "eth0";
+ int repeat = 10;
+ int num_packets = 0;
+ int len;
+ int ifindex;
+ int sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);
+
+ if (sockfd == -1)
+ {
+ perror("ERROR: creating socket failed");
+ return -errno;
+ }
+
+ if (argc >= 2)
+ {
+ ifname = argv[1];
Review Comment:
why make this change? all.main should have the same prototype
int main(int argc, char *argv[]);
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] examples/netpkt: add ethercat test example for robot [nuttx-apps]
Posted by "nuttxpr (via GitHub)" <gi...@apache.org>.
nuttxpr commented on PR #2777:
URL: https://github.com/apache/nuttx-apps/pull/2777#issuecomment-2439747413
[**\[Experimental Bot, please feedback here\]**](https://github.com/search?q=repo%3Aapache%2Fnuttx+13552&type=issues)
The provided PR description **partially meets** the NuttX requirements.
**Here's what's good:**
* **Summary:** It clearly states the purpose of the PR - adding a test example for EtherCAT.
* **Testing:** It mentions the build host (x86_64) and implies the target is a device (presumably running NuttX). However, more details are needed (see below).
**Here's what needs improvement:**
* **Summary:**
* **What functional part?** Be specific about which part of the codebase (e.g., drivers/net/ethercat/) is affected.
* **How does it work?** Briefly describe the example's logic - what data is sent/received, how it's verified, etc.
* **Related issues/PRs:** Link any relevant issues or PRs in the NuttX or NuttX-Apps repositories.
* **Impact:** Address **ALL** impact points, even if the answer is "NO." Provide brief explanations for "YES" answers:
* **New feature?** This seems like a "YES" - clarify if it's for users or just for development/testing.
* **User impact?** Likely "NO" if it's just a test example, but confirm.
* **Build impact?** Does this add any new build dependencies or options?
* **Hardware impact?** Does this example require specific hardware or EtherCAT configurations?
* **Documentation impact?** Does this example warrant an update or addition to the documentation?
* **Security impact?** Unlikely, but analyze if the example handles any sensitive data.
* **Compatibility impact?** Unlikely, but analyze if it introduces any changes to the EtherCAT interface.
* **Testing:**
* **Target:** Specify the exact architecture (e.g., ARM Cortex-M4), board, and configuration used for testing.
* **Logs:** Instead of placeholder comments, include **actual** relevant log snippets from before and after the change. These logs should demonstrate the example's functionality.
**Recommendation:**
Revise the PR description to address the missing information and provide more specific details. A well-structured and informative PR description increases the chances of quick review and merging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org