Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Sending BYTE to serial port - C++

Avatar of arunykand
arunykandFlag for United States of America asked on
CC++Editors IDEs
5 Comments1 Solution778 ViewsLast Modified:
Hi, I have a 5 byte 'unsigned char' data structure: unsigned char m_TxBuf[5];, and I need to send one byte at a time to a function that will write the data to the serial port.  I have the functions in place, but I guess the way i'm trying to send each byte to the function that writes to the serial port is not correct.  

	

       unsigned char m_TxBuf[5];

        //Call function to write one byte at a time to serial port
	Serialport.WriteByte(m_TxBuf[0]);    //Problem compiling
        Serialport.WriteByte(m_TxBuf[1]);    //Problem compiling

        Serialport.WriteByte(m_TxBuf);  //No problem if I send the entire data structure

BOOL CSerialPort::WriteByte(BYTE *bybyte)
{
	iBytesWritten=0;
if(WriteFile(hComm,bybyte,1,&iBytesWritten,NULL)==0)
    return false;
     else return true;
}

I get the following error when compiling:

error C2664: 'CSerialPort::WriteByte' : cannot convert parameter 1 from 'unsigned char' to 'BYTE *'

Thanks for your help
ASKER CERTIFIED SOLUTION
Avatar of Harisha M G
Harisha M GFlag of India imageEngineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answers