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. Managed C++/CLI
  4. Checking for presence of System::IO::Ports::SerialPort

Checking for presence of System::IO::Ports::SerialPort

Scheduled Pinned Locked Moved Managed C++/CLI
c++questionsharepointtestingbeta-testing
2 Posts 2 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.
  • B Offline
    B Offline
    BubbaGeeNH
    wrote on last edited by
    #1

    I'm attempting to write communication software to talk to a laser via RS232. If I setup a Managed C++ class that has a SerialPort variable how can I test the variable to see that it is present or has a valid value. So in my code I have: .h file -------- SerialPort^ sp; .cpp file --------- if(sp) //Testing to see if 'sp' has already been assigned a value. { if(sp->IsOpen) sp->Close(); } sp = gcnew SerialPort("Com1"); Any idea how to check to see if an Object handle has been assigned? Thanks,

    George

    Z 1 Reply Last reply
    0
    • B BubbaGeeNH

      I'm attempting to write communication software to talk to a laser via RS232. If I setup a Managed C++ class that has a SerialPort variable how can I test the variable to see that it is present or has a valid value. So in my code I have: .h file -------- SerialPort^ sp; .cpp file --------- if(sp) //Testing to see if 'sp' has already been assigned a value. { if(sp->IsOpen) sp->Close(); } sp = gcnew SerialPort("Com1"); Any idea how to check to see if an Object handle has been assigned? Thanks,

      George

      Z Offline
      Z Offline
      zhushaolin2005
      wrote on last edited by
      #2

      ...sp=nullptr; if (sp==nullptr) { dosometing; } alse,you can do like this ..sp; if (sp==nullptr) { dosometing; } in the c++/cli,the default object is equal to "nullptr".

      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