串口缓冲区是怎么存放数据的?
请问在串口传出数组ByteData的时候像这样写,
每一字节写一次,会不会覆盖上一次写的字节?缓冲区的内容是怎么存放的呢?
byte ch;
for(i=ByteData.Low; i<=ByteData.High; i++)
{
ch=ByteData[i];
WriteFile(hComm,&ch,1,&lrc,NULL);
}
[解决办法]
那你,开个数组,加个计数值不就完了。
[解决办法]
使用 SetupComm 函数设置接收、发送缓冲区大小
After a process uses the CreateFile function to open a handle to a communications device, it can call SetupComm to set the communications parameters for the device. If it does not set them, the device uses the default parameters when the first call to another communications function occurs.
The dwInQueue and dwOutQueue parameters specify the recommended sizes for the internal buffers used by the driver for the specified device. For example, YMODEM protocol packets are slightly larger than 1024 bytes. Therefore, a recommended buffer size might be 1200 bytes for YMODEM communications. For Ethernet-based communications, a recommended buffer size might be 1600 bytes, which is slightly larger than a single Ethernet frame.
使用 ClearCommError 函数获取缓冲区中存在多少数据
The COMSTAT structure contains information about a communications device. This structure is filled by the ClearCommError function.
typedef struct _COMSTAT { // cst
DWORD fCtsHold : 1; // Tx waiting for CTS signal
DWORD fDsrHold : 1; // Tx waiting for DSR signal
DWORD fRlsdHold : 1; // Tx waiting for RLSD signal
DWORD fXoffHold : 1; // Tx waiting, XOFF char rec'd
DWORD fXoffSent : 1; // Tx waiting, XOFF char sent
DWORD fEof : 1; // EOF character sent
DWORD fTxim : 1; // character waiting for Tx
DWORD fReserved : 25; // reserved
DWORD cbInQue; // bytes in input buffer
DWORD cbOutQue; // bytes in output buffer
} COMSTAT, *LPCOMSTAT;
[解决办法]
szInputBuffer 创建了没?