Wolly Posted March 19, 2018 Report Share Posted March 19, 2018 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? Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted March 20, 2018 MVP 2023 Report Share Posted March 20, 2018 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now