enemra
Junior Member level 1
Dear all,
I am struck with serial port programming. The scenario is like this-
PROBLEM 1:
Establish a communication between PC and a microcontroller board via serial port. There are options in microcontroller to set HARDWARE HANDSHAKE or SOFTWARE HANDSHAKE.
My program in PC side is like this...........
if (iHandshakeType=="SOFTWARE")
{
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fOutX = TRUE;
dcb.fInX = TRUE;
dcb.XonChar = 0x11;
dcb.XoffChar = 0x13;
dcb.XoffLim = 100;
dcb.XonLim = 100;
}
if (iHandshakeType=="HARDWARE)
{
dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
dcb.fOutxDsrFlow = FALSE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
}
The hardware handshaking works fine but software handshaking doesn't work.
It is given in microcontroller datasheet that it sends data if it receives XON from PC side. Other than this, nothing else is mentioned.
I also doub't whether XON lim should be 1 ????
PROBLEM 2:
Suppose if the above program works fine, can I write like this..???
"
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fOutX = TRUE;
dcb.fInX = TRUE;
dcb.XonChar = 0x11;
dcb.XoffChar = 0x13;
dcb.XoffLim = 100;
dcb.XonLim = 100;
dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
dcb.fOutxDsrFlow = FALSE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
"- enable both hardware and software handshake no matter either any option is selected in the board. Will this work??
PROBLEM 3:
Is it necessary that I should mention these lines in code?
dcb.XonChar = 0x11;
dcb.XoffChar = 0x13;
dcb.XoffLim = 100;
dcb.XonLim = 100;
Won't dcb.fOutX = TRUE;
dcb.fInX = TRUE; Isn't these are just enough for SOFTWARE handshake?
Thanks
I am struck with serial port programming. The scenario is like this-
PROBLEM 1:
Establish a communication between PC and a microcontroller board via serial port. There are options in microcontroller to set HARDWARE HANDSHAKE or SOFTWARE HANDSHAKE.
My program in PC side is like this...........
if (iHandshakeType=="SOFTWARE")
{
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fOutX = TRUE;
dcb.fInX = TRUE;
dcb.XonChar = 0x11;
dcb.XoffChar = 0x13;
dcb.XoffLim = 100;
dcb.XonLim = 100;
}
if (iHandshakeType=="HARDWARE)
{
dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
dcb.fOutxDsrFlow = FALSE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
}
The hardware handshaking works fine but software handshaking doesn't work.
It is given in microcontroller datasheet that it sends data if it receives XON from PC side. Other than this, nothing else is mentioned.
I also doub't whether XON lim should be 1 ????
PROBLEM 2:
Suppose if the above program works fine, can I write like this..???
"
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fOutX = TRUE;
dcb.fInX = TRUE;
dcb.XonChar = 0x11;
dcb.XoffChar = 0x13;
dcb.XoffLim = 100;
dcb.XonLim = 100;
dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
dcb.fOutxDsrFlow = FALSE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
"- enable both hardware and software handshake no matter either any option is selected in the board. Will this work??
PROBLEM 3:
Is it necessary that I should mention these lines in code?
dcb.XonChar = 0x11;
dcb.XoffChar = 0x13;
dcb.XoffLim = 100;
dcb.XonLim = 100;
Won't dcb.fOutX = TRUE;
dcb.fInX = TRUE; Isn't these are just enough for SOFTWARE handshake?
Thanks
Last edited: