I am trying to figure out how to increment or decrement a 8 byte Hex string as it repeats its output via repitiion. I can use the Send feature to replicate the same HEX command over and over again with no problem, but for this command I would need to change the 7th byte in the 8 byte HEX and recalculate the IDCHK and send the output to the comport. The range of the 7th byte is 0 to 255 or 0 to FF in HEX. I know enough to be dangerous, but cant seem to see how to structure the code.
I am trying using the Send cyclic sequence with an optional script.
Any help would be appreciated, thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I hope I unsterstand you correct. I would do this with a worker script (script window).
In the attachment you can find an example which increments the 8th element of an array by 1 and send this array every 500ms.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2018-08-16
Thanks Stefan I am looking at the code now, but doesnt this just increse by one with dec values?
The HEX I am trying to increment is 07 FF 42 52 54 01 10 27 D8, but when I try to add this to the var data array I get an error stating it can not find variable FF. I am wanting to increase or derease just the 7th hex bye [27].
Thanks for the help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2018-08-16
Hi,
I updated the script (attachment). If you want to use hex bytes then you have to add 0x in front of the bytes. And if you want to access the 8th byte of an array then you have to use the index 7 because the array index starts at 0.
I am trying to figure out how to increment or decrement a 8 byte Hex string as it repeats its output via repitiion. I can use the Send feature to replicate the same HEX command over and over again with no problem, but for this command I would need to change the 7th byte in the 8 byte HEX and recalculate the IDCHK and send the output to the comport. The range of the 7th byte is 0 to 255 or 0 to FF in HEX. I know enough to be dangerous, but cant seem to see how to structure the code.
I am trying using the Send cyclic sequence with an optional script.
Any help would be appreciated, thank you.
Hi,
I hope I unsterstand you correct. I would do this with a worker script (script window).
In the attachment you can find an example which increments the 8th element of an array by 1 and send this array every 500ms.
Best regards,
Stefan
Last edit: Stefan Zieker 2018-08-16
Thanks Stefan I am looking at the code now, but doesnt this just increse by one with dec values?
The HEX I am trying to increment is 07 FF 42 52 54 01 10 27 D8, but when I try to add this to the var data array I get an error stating it can not find variable FF. I am wanting to increase or derease just the 7th hex bye [27].
Thanks for the help.
Hi,
I updated the script (attachment). If you want to use hex bytes then you have to add 0x in front of the bytes. And if you want to access the 8th byte of an array then you have to use the index 7 because the array index starts at 0.
Best regards,
Stefan
Last edit: Stefan Zieker 2018-08-17