Jump to content

FB Procotol Scan command error

Recommended Posts

I use the Protocol Scan command to read the ASCII character string 0D 0A 31 32 20 20 20 31 30 31 2E 33 32 6B 50 61 61 0D 0A -  "/ n / r12 101.32kPaa / n / r"  from the receive buffer.  The number of bytes of the pressure value kPaa is not constant, it can be from 3 to 6 bytes. Therefore, when configuring a command, I use "Decimal, no fixed length".  After scanning, the command returns the Index of the received message -1.  If in this case I use the "Decimal, fixed length"  (6 bytes) the command returns the result 0  "OK",  and the number of bytes received   19.

What is the reason that the message considers as invalid?


ASCII RX online.jpg5aafac0485703_ASCIITX.thumb.jpg.39ad3c0f2d12fee61270d23815746a9e.jpgASCII RX data.jpg


ASCII TX online.jpg

Link to comment
Share on other sites

  • MVP 2023

I gave up on the Decimal formats in the Protocol block long ago.  They're just not consistent in their behavior, as you've seen.

I catch the whole string in a Stream variable and then use the String functions to find locators such as your "kPaa" string.  Once you find a pointer to that location you can search backwards for the space, which will give you your numeric string length.  Then extract the numeric string to their own MIs and convert them to a number using the ASCII=>NUM function, which works quite well.

This sounds more complicated than it is. The nice thing is you can examine the output of your string manipulation code at each step.  I have found it to be way more reliable.

Joe T.

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...