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/04/07 08:56:40 UTC

[PR] net/can: deliver data into multiple CAN conn bound to same dev [nuttx]

zhhyu7 opened a new pull request, #12089:
URL: https://github.com/apache/nuttx/pull/12089

   ## Summary
   Because CAN is a broadcast protocol, each conn needs to be given independent data to avoid mutual interference.
   
   ## Impact
   
   ## Testing
   sim:local
   


-- 
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] net/can: deliver data into multiple CAN conn bound to same dev [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #12089:
URL: https://github.com/apache/nuttx/pull/12089


-- 
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] net/can: deliver data into multiple CAN conn bound to same dev [nuttx]

Posted by "zhhyu7 (via GitHub)" <gi...@apache.org>.
zhhyu7 commented on code in PR #12089:
URL: https://github.com/apache/nuttx/pull/12089#discussion_r1555140064


##########
net/can/can_input.c:
##########
@@ -151,50 +152,96 @@ const uint8_t len_to_can_dlc[65] =
  *
  ****************************************************************************/
 
-static int can_in(struct net_driver_s *dev)
+static int can_input_conn(FAR struct net_driver_s *dev,
+                          FAR struct can_conn_s *conn)
 {
-  FAR struct can_conn_s *conn = NULL;
-  int ret = OK;
+  uint16_t flags;
   uint16_t buflen = dev->d_len;
+  int ret = OK;
+
+  /* Setup for the application callback */
 
-  do
+  dev->d_appdata = dev->d_buf;
+  dev->d_sndlen  = 0;
+  dev->d_len     = buflen;
+
+  /* Perform the application callback */
+
+  flags = can_callback(dev, conn, CAN_NEWDATA);
+
+  /* If the operation was successful, the CAN_NEWDATA flag is removed
+   * and thus the packet can be deleted (OK will be returned).
+   */
+
+  if ((flags & CAN_NEWDATA) != 0)
     {
-      conn = can_nextconn(conn);
+      /* No.. the packet was not processed now.  Return -EAGAIN so
+       * that the driver may retry again later.  We still need to
+       * set d_len to zero so that the driver is aware that there
+       * is nothing to be sent.
+       */
 
-      if (conn && (conn->dev == NULL || dev == conn->dev))
-        {
-          uint16_t flags;
+        nwarn("WARNING: Packet not processed\n");
+        ret = -EAGAIN;

Review Comment:
   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] net/can: deliver data into multiple CAN conn bound to same dev [nuttx]

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #12089:
URL: https://github.com/apache/nuttx/pull/12089#discussion_r1555081664


##########
net/can/can_input.c:
##########
@@ -151,50 +152,96 @@ const uint8_t len_to_can_dlc[65] =
  *
  ****************************************************************************/
 
-static int can_in(struct net_driver_s *dev)
+static int can_input_conn(FAR struct net_driver_s *dev,
+                          FAR struct can_conn_s *conn)
 {
-  FAR struct can_conn_s *conn = NULL;
-  int ret = OK;
+  uint16_t flags;
   uint16_t buflen = dev->d_len;
+  int ret = OK;
+
+  /* Setup for the application callback */
 
-  do
+  dev->d_appdata = dev->d_buf;
+  dev->d_sndlen  = 0;
+  dev->d_len     = buflen;
+
+  /* Perform the application callback */
+
+  flags = can_callback(dev, conn, CAN_NEWDATA);
+
+  /* If the operation was successful, the CAN_NEWDATA flag is removed
+   * and thus the packet can be deleted (OK will be returned).
+   */
+
+  if ((flags & CAN_NEWDATA) != 0)
     {
-      conn = can_nextconn(conn);
+      /* No.. the packet was not processed now.  Return -EAGAIN so
+       * that the driver may retry again later.  We still need to
+       * set d_len to zero so that the driver is aware that there
+       * is nothing to be sent.
+       */
 
-      if (conn && (conn->dev == NULL || dev == conn->dev))
-        {
-          uint16_t flags;
+        nwarn("WARNING: Packet not processed\n");
+        ret = -EAGAIN;

Review Comment:
   ```suggestion
         nwarn("WARNING: Packet not processed\n");
         ret = -EAGAIN;
   ```



-- 
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