Skip to Main Content
Centre d’assistance Cognex
LogoLogo

How to Send Packets Longer Than 254 Byte Through TCPDevice

Instructions on how to workaround the 254 byte limitation on the In-Sight TCPDevice spreasheet function

15/09/2024

Question

How do I send a message greater than 254 characters using TCP Device?

Answer

In-Sight has a limitation of around 250 characters that can be placed within any cell, including function names and parameters. This means it is not possible to concatenate a string longer than that. Sometimes it is necessary to send out longer results, and having to split the message into multiple packets sent in succession makes the communication more complicated on both sides. It is possible to send a longer string when formatting it as binary data by performing the following steps:

  1. Set up a TCPDevice function as usual, but set the Packet Type to “Binary with Custom Terminator”.
  2. Concatenate the strings using the BStringf function. For example, if there are strings in B0, B1 and B2 it would look like this: BStringf(0,"%s%s%s",$B$0,$B$1,$B$2)
  3. Link the Data1 parameter of the WriteDevice function to the cell with the BStringf function.

Ressources connexes