How to configure S32K14x to receive variable data size with UART in MBDT

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to configure S32K14x to receive variable data size with UART in MBDT

861 次查看
aungkm
Contributor III

Hi,

I am trying to implement MODBUS protocol in S32K14s using MBDT. Since the MODBUS server response packet varies in size depending on the client request, how can I configure the LPUART_Receive and LPUART_RxTx_ISR blocks to be able to receive these variable size packets?

If I configured the LPUART_Receive block to receive the fix size packet, for example, 8 byte, I could receive the 8 byte response packet without any issue. But, if i configured the size to be variable, I could not receive the correct data and sometime there is data at all.

I have attached the model in this thread.

Please kindly advice.

Thanks.

标记 (3)
0 项奖励
回复
1 回复

716 次查看
cristiand
Contributor I

Hello,

I think you can use a software approach to this problem. You can use delimiters in the message you send over uart and to read characters into a string one by one.

For example, if you want to send voltage, current and fault status over uart, you can format the message like this "voltage:10;current:1;fault:0" (using the ; as a delimiter). Then you can break the message like this:

  • Voltage:10
  • Current:1
  • Fault:0

Let me know if this approach helps you.

0 项奖励
回复