Menu

Increment an 8 byte hex string in the 7 byte field as it repeats for X repetitions.

Anonymous
2018-08-15
2018-08-16
  • Anonymous

    Anonymous - 2018-08-15

    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.

     
  • Stefan Zieker

    Stefan Zieker - 2018-08-16

    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
  • 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.

     
  • 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.

    Best regards,
    Stefan

     

    Last edit: Stefan Zieker 2018-08-17

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.