Write Method
Writes specified number of bytes to serial port.
Syntax
Visual Basic | - |
---|---|
Visual C++ (MFC) | long Write(long DataBuffer, long BytesToWrite); |
Visual C++ (#import) | LONG Write(LONG DataBuffer, LONG BytesToWrite); |
Parameters
DataBuffer
[in] Buffer of characters to be written. Use type-casting to convert it from void* or char*.
BytesToWrite
[in] Number of bytes to write to serial port.
Return
Number of bytes written to serial port. It can write fewer bytes than requested; the return value must be noted, and the reminder of the operation should be retried when possible.
Errors
The method may throw exception. Use GetLastError method to get the error code.
Remarks
In Visual Basic use WriteArray.
Code Example
char *WriteBuffer = "Data to write"; try { m_SPCControl1.Write((LONG)WriteBuffer, strlen(WriteBuffer)); } catch(COleDispatchException* E) { MessageBox(E->m_strDescription, mbCaption, MB_OK | MB_ICONERROR); }