Fist of all I want to apologize for not being able to express my self very well in english (as well for my misspelligns).
I am just starting out with Node-Red and my programming background is only making easy programs for arduino (something simmilar to C++), and I am learning C# since fes weeks ago.
I started doing easy flows with node-red that work (flows that does not require code writting) without need of help. But I have a problem that I am not able to solve at this moment.
I want to send a command to the driver of a stepper via the serial port (USB). Each command consists of 9 bytes:
- byte 1: module adress
- byte 2: Command number
- byte 3: Type number
- byte 4: Motor or bank number
- bytes 5-8: Value (MSB first)
- byte 9: checksum (sum of previous 8 bytes)
When I started programming arduino (or when starting out wiht C#), one of the first thinks that I became familiar with was the variable statement, so that the number of bits of each variable is fixed. But in node-red I haven't found a way to define the bit-lenght of messages.
In this case, what I think that I have to do is:
- Create the first part of the message (bytes 1-4) as a fixed one.
- Read the input (from a dashboard node) to set the "value", and express it as a 32 bits integer.
- split the 32 bit number in 4 bytes.
- sum the 4 bytes of the first part of the message and the 4 bytes of the Value.
- Put the 9 bytes (4 of the first part of the command, 4 bytes of the value and the checksum) toghether and send the message...
any idea to do that?