types - How to read negative byte values in Java less than -128 -


I am reading data from another system using serial port. I am reading packs of 133 bytes. I second byte The packet is the number and the third byte is the negative value of the packet number.

The problem is that there is a limit of type byte -128 to 127. When I try to read I-129 (out of the bounds), this value will be given as 127.

What can I do to get I-129?

You have to decide which bits you expect for byte values ​​if you expect Can use range ranging from 12 to 126.

  int min = 129; Int i = ((B + min) and 0x FF) - Min;  

BTW You can not be worth more than 256.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -