PX4 Serial Receive Variable Data Length

5 visualizaciones (últimos 30 días)
riley
riley el 3 de Feb. de 2025
Editada: Walter Roberson el 20 de Feb. de 2025
Hello,
I am currently trying to receive serial data from a UART&I2C Port in my simulink model. The data stream I am receiving has 6 signals with one singal being an iteration counter that increases from 1 - 1000. This means that the total character length of the serial pack is increasing as time progresses. I have no current way to alter the length of the transmission. When accepting signals that are longer than the prescribed length, valuable data is cut off. When accepting data that is shorter than the prescribed length, erroenous zeros are thrown in to the data making my signals have very jumpy time histories. The only time this system works is when the data is corrent length as specified in the serial receive PX4 block.
Is there a way for the PX4 Serial Receive block to handle a signal with a variable data length?
Furthermore, are there any work arounds with different serial receive blocks that can connect to the relevant ports on a Pixhawk 6x(dev/ttyS4)?

Respuesta aceptada

Ankur Bose
Ankur Bose el 20 de Feb. de 2025
Yes, The PX4 Serial receive has a checkbox in Advanced tab called "Output partially received data". When this parameter is enabled, the block outputs whatever is available on the buffer and the actual length of the received buffer. The serial blocks can operate across all ports of Pixhawk 6x. You need to mention the correct port name in the serial block
  1 comentario
riley
riley el 20 de Feb. de 2025
Editada: Walter Roberson el 20 de Feb. de 2025
I have tried this option many times but the outputted data is very inconsistent and are seldom representative of the data length that I know is being actually being sent to the port. There is a potential that I am not orienting the data correctly after receiving it, however I know what length of data to expect at a certain point in time.
To provide more context I am sending a serial signal that looks like this
123;110000;110000;110000;110000;110000;\r\n
The first value is an iteration counter that inevitably increases the length of the string when crossing to 1000, 10000, etc.
I am currently receving this data in the form of the ascii characters, then I input these values into a matlab function that works as follows:
function y = fcn(u)
y = circshift(u, -find(u==13));
This finds the my carriage return character that is at the end of my signal and orients my signal
Note that the length of the signal changes wildly even before using this function and subsequent blocks.
An ascii to string block paired with a scan string(%d;%d;%d;%d;%d;%d;) block then allows me to separate everything out and utilize downstream as needed.
Since posting this question, I have managed to successfully modify the source MATLAB system code for the PX4 serial receive block in order to get my string to be properly received with a buffer that waits until a full string between carriage returns is received. I will go over it in more detail in my other question: Custom Matlab System Objects for use with PX4 Architecture (PX4 Serial Receive)

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by