This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

loading images via packets in lightcrafter

Currently im trying to send packets to load a saved image that is something like 17x18 bitmap image. I was able to project it through the gui so i know its fine. 


Trying to do it via Matlab is giving me some issues.

I have to send decimal values of the packets over tcpip in order for it to work, but how exactly do i convert image data which i can import as a character array of the size of its bytes, and input that along with the packet so that it can see this image?

Im converting all the hex to decimal in order for this to work.

Any ideas? Im pretty close and i know its possible since the gui handles it similarly.

Thanks,
Samir 

  • I am able to figure out how to send it across but im not sure whether the method is correct. If i send over tcp, what is my max packet limit? is it 1500 or 65536 like said in a previous thread. The first would require about 866 packets where the latter not many at all.

    Just trying to figure it out as sending that many packets with my current method is taking ages as i have to compute the checksum for each package.

  • Hi Samir Zutshi,

    Suggest you to have the image saved in BMP file format in the matlab environment. Then the generated bmp file can be sent as it is like any other binary file. Just open the file and copy data data from it and send it to light crafter hardware.

    The TCP packet size is 65535 (0xFFFF) the data transmission over TCP is most reliable in your TCP transmission code you should always check that number the number of bytes transmitted is matching to requested number of bytes.

    For example - The TCP send request returns less number of bytes than the requested then you have call TCP send again to esnure the remaining bytes send requested.

    The below logic explains it better -

    int TCP_SendData(int sock, unsigned char *buffer, int length)
    {
     int sent = 0;
     while(sent < length)
     {

      int ret =  send(sock, buffer + sent, length - sent, 0); // This can return equal to less than requested

      if(ret <= 0)
       return -1;

      sent += ret;
     }

        return 0;
    }

    Saw example on Matalab see if it helps http://www.mathworks.com/matlabcentral/fileexchange/11802

    Regards,

    Sanjeev