receive data from sensor on udp at the same time

5 ビュー (過去 30 日間)
Rashi Mehrotra
Rashi Mehrotra 2021 年 10 月 11 日
コメント済み: Rashi Mehrotra 2021 年 10 月 12 日
I have to receive data from multiple sensors at the same time. I have data received on udp ffrom two different sensors. the process have to be time stamped at the same values of time.
Will this require multithreading in matlab. or it can be also done by vectoring the variable.
Please tell how it can done in both ways.
I have considered using parfor and parpool but cannot arrive at the result.

回答 (1 件)

Electrification Enthusiasts
Electrification Enthusiasts 2021 年 10 月 11 日
Hello Rashi,
you should focus on processing the data serially (not in parallel) because UDP doesn't support parallel packets. They may have the same time stamps, but they will not be received simultaneously. One will always come in before the other. Also, technically, UDP can drop packets so there is not guarentee you will get data from each sensor for each time step. As for processing data that was generated at the same time, you can use vectors in maltab. Adding threads won't change that the bottlneck is your network adapter which will process everything serially.
You can look for serial to parallel (and vice versa) converters in the file exchange to starting points.
Regards,
Joel
  1 件のコメント
Rashi Mehrotra
Rashi Mehrotra 2021 年 10 月 12 日
hi,
I am using parfor for running the data parallely, but it is not giving the desired result which is receiving data at the same time that for two udp connection. The parfor does not work for different udp connections?
The code is
If I have two sensors
u1 and u2 are the udp objects declared using udp command and fopen
parfor i=1:2
data(:,1)=fscanf(u1);
data(:,2)=fscanf(u2);
end
Please tell

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by