Question : Sending BYTE to serial port - C++

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.  

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
	

       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

Answer : Sending BYTE to serial port - C++

     Serialport.WriteByte(&m_TxBuf[0]);
       Serialport.WriteByte(&m_TxBuf[1]);


Random Solutions  
 
programming4us programming4us