How to send and receive data using UDP on the same computer?
이전 댓글 표시
I want to use UDP to send and receive a data from a same computer in real time. I have an s-function block which get data from another software(optitrack) and I want to send this data to another simulink model on the same computer. I am just wondering if this can be possible by just using the 'DSP System Toolbox' sender and receiver udp blocks. I used '127.0.0.1' for the ip address to send the data and used '0.0.0.0' to receive it. Notice: I first packed the data from the s-function block and then connected it to UDP sender and for the receiver side I unpacked the data using Unpack block but still didn't work.
댓글 수: 5
Nick Choi
2017년 10월 5일
Can you clarify what you mean by real-time? Are you referring to sending and receiving data while the models are running on a PC or are you referring to a real-time kernel?
Given that the models are both running on the same computer, is there a specific reason why the two models can't be integrated into one?
Kidus Guye
2017년 10월 13일
Chris Jarrett
2018년 8월 23일
Hi,
I'm trying to do the same thing, could you explain how you got it to work?
Kidus Guye
2018년 8월 23일
Vaibhav Arora
2019년 9월 17일
Although any of the blocks from different libraries can be used, use the UDP send and UDP receive blocks from the embedded coder library. Use '127.0.0.1' for the remote IP address of both the blocks.
The remote IP port of the send block should match the local IP port of the receive block. Additionally, you should use byte pack and byte unpack blocks to pack the data into uint8.
For the receive block, let the receive buffer size have the default value. 'Maximum length for Messafe' parameter of the receive block would depend on the data packed. For example, if you expect to pack 4 double values using the input bus of byte pack and send it through UDP send, then this value should be 32 (4*8).
Output variable-size signal should be unchecked. Blocking time blocks UDP receive until it receives a message from UDP send.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Buffers, Switches, and Counters에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!