LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert byte to integer, have troube in type cluster

You have to use the entire cluster as defined. If you look at the actual cluster definition you will see that the various 0s in the cluster are either represented as unsigned 8-bit values or signed/unsigned 16-bit values. The size corresponds to the protocol definition. So the temperature values are U16 integers. Wind speed and humidity would be U8 integers.

 

Also, change your read to only read the amount of data necessary for one set of data. This would be 16 bytes. The ACK plus the remaining 15 bytes which make up the actual sensor data. Unless of course the data is actually terminated by the 0x0A (carriage return) and you have not posted the full message definition.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 21 of 57
(180 Views)

@Mark_Yedinak wrote:

Unless of course the data is actually terminated by the 0x0A (carriage return) and you have not posted the full message definition.


Considering we are using binary/hex/raw data, that would be a horrible protocol (in theory, 10/0xA is a valid data point to have).


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 22 of 57
(173 Views)

@crossrulz wrote:

@Mark_Yedinak wrote:

Unless of course the data is actually terminated by the 0x0A (carriage return) and you have not posted the full message definition.


Considering we are using binary/hex/raw data, that would be a horrible protocol (in theory, 10/0xA is a valid data point to have).


I agree. But since we are given the information in bits and drabs, who knows what the protocol actually is. Plus, the code is using a termination character to terminate the reads. Given that the OP mentioned other sensor values (precipitation), I still don't think we have the complete definition.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 23 of 57
(171 Views)

@feelsomoon wrote:

Sorry if I misunderstand, are you just put constant number 0 in the cluster? How does it know what size is each parameter? I did the same for the part just Outside Temperature, it didn't work. Do you know what's the problem?


As stated, you need to define the entire packet cluster.  I set the representation according to the number of bytes for that parameter and made sure the order was correct.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 24 of 57
(168 Views)

Thank you crossrulz! I just cut the 2 bytes for Outside Temperature. Is it enough I only define them with one constant 0 with the representation of U16? I think I did so but the result is wrong.

0 Kudos
Message 25 of 57
(163 Views)

Why not decode all of the data as shown above? As the applications expands you may want access to the other data points. You read the data, simply decode it using a complete cluster and then use what pieces you need. Much simpler to work with the actual protocol as defined than to pick it apart piece meal.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 26 of 57
(158 Views)

@feelsomoon wrote:

I just cut the 2 bytes for Outside Temperature. Is it enough I only define them with one constant 0 with the representation of U16? I think I did so but the result is wrong.


If you actually get the right 2 bytes, it will work.  Post your code, preferably with the data string having a representative default data, and we can have a look.

 


@feelsomoon wrote:

Thank you crossrulz!


Words are meaningless.  I have yet to see a "thank you" from you (ie kudos and marked solutions).


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 27 of 57
(157 Views)

@Mark_Yedinak wrote:

Why not decode all of the data as shown above? As the applications expands you may want access to the other data points. You read the data, simply decode it using a complete cluster and then use what pieces you need. Much simpler to work with the actual protocol as defined than to pick it apart piece meal.


Yes, it is. But the total length is 99 bytes. The snipped part is only a part of the total protocol. Anyway, I need to pick.

0 Kudos
Message 28 of 57
(130 Views)

 


@crossrulz wrote:

@feelsomoon wrote:

I just cut the 2 bytes for Outside Temperature. Is it enough I only define them with one constant 0 with the representation of U16? I think I did so but the result is wrong.


If you actually get the right 2 bytes, it will work.  Post your code, preferably with the data string having a representative default data, and we can have a look.

 


@feelsomoon wrote:

Thank you crossrulz!


Words are meaningless.  I have yet to see a "thank you" from you (ie kudos and marked solutions).


 

Sorry I can't mark solution cause I still didn't the right result. I'm using another byte string.

 

064C 4F4F C400 C108 EE73 F902 3197 03FF FFFF 7FFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 21FF FFFF FFFF FFFF 0000 34AC 0300 00FF FF00 0000 0003 0000 0000 0010 00FF FFFF FFFF FFFF 0000 0000 0000 0000 0000 0000 0000 0000 0000 3F03 06AA 7502 7107 0

 

As you suggested. 0xF902319703 should be Inside Temperature, Relative Humidity, Outside Temperature, in which 9703 is Outside Temperature, equals 91.9. I put an indicator after I cut it. This part should be fine. I set the little-endian and type as U16. I'm really confused what's wrong with it.

block.PNGfront.PNG

0 Kudos
Message 29 of 57
(125 Views)

Hi feel,

 

you should ALWAYS show the display mode indicator with string constants. Expecially when you use data in hex display mode!

 

When you want the two bytes "97 03" from your (hex formatted) string you should get a substring starting at index 13 with a length of 2:

check.png

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 30 of 57
(106 Views)