in reply to Re^2: Sending UDP Packets to MATLAB
in thread Sending UDP Packets to MATLAB

#!/usr/bin/perl #udpclient.pl use IO::Socket; use warnings; use Time::HiRes qw (sleep); my ($socket,$data); $socket = IO::Socket::INET->new (PeerAddr => '10.11.254.81', PeerPort => 5005, Type => SOCK_DGRAM, Proto => 'udp') or die "ERROR in + Socket Creation : $!\n"; @tempData = (20,30,40); $socket->send(pack ("(A*)*", @tempData)); $socket->close();
I am receiving the data as 203040 ... How cna I add a delimiter like a space to this ... so that I can receive the data as 20 30 40 ....

Replies are listed 'Best First'.
Re^4: Sending UDP Packets to MATLAB
by pryrt (Abbot) on Aug 24, 2016 at 22:09 UTC
    If you are trying to send floating point data in a form that the Simulink will be happy with -- one of the binary formats that RadioEngineer listed -- then trying to encode the integers 20, 30, 40 as a string "20 30 40" is not the right way to go about it. Read the other thread I referenced, and ask specific questions.

    In that other thread, I already said which pack formats are needed in order to properly encode floating point numbers; you concatenate those together (with whatever separators that the Simulink block is expecting) and send them as a single message.