Reading byte from serial ports

Discussion in 'C#' started by firstoption, Jun 8, 2014.

  1. firstoption

    firstoption New Member

    Joined:
    Apr 1, 2014
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Good day to all,
    Please I need your guide and support on how to use this function:
    Code:
    ftStatus = myFtdiDevice.Read(readData, numBytesAvailable,ref numBytesRead); 
     
     
    to read byte from the serial port.This function is part of the DLL that came with the chip(FT2232D) I am using on my board.I want to use the function to read a byte from the serial port and then send the value to the Graphic user interface.Unfortunately I was unable to get the expected value on my GUI.If I send for instance 40,what I get on the GUI are letters instead of the number 40 or at times the GUI will not even respond.Below are my lines of code I used to read the byte from the serial port:

    The following instructions are executed whenever the CHECKBOX is checked

    Code:
    private
    void checkBox1_CheckedChanged(object sender, EventArgs e)
    
             {
    
                 
     
    UInt32 numBytesRead = 0;
    
                 
    UInt32 numBytesAvailable = 1;
    
                 ftStatus = myFtdiDevice.Read(readData, numBytesAvailable, ref numBytesRead);
     
    
                 label11.Text =Convert.ToString(ftStatus);
    
    
    
      
      
     
      
    
             }
    
     
    Below is the definition of the function from the supplied library:
    Code:
      Read data from an open FTDI device.
    
            
    //
    
            
    // Parameters:
    
            
    //   dataBuffer:
    
            
    //     An array of bytes which will be populated with the data read from the device.
    
            
    //
    
            
    //   numBytesToRead:
    
            
    //     The number of bytes requested from the device.
    
            
    //
    
            
    //   numBytesRead:
    
            
    //     The number of bytes actually read.
    
            
    //
    
            
    // Returns:
    
            
    //     FT_STATUS value from FT_Read in FTD2XX.DLL
    
            
    publicFTDI.FT_STATUS Read(byte[] dataBuffer, uint numBytesToRead, refuint numBytesRead);
    
     
    Your guide and assistance will be highly appreciated in this regard.
    Best regards.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice