Reads specified number of bytes from serial port.
| Visual Basic | -
|
|---|---|
| Visual C++ (MFC) | long Read(long DataBuffer, long BytesToRead);
|
| Visual C++ (#import) | LONG Read(LONG DataBuffer, LONG BytesToRead);
|
DataBuffer
[out] Pointer to the buffer that receives the data. Use type-casting to convert it to void* or char*.
BytesToRead
[in] Number of bytes to read from serial port
Number of bytes read from serial port.
The method may throw exception. Use GetLastError method to get the error code.
In Visual Basic use function ReadArray.
void CSPCDemoDlg::OnReceiveFtspccontrol1(unsigned long Count)
{
CHAR *Buffer = new CHAR[Count];
LONG ReadCnt;
try
{
ReadCnt = m_SPCControl1.Read((LONG)Buffer, Count);
}
catch (COleDispatchException* E)
{
MessageBox(E->m_strDescription, mbCaption,
MB_OK | MB_ICONERROR);
}
for (int i = 0; i < ReadCnt; i++)
{
PCHAR P = (PCHAR)Buffer + i;
// Todo: add your code
}
}