You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2021/04/12 17:25:12 UTC

[GitHub] [mynewt-core] vrahane commented on a change in pull request #2562: hw/ipc_nrf5340: Allow sending data in fragments

vrahane commented on a change in pull request #2562:
URL: https://github.com/apache/mynewt-core/pull/2562#discussion_r611818635



##########
File path: hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
##########
@@ -212,17 +204,39 @@ ipc_nrf5340_recv(int channel, ipc_nrf5340_recv_cb cb, void *user_data)
 int
 ipc_nrf5340_send(int channel, const void *data, uint16_t len)
 {
-    int rc = 0;
+    struct ipc_shm *shm;
+    uint16_t frag_len;
+    uint16_t space;
 
     assert(channel < IPC_MAX_CHANS);
+    shm = &shms[channel];
 
     if (data && len) {
-        rc = ipc_nrf5340_shm_write(&shms[channel], data, len);
-    }
+        while (len) {
+            do {
+                space = IPC_BUF_SIZE - 1;
+                space -= ipc_nrf5340_shm_get_data_length(shm->head, shm->tail);
+#if !MYNEWT_VAL(IPC_NRF5340_BLOCKING_WRITE)
+                /* assert since that will always fail for non-blocking write indicating
+                 * use error
+                 */
+                assert(data_len <= IPC_BUF_SIZE);
+                if (data_len > space) {
+                    return -ENOMEM;

Review comment:
       I think we should be using `SYS_ENOMEM` here.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org