05-09-2017 12:04 PM - edited 05-09-2017 12:16 PM
Hello, I am receiving data from the serial port from an XBEE and I want to take the portion
corresponding to a value within the payload. So far, I have extracted the portion and regenerated the numeric data with Type Cast.
But that data I only managed to indicate in U16. My problem is that since I need to manipulate that data in a mathematical formula, I must
treat it as SGL and I do not know how to get it with Type Cast or something like that. This result will be to show on a humidity and a temperature indicator. Below I leave a
schematic where I get the plot and I get some data like the one I need. For any question about what each byte in the Zigbee package means, I leave a link
(http://docs.digi.com/display/RFKitsCommon/Frame+structure). And My Diagram
Thank you all and have a great day.
05-09-2017 02:18 PM
Hi Paul,
So far, I have extracted the portion and regenerated the numeric data with Type Cast. But that data I only managed to indicate in U16. My problem is that since I need to manipulate that data in a mathematical formula, I must treat it as SGL and I do not know how to get it with Type Cast or something like that.
So you know how to typecast to U16, but you don't know how to typecast to SGL? Really?
Maybe you just need to think about that one more minute 😄
Using BytesAtPort seems wrong to me!
All you need to do is waiting for the start delimiter, then read another 2 bytes and convert them to the "length" parameter. Then read "length" more bytes containing the frame data and one more byte with the checksum. When the received checksum is wrong you didn't start your message at the right offset in the stream - the start delimiter might also occur within the message… In this case just throw away the message and search for the next start delimiter!
05-10-2017 06:44 AM
05-11-2017 09:58 AM
Have you tried this?
You could also place an SGL constant as "type" in the Type Cast Function