If I use COM1(hCom1) write data and COM2(hCom2) to receive data, so:
the problem now is:
#define input_Buffer 2 //for hCom2 input buffer
//#define output_Buffer 10
SetupComm(hCom2, input_Buffer, output_Buffer)
/* hCom2 only can have only 2 bytes receved at time, right??*/
/*assume that there are 100 bytes already in hCom1 and I use one cable to connect COM1 and COM2 with each other*/
/*now I start reading from COM2*/
ReadFile(hCom2, &valRead, 10, &dwRead, NULL);
I think there must be only 2 bytes in buffer valRead cause the maximum input buffer in hCom2 is 2 bytes only. But always there are 10 bytes in valRead, Why??? and it still is not working with
Thanks for help.
Don't call SetupComm(). The device driver will use setup appropriate default values for you.
You don't want to limit the receive buffer for your port. Just read 2 bytes at a time if that's what you're trying to accomplish.
Use the SFile object I showed you in your other thread, or use is as a reference for Win32 serial communications.