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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Question on serial port and data buffer

Question on serial port and data buffer

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformancetutorial
5 Posts 3 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.
  • K Offline
    K Offline
    knightri
    wrote on last edited by
    #1

    I have a GPS program serially reading incoming data. A sample of my code is below. // get speed Code = mgcGetData(GPRMC_SPEED,(LPSTR)DataBuffer); if(Code<0) ShowMGC32Error(Code); if(Code>0) printf("%5s ", DataBuffer); I have the program printing a few of these data buffers to the screen. I was wondering how to store this data file readout into a actual variable so i can do some calculations i cant just do variable=databuffer; ???

    S P 2 Replies Last reply
    0
    • K knightri

      I have a GPS program serially reading incoming data. A sample of my code is below. // get speed Code = mgcGetData(GPRMC_SPEED,(LPSTR)DataBuffer); if(Code<0) ShowMGC32Error(Code); if(Code>0) printf("%5s ", DataBuffer); I have the program printing a few of these data buffers to the screen. I was wondering how to store this data file readout into a actual variable so i can do some calculations i cant just do variable=databuffer; ???

      S Offline
      S Offline
      Simon W 0
      wrote on last edited by
      #2

      TCHAR szData[16]; wsprintf(szData,_T("%5s"),DataBuffer); or use sprintf,(CRT Library) I am seeking... For what? Why did you ask me for what? I don't know!

      K 1 Reply Last reply
      0
      • S Simon W 0

        TCHAR szData[16]; wsprintf(szData,_T("%5s"),DataBuffer); or use sprintf,(CRT Library) I am seeking... For what? Why did you ask me for what? I don't know!

        K Offline
        K Offline
        knightri
        wrote on last edited by
        #3

        i get these errors C:\Program Files\Microsoft Visual Studio\VC98\MGC4C\apps\gprmc.c(125) : warning C4013: '_T' undefined; assuming extern returning int C:\Program Files\Microsoft Visual Studio\VC98\MGC4C\apps\gprmc.c(125) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int ' C:\Program Files\Microsoft Visual Studio\VC98\MGC4C\apps\gprmc.c(125) : warning C4024: 'wsprintfA' : different types for formal and actual parameter 2

        S 1 Reply Last reply
        0
        • K knightri

          I have a GPS program serially reading incoming data. A sample of my code is below. // get speed Code = mgcGetData(GPRMC_SPEED,(LPSTR)DataBuffer); if(Code<0) ShowMGC32Error(Code); if(Code>0) printf("%5s ", DataBuffer); I have the program printing a few of these data buffers to the screen. I was wondering how to store this data file readout into a actual variable so i can do some calculations i cant just do variable=databuffer; ???

          P Offline
          P Offline
          Paul Ranson
          wrote on last edited by
          #4

          I assume you want to convert a string of some form into a number of some form. So look at 'atoi' as a first pass, then 'strtoul' and it's relatives, possibly 'scanf'. Paul

          1 Reply Last reply
          0
          • K knightri

            i get these errors C:\Program Files\Microsoft Visual Studio\VC98\MGC4C\apps\gprmc.c(125) : warning C4013: '_T' undefined; assuming extern returning int C:\Program Files\Microsoft Visual Studio\VC98\MGC4C\apps\gprmc.c(125) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int ' C:\Program Files\Microsoft Visual Studio\VC98\MGC4C\apps\gprmc.c(125) : warning C4024: 'wsprintfA' : different types for formal and actual parameter 2

            S Offline
            S Offline
            Simon W 0
            wrote on last edited by
            #5

            include tchar.h in stdafx.h or remove _T() mark I am seeking... For what? Why did you ask me for what? I don't know!

            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