Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Node.JS Read/write serial communication, bitwise

alveman

New Coder
I am trying to read/write values to a heat pump. How the communication works is described at https://rago600.sourceforge.net/ and in these examples.

For example:
Register 020B is sixteen bit number.
Let's write it in binary form 0000 0010|0000 1011
Now we can mark 7 groups from the end 00|0000100|0001011
And now we have this number in 7 bit form 00 04 0B

We have received temperature 00 04 38
Let's write 7 bit numbers in binary form 0000000|0000010|0111000
We will mark 8 bit delimiters 00000001|00111000
It is: 138(hex) 312(dec)
In that case temperature is 31.2C

We have received temperature 03 7C 1D
Let's write 7 bit numbers in binary form 0000011|1111100|0011101
We will mark 8 bit delimiters 11111110|00011101
It is: FE1D(hex) 65053(dec)-483(signed integer)
Received temperature is -48.3C

I have succeeded in decoding the values coming from the heat pump with this function but cannot get the reverse to work ie from dec to 7 bit hex.

Code:
var data = Buffer.from(msg.payload);
var decoded_int = (data[1] << 14) + (data[2] << 7) + data[3];
var decoded_buffer = Buffer.from([decoded_int & 0xff, decoded_int >> 8]);
var decoded = decoded_buffer.readInt16LE();
return { "decoded": decoded };
 
I am trying to read/write values to a heat pump. How the communication works is described at https://rago600.sourceforge.net/ and in these examples.

For example:
Register 020B is sixteen bit number.
Let's write it in binary form 0000 0010|0000 1011
Now we can mark 7 groups from the end 00|0000100|0001011
And now we have this number in 7 bit form 00 04 0B

We have received temperature 00 04 38
Let's write 7 bit numbers in binary form 0000000|0000010|0111000
We will mark 8 bit delimiters 00000001|00111000
It is: 138(hex) 312(dec)
In that case temperature is 31.2C

We have received temperature 03 7C 1D
Let's write 7 bit numbers in binary form 0000011|1111100|0011101
We will mark 8 bit delimiters 11111110|00011101
It is: FE1D(hex) 65053(dec)-483(signed integer)
Received temperature is -48.3C

I have succeeded in decoding the values coming from the heat pump with this function but cannot get the reverse to work ie from dec to 7 bit hex.

Code:
var data = Buffer.from(msg.payload);
var decoded_int = (data[1] << 14) + (data[2] << 7) + data[3];
var decoded_buffer = Buffer.from([decoded_int & 0xff, decoded_int >> 8]);
var decoded = decoded_buffer.readInt16LE();
return { "decoded": decoded };
Hi there,
Is there a particular reason you would need this knowledge?
 

Buy us a coffee!

Back
Top Bottom