Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Data string Parsing

Data string Parsing

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresjsontutorialquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    srija
    wrote on last edited by
    #1

    Hello, Actually, am getting data from the machine as 0x03 0x10 0x82 0x10..... and length of the buffer is varying, as Length:108 or 256 or....so how to proceed further to parse the data and store the data in an array. do we have any Active X control for parsing the data?

    T N M 3 Replies Last reply
    0
    • S srija

      Hello, Actually, am getting data from the machine as 0x03 0x10 0x82 0x10..... and length of the buffer is varying, as Length:108 or 256 or....so how to proceed further to parse the data and store the data in an array. do we have any Active X control for parsing the data?

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      srija wrote:

      do we have any Active X control for parsing the data?

      how an activeX could help you there ??? well, you reposted your question, but you don't really say much once again.

      srija wrote:

      am getting data from the machine as 0x03 0x10 0x82 0x10

      this doesn't mean anything (or it could mean everything) depending on haw you want to interpret those bytes... that's why i asked you the format of the datas supposed to be received... please precise the type on how you receive those data, how you want to change them, tell also if there are some important thing to read from the stream... help us or we won't be able to help you !!


      TOXCCT >>> GEII power
      [toxcct][VisualCalc 2.24][3.0 soon...]

      S 2 Replies Last reply
      0
      • S srija

        Hello, Actually, am getting data from the machine as 0x03 0x10 0x82 0x10..... and length of the buffer is varying, as Length:108 or 256 or....so how to proceed further to parse the data and store the data in an array. do we have any Active X control for parsing the data?

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #3

        Use CArray for storing the data nave

        1 Reply Last reply
        0
        • T toxcct

          srija wrote:

          do we have any Active X control for parsing the data?

          how an activeX could help you there ??? well, you reposted your question, but you don't really say much once again.

          srija wrote:

          am getting data from the machine as 0x03 0x10 0x82 0x10

          this doesn't mean anything (or it could mean everything) depending on haw you want to interpret those bytes... that's why i asked you the format of the datas supposed to be received... please precise the type on how you receive those data, how you want to change them, tell also if there are some important thing to read from the stream... help us or we won't be able to help you !!


          TOXCCT >>> GEII power
          [toxcct][VisualCalc 2.24][3.0 soon...]

          S Offline
          S Offline
          srija
          wrote on last edited by
          #4

          I would like to have the data in (Radius, Angle) i,e in polar coordinates, thats all the data what i could read from machine, i dont even have the header information also. I think, you got my problem...

          1 Reply Last reply
          0
          • T toxcct

            srija wrote:

            do we have any Active X control for parsing the data?

            how an activeX could help you there ??? well, you reposted your question, but you don't really say much once again.

            srija wrote:

            am getting data from the machine as 0x03 0x10 0x82 0x10

            this doesn't mean anything (or it could mean everything) depending on haw you want to interpret those bytes... that's why i asked you the format of the datas supposed to be received... please precise the type on how you receive those data, how you want to change them, tell also if there are some important thing to read from the stream... help us or we won't be able to help you !!


            TOXCCT >>> GEII power
            [toxcct][VisualCalc 2.24][3.0 soon...]

            S Offline
            S Offline
            srija
            wrote on last edited by
            #5

            I would like to have the data in (Radius, Angle) i,e in polar coordinates, thats all the data what i could read from machine, i dont even have the header information also. I think, you got my problem... shirin

            1 Reply Last reply
            0
            • S srija

              Hello, Actually, am getting data from the machine as 0x03 0x10 0x82 0x10..... and length of the buffer is varying, as Length:108 or 256 or....so how to proceed further to parse the data and store the data in an array. do we have any Active X control for parsing the data?

              M Offline
              M Offline
              mbue
              wrote on last edited by
              #6

              I hope to understand you right. The aim is to convert a variable length block of input data with hexadecimal numbers into an array to integers. If it' true try this: // comment: lp must be null terminated void ParseBlock(const char* lp) { CArray a; unsigned int i,n; int result; for(i=0;lp[i];i+=n) { if(!(n=ParseOneValue(lp+i,result)) break; a.Add( result ); } } unsigned int ParseOneValue(const char* lp,int& result) { unsigned int i; char* e; while(lp[i] && !isdigit(lp[i])) ++i; // trim leading non number chars if(!lp[i]) return 0; if((lp[i]!='0')||(lp[i]!='x')) // lp+i != "0x" hex prefix { // it seems to be decimal number result = strtol(lp+i,&e,10); return e-lp; } i += 2; result = strtol(lp+i,&e,16); return e-lp; } sorry the html won't take the tabs.

              S 1 Reply Last reply
              0
              • M mbue

                I hope to understand you right. The aim is to convert a variable length block of input data with hexadecimal numbers into an array to integers. If it' true try this: // comment: lp must be null terminated void ParseBlock(const char* lp) { CArray a; unsigned int i,n; int result; for(i=0;lp[i];i+=n) { if(!(n=ParseOneValue(lp+i,result)) break; a.Add( result ); } } unsigned int ParseOneValue(const char* lp,int& result) { unsigned int i; char* e; while(lp[i] && !isdigit(lp[i])) ++i; // trim leading non number chars if(!lp[i]) return 0; if((lp[i]!='0')||(lp[i]!='x')) // lp+i != "0x" hex prefix { // it seems to be decimal number result = strtol(lp+i,&e,10); return e-lp; } i += 2; result = strtol(lp+i,&e,16); return e-lp; } sorry the html won't take the tabs.

                S Offline
                S Offline
                srija
                wrote on last edited by
                #7

                How to store the data first in CArray object? am getting continous data output with just Length:204 0x02 0x90 0x02 0x8D 0x02................ LEngth:204 0x02 0x71 0x02 0x78 0x02 0x79 0x0 in C output window, how could i store certain set of data in CArray object?

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups