Go to content Go to navigation

SEND_STRING 0

29 December 2008, 09:27 by Chad Reynoldson

I do a lot of run-time debugging with SEND_STRING 0,”‘Some Message’”. Normally the messages are short and sweet and all is good in NetLinx. When the messages get larger, NetLinx starts to push back and you don’t get what you expect. The master sends you an indicator that something is wrong:

>(0000479304) SendString 0:0:0 too long 310 truncated to 274


NetLinx is telling us that it can only send out 274 characters to the terminal with a single SEND_STRING.

So we add some code to loop over the entire message and send it in chunks of 274 bytes. This gets us over the hump of the truncated error, but we only get 131 bytes. I believe this is a bug, but nothing we cannot overcome. We just modify our code to loop over the message in chunks of 131 bytes, as shown below.

(*---------------------------------------------------------*)
(*-- Echo to terminal (131, not 274 like you'd think).   --*)
(*---------------------------------------------------------*)
DEFINE_FUNCTION echoToTerminal (CHAR strHeader[], CHAR strData[])
STACK_VAR
  INTEGER nLoop
{
  SEND_STRING 0,"13,10,'--------- ',strHEADER,' ---------'"

  FOR(nLoop=1; nLoop<=LENGTH_STRING(strData); nLoop=nLoop+131)
  {
    IF(LENGTH_STRING(strData) > (nLoop-1+131))
      SEND_STRING 0,"MID_STRING(strData,nLoop,131)"
    ELSE
      SEND_STRING 0,"MID_STRING(strData,nLoop,LENGTH_STRING(strData)-nLoop+1)"
  }
}


Keep in mind that strData[] is unbounded, so NetLinx will limit it to 2048 characters. If you are echoing data larger than this, you’ll need to bound it.

Share This Article

Comments

No Current Comments

Write a comment.

Please note…

  1. Please keep comments to a thoughtful discussion on the topic.
  2. If you just want to say hello, use the contact form instead.
  3. Textile is limited to *strong*, _italics_ and "link":url .
  4. I reserve the right to edit/remove any comments.