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. Managed C++/CLI
  4. RS232 IN C++/CLI .NET2 vs2005

RS232 IN C++/CLI .NET2 vs2005

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++data-structuresquestion
3 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.
  • Y Offline
    Y Offline
    yonas_mgm
    wrote on last edited by
    #1

    Dear all, I have been trying to send a string and read through Rs232 loop back null modem using the .net2 class serial port. The code is below: the program sort of works but does not print "hello world", it prints the number 5, which is the byte size i am looking to print. i expected "hello" to print. any ideas as to where i am going wrong? many thanks. void SendRs232Data() { serialPort->Open(); serialPort->Write("Hello World"); int offset = 0;//The offset in the buffer array to begin writing. int count = 5; //The number of bytes to read. array^ buffer = gcnew array (10);//The buffer array to write the input to. serialPort->Read(buffer, offset, count); lblSerial->Text= (serialPort->Read(buffer, offset, count)).ToString(); serialPort->Close(); }

    R 1 Reply Last reply
    0
    • Y yonas_mgm

      Dear all, I have been trying to send a string and read through Rs232 loop back null modem using the .net2 class serial port. The code is below: the program sort of works but does not print "hello world", it prints the number 5, which is the byte size i am looking to print. i expected "hello" to print. any ideas as to where i am going wrong? many thanks. void SendRs232Data() { serialPort->Open(); serialPort->Write("Hello World"); int offset = 0;//The offset in the buffer array to begin writing. int count = 5; //The number of bytes to read. array^ buffer = gcnew array (10);//The buffer array to write the input to. serialPort->Read(buffer, offset, count); lblSerial->Text= (serialPort->Read(buffer, offset, count)).ToString(); serialPort->Close(); }

      R Offline
      R Offline
      RSangeetha
      wrote on last edited by
      #2

      serialPort->Read(buffer, offset, count) This function returns the number of bytes read.Since u have given the count value as 5,it would always return 5.Get the expected data from the buffer array

      Y 1 Reply Last reply
      0
      • R RSangeetha

        serialPort->Read(buffer, offset, count) This function returns the number of bytes read.Since u have given the count value as 5,it would always return 5.Get the expected data from the buffer array

        Y Offline
        Y Offline
        yonas_mgm
        wrote on last edited by
        #3

        Thanks. Can you suggest what statment i need in ordr to read from the port?

        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