| ||||
|
Look RS232
Download Order Support Testimonials FAQ Online help Modem Programming Serial port RS232 Hardware
Interface RS232C
ProgrammingHistory RS232C Likely problems Hardware
Hardware Properties
Interfacing devicesBit Rates DTE/DCE Speeds Flow control The UART Types of UARTs Null modems Loop Back Plug Registers |
|
||||||||
As COM-ports are asynchronous connection devices, buffers for incoming and outgoing data are provided to make the work with the ports more effective. It is connected with the fact that the data bus baud rates greatly varies from the line baud rates, that's why to optimize the work of the system it is advisable to read data from/write data into the port by batches regardles of when they were received. One can also write data into the buffer and only then start the transmission - it is useful when the batch transmission is needed regardless of whether the system is busy. To set the size of the receiving and transmitting buffers SetupComm function is used. Function syntax:
BOOL SetupComm(HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue);
Parameters specifications:
hFile � the descriptor of the open communication port file;
dwInQueue - receiving buffer size, in bytes; dwOutQueue - transmitting buffer size, in bytes Note
Let's assume you exchange 1024-byte-batches of information with en external device. In this case the reasonable size of buffers will be 1200. SetupComm function is also interesting as it can just take the size you specify into consideration and correct it, or it can reject the specified size of buffers - in this case its work will end in an error.
Function usage example: if (!SetupComm(hCOM,2048,2048)) cout << "Error Open" << endl; | |||||||||
Contact us © fCoder SIA |