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.

[参考译文] TM4C1294NCPDT:通过 tcp_write 发送整数 ui32_t

Guru**** 2489685 points


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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/736406/tm4c1294ncpdt-sending-integer-ui32_t-through-tcp_write

器件型号:TM4C1294NCPDT

您好!  

我尝试通过以太网发送 ADC 读取数据,我使用 lwip 栈, 我可以发送字符串和字符之类的简单 TCP-Data,但我无法以整数类型发送数据。 我知道 tcp_write 处理字节、并且我正在尝试使用没有成功的指针。

有人可以向我举例说明如何做到 这一点? 除了指示器之外、我还尝试了几件事情、也许有人已经体验过这种情况、或者任何新的外观都很棒。  

最好

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好!
    下面是一个实现方法。 您可以将此想法扩展到适合您的应用。

    uint32_t ADC_DATA = 1234;
    char pcBuf[4];
    uint32_t len = sizeof (pcBuf);

    usprintf (pcBuf、"%d"、adc_data);

    ERR = tcp_write (testpcb、&pcBuf[0]、len、tcp_write_flag_copy);
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    非常感谢 Charles、这解决了问题。 但现在的问题是转换过程非常慢(我使用3700数据数组)、我假设是 usprintf 函数、还有其他方法可以避免它吗?
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好!
    我想您可以编写自己的函数、将整数转换为 ASCII。