Hi, I find in the msdn sample a little program for use the mscomm32.ocx with VC++6.
My question is : I would like to send binary data on the serialport. How I can do it with this sample ?
example : send byte 0x60, 0x3f, ...
Thanks for Your help ?
Best regards
=========================================
VARIANT var;
// Read/Transmit the file in blocks the size of the transmit buffer.
for (int nRxTx = 0; nRxTx<(nFileSize/nBlockSize) && !m_bCancel; nRxTx++)
{
file.Read(pchBuffer,nBlockSize);
// Convert the ASCII text string to a UNICODE string.
MultiByteToWideChar(CP_ACP,0,pchBuffer,nBlockSize,pchData,nBlockSize);
var.vt = VT_BSTR;
var.bstrVal = ::SysAllocStringLen(pchData,nBlockSize);
// Send data to comm port.
m_commctrl.SetOutput(var);
SysFreeString(var.bstrVal);
// Wait for the transmit buffer to empty.
while ((m_commctrl.GetOutBufferCount() > 0) && !m_bCancel)
DoEvents();
}
My question is : I would like to send binary data on the serialport. How I can do it with this sample ?
example : send byte 0x60, 0x3f, ...
Thanks for Your help ?
Best regards
=========================================
VARIANT var;
// Read/Transmit the file in blocks the size of the transmit buffer.
for (int nRxTx = 0; nRxTx<(nFileSize/nBlockSize) && !m_bCancel; nRxTx++)
{
file.Read(pchBuffer,nBlockSize);
// Convert the ASCII text string to a UNICODE string.
MultiByteToWideChar(CP_ACP,0,pchBuffer,nBlockSize,pchData,nBlockSize);
var.vt = VT_BSTR;
var.bstrVal = ::SysAllocStringLen(pchData,nBlockSize);
// Send data to comm port.
m_commctrl.SetOutput(var);
SysFreeString(var.bstrVal);
// Wait for the transmit buffer to empty.
while ((m_commctrl.GetOutBufferCount() > 0) && !m_bCancel)
DoEvents();
}