Results 1 to 2 of 2

Thread: Decode USB data stream

  1. #1
    Join Date
    Feb 2009
    Posts
    27

    Default Decode USB data stream

    Hi
    I am trying to decode data from a USB connected weather station and need some support/help regarding pattern matching,
    I have tried "everything" like,
    Code:
    "%x255([^%x255]*)"
    ([^%x255%x255]*)
    "(.-%xff%xff)
    "
    and search the "entire" internet without successes,

    I want with a string.find capture the data between 0xff0xff any data 0xff0xff.

    Below is an example of the data (in hex)

    Code:
    FF FF 00 48 0F 0C 0B D0 00 00 20 5E 01 FF FF 00 42 81 47 00 28 3C 80 00 00 EE 01 FF FF 00 42 80 0A 01 11 00 00 00 00 DE 00 FF FF 00 48 06 0C 06 D0 00 00 20 50 01 FF FF 00 42 80 0A 01 11 00 00 00 00 DE 00 FF FF 00 48 09      .H..... ^..BG.(<....B.........H..... P..B.........H.
    Is there any friendly soulout there wiling to help......would be very much appriciated.

    Regards

  2. #2
    Join Date
    Feb 2009
    Posts
    27

    Default

    I got it.
    Kind of obvious when you see it........

    The following did the trick,
    Code:
    pattern = string.char(255)..string.char(255).."(.-)"..string.char(255)..string.char(255)
    st, en, wdata = string.find(c, pattern)
    Maybe not the best way to do it but it is working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •