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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

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

Tags (3)
0 Kudos
1 Reply

688 Views
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 Kudos