Why do the Arduino Wifi TCP/UDP Send/Receive blocks in Simulink only send/receive 8-Bits of data (uint8)?

1 view (last 30 days)
I'm trying to send an AnalogInput signal from my Arduino via wifi to a PC with Simulink. I've created two models, one which runs on an Arduino Due with a Wifi Shield and one that receives the data and plots it onto a scope in Simulink.
The problem is that the Wifi TCP\UDP Send blocks are only able to send 1 Byte of data (uint8) per call. In the Code Generation Report it shows that the uint16 data of the AnalogInput will be explicitly casted to uint8:
uint16_T rtb_AnalogInput_0;
MW_WifiTCPFinalWrite(untitled_P.TCPSend_p1, (uint8_T)rtb_AnalogInput_0, untitled_P.TCPSend_p2);
This will chop off any leading bits which won't fit into the uint8 datatype. The implementation of the MW_WifiTCPFinalWrite method can be found in the io_wrappers.cpp and looks like this:
extern "C" void MW_WifiTCPFinalWrite(uint8_t wifitcpindex, uint8_t data, uint32_t serverport)
It calls the write method implemented in the class EthernetServer which then passes the address of that parameter and the length of 1 byte:
size_t EthernetServer::write(uint8_t b)
return write(&b, 1);
This leads to an overloaded write(const uint8*, size_t) method, is then passed to a write method in EthernetClient until it eventually reaches the send method defined in socket.cpp.
These last two methods both use pointers and a length parameter meaning that these are able to process and send more than just 8 bits of data.
Long story short...
I could now just extend the framwork by myself but it raises the question why this has been so poorly implemented. Maybe I missed something and I'm not right about this conclusion?
Is there any good reason that the method MW_WifiTCPFinalWrite used by Simulink only allows 8-Bit of data which it copies instead of passing a pointer and a size?

Accepted Answer

Subin Kuttappan Stellal Mary
As of Simulink R2017a, the TCP/UDP send/receive blocks in the Simulink Support Package for Arduino Hardware can send or receive only uint8 data per step.
This is mentioned in the documentation of the blocks. Eg : https://in.mathworks.com/help/supportpkg/arduino/ref/wifitcpipsend.html
However, the developers have already working on multi byte enhancements and planned it for a future release.
Stay tuned...
  1 Comment
Andreas Nagl
Andreas Nagl on 13 Oct 2017
Edited: Andreas Nagl on 13 Oct 2017
Hello, did I see it correctly that for 2017b, this limitation has already been removed for Wifi TCP/IP send, but for TCP/IP send it's still there? Thanks a lot!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by