TCP IP communication b/w two systems

3 views (last 30 days)
Saravanan Mani
Saravanan Mani on 27 Jul 2019
Answered: Walter Roberson on 27 Jul 2019
I try to implement the TCPIP algorithm between two sysstems. I couldn't slove the following problems:
  1. The data is transferred in fwrite is by default 'uint8' and this is making any value >=256 as 255 in the receiver side.
  2. If I use the precision as per the documentation suggested in the MALTAB like 'double' or 'integer*8' or 'uint64', I keep on getting different errors as Precision not supported or Sync/Async related error.
  3. Since the data size could be different in each of our iteration (for loop condition), I transfered the length of the data first and then the original data in two different sends and two different receives. I found that sometime sender side is working very fast showing that the data has been sent for several entries of i without being shown in the side of reciever and sometimes even while the data was not being sent, reciver side was continuously getting the data.
  4. Even one time the first send of the length of the signal got appended with the second send of the original signal and that's a new issue we would not want to see.
I have shared my latest code.

Answers (1)

Walter Roberson
Walter Roberson on 27 Jul 2019
For transmission, typecast() all data to uint8(). This would produce a vector of uint8 values for each item; concatenate all of those together into a uint8 vector.
For reception, index into the vector to break the vector at appropriate places, and typecast() back to the type you know the value should be.
It is a good idea to prefix the data with the length of the data, and you can do that as part of the uint8 vector; you do not need a separate packet for it.

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!