Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

lua code help


Martin555

Question

Hi I have data in HEX format it is a long string of numbers and letters. It still start with 5C75303030 and ends
with numbers or letters. I would like to to save the last 6 values after value 5C75303030 in the table, or if is some
value after 5C75303030.
How I can do it?

String is for example:

5B22 AA557FC0 5C7530303031868C 5C7530303045F6 5C7530303030 5C7530303046 5C7530303031 5C75303030357B 5C7530303030 5C7530303132 5C7530303030 5C7530303031F1 5C7530303030 5C7530303033 5C753030303050 5C7530303030FD 5C75303030306D 5C753030303064

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Please login or register to see this code.

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • So I will try it. But there is a problem. It's not that.  That string still starts with 5C303030 but has different lengths .

    that's the result:

    "31868","45B85","465C7","35405","305C7","305C7","30505","304E5","30645","30385","335C7","305C7","305C7","305C7","315C7","305C7"........................

     

    1 is ok, 2 is ok 3 is not Ok it has value 5c7 etc...

     

    After the assignment, I received these results, where in the result there is also 5C7... Wouldn't it be better to find 5C in a string and save 4 values to a table before value 5C? It sends the values after 5C75303030 and selects the values to the next 5C. wouldn't that be better? Is there a command for this?

    Please login or register to see this attachment.

    Edited by Martin555
    Link to comment
    Share on other sites

    • 0

    Eh, I don't think I understand. The code I posted solved your example in the first post. 

    Can you give a new example with input string and wanted output table?

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • This is string code for eample:

    5B22AA557FC05C7530303031868C5C7530303045F65C75303030305C75303030465C75303030315C75303030357B5C75303030305C75303031325C75303030305C7530303031F15C75303030305C75303030335C7530303030505C7530303030FD5C75303030306D5C7530303030645C7530303030645C75303030305C225C75303030305C225F5C7530303033

     

    I need value underlined. so example  5C7530303031868C  I need 868C  for example 5C73030305C22  I need 5C22,    for example 5C7530303033 I need 33.  for example 5C7530303031EB I need EB

     

    It will probably be better to select each part 5C75303030XXX in the table at the beginning and then solve each position separately with the gsub command

     

    Edited by Martin555
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...