This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] SK-AM62:我想在我自己的工程中使用 ti-rpmsg-char

Guru**** 2430950 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1537896/sk-am62-i-want-to-use-ti-rpmsg-char-in-my-own-project

器件型号:SK-AM62


工具/软件:

您好、
Im 处理的工程使用了 rpmsg/ti-rpmsg-char。 此选项在运行时投影单个。 但我想说明如何实现与我自己的工程相同的功能、即我自己的工程具有更多功能、并且使用 rpmsg 与 MCU 进行通信、这是该工程包含的特性之一。 我在努力实现它。

此致、
Bawantha.

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    大家好、为了更好地了解您是在 Linux Processor SDK 还是在 MCU+RTOS SDK 上进行开发?

    谢谢您、

    Paula

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、
    很抱歉、我忘了提及它。 正在 Linux Processor SDK 上进行开发。 我做了一些挖掘,并找到了一种方法来做到这一点。 您能确认这是否是最好的方法吗

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <errno.h>
    
    #define RPMSG_DEVICE "/dev/rpmsg0"
    #define GET_COMMAND "GET_DATA\n"
    #define BUFFER_SIZE 128
    #define POLL_INTERVAL_SEC 4000  // Delay between requests in microseconds
    
    void rpmsg_poll_loop(void) {
        int fd;
        char buffer[BUFFER_SIZE];
        ssize_t bytes_written, bytes_read;
    
        // Open RPMsg device
        fd = open(RPMSG_DEVICE, O_RDWR);
        if (fd < 0) {
            perror("Error opening RPMsg device");
            return;
        }
    
        printf("Starting continuous RPMsg polling...\n");
    
        while (1) {
            // Send "GET DATA\n" to MCU
            bytes_written = write(fd, GET_COMMAND, strlen(GET_COMMAND));
            if (bytes_written < 0) {
                perror("Error writing to RPMsg device");
                break;
            }
    
            printf("Sent: %s", GET_COMMAND);
    
            // Read response from MCU
            bytes_read = read(fd, buffer, BUFFER_SIZE - 1);
            if (bytes_read < 0) {
                perror("Error reading from RPMsg device");
                break;
            }
    
            buffer[bytes_read] = '\0';  // Null-terminate the string
            printf("Received: %s\n", buffer);
    
            usleep(POLL_INTERVAL_SEC);  // Wait before next request
        }
    
        close(fd);
    }
    

    谢谢、
    Bawantha.

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    请让我和我们的 Linux IPC 专家谈谈。 请给他一两天时间答复

    谢谢您、

    Paula

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Bawantha、

    该主题可能会有所帮助:
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1248401/processor-sdk-am62x-question-of-ti-rpmsg-char-scripts-specifically-the-recv_msg-method/4731803#4731803

    如果您想查看任何其他注释、可以向我提供有关您的用例的更多信息。

    例如:
    您发送的数据是什么? 数据流向哪个方向?

    一次发送多少数据?

    是否有吞吐量要求?

    有延迟要求吗?

    此致、

    Nick