c - 如何获取字符串大小

标签 c uart at-command

我正在尝试从我的微 Controller 发送 AT 命令,并且我正在编写自己的实现来检查远程模块的响应

此时我想通过以下方式将带有命令的字符串发送到模块:

    //File.h

    //where char const *message is my string from my file.c, LEN the lenght for my message and reply message from the remote module.

uint8_t CommandSenderCheckResponse(char const *message, uint16_t LEN, char const *reply);

    ---------------
    //File.c
    #include "File.h"
    #define Reply "OK"



    uint8_t CommandSenderCheckResponse(char const *message, uint16_t LEN, char const *reply);
    {       
    //something...
    }


    int main(void)
    {
    while(1)
    {
        CommandSenderCheckResponse("AT#TurnSomething=1", LEN, Reply);
    }
    }

如何获取“AT#TurnSomething=1”的大小?当然,我正在重新发明轮子,您可以向我推荐什么库来发送通用 AT 命令并解析来自模块的响应?

问候

最佳答案

您不需要使用库(比标准库更多)来获取字符串的长度。

int length = strlen(message);

关于c - 如何获取字符串大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51794557/

相关文章:

将字符串复制到c中的剪贴板

c - 不同数据类型的乘法变量的顺序是否会导致不同的结果?

c - 如何让命令窗口中的文本跳到下一行? C语言编程?

Linux用户空间: how to put 16550-compatible UART in loopback mode persistently

sockets - 如何使用AT命令可靠地拆除和重新连接TCP/IP套接字

c - 如何编写 "selective"Makefile?

arrays - 为什么在 char 数组的字符之间插入 "\000"个字符?

c++ - Gem5 中的 UART 通信与 ARM 裸机

gsm - 手机上的AT命令

java - 当短信再次发送时,命令显示忙(在java中)