|
Can any one suggest me some ways to monitor the cts pin of the serial port using DCB.
S.Yamini
|
|
|
|
|
i have worked very enough with serial port(RS 232).
but never heard of the cts pin and dcb.
atleast for my information please educate me regarding those.
then i will try to solve if it in my perview.
thanku.
|
|
|
|
|
I am using vc++ 6.0 for serial port communication. dcb is structure defines the control setting for a serial communications device.
I have to monitor the cts (Clear to send)pin of the serial port.
S.Yamini
|
|
|
|
|
I use PCOMM library for sending and receiving data using serial port.
functions are like
sio_ioctl(); to define the port settings.
sio_read();
sio_write();
soi_iqueue();to find weather any data is there in the port.
may be i can help you if you are also using these libraries and functions.
|
|
|
|
|
yaminisridaran wrote: Can any one suggest me some ways to monitor the cts pin of the serial port using DCB.
i think u need to set fOutxCtsFlow flag of the DCB to TRUE to monitor the CTS signal.
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
I have set fOutxCtsFlow to true but it is always true even if the voltage level in cts pin changes.
S.Yamini
|
|
|
|
|
|
I already using GetCommState.
My Code
CString strPort;
strPort.Format("COM%d:",1);
m_hPort=CreateFile(strPort,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if(m_hPort==INVALID_HANDLE_VALUE)
{
return false;
}
GetCommState(m_hPort,&dcb);
BOOL res;
dcb.fOutxCtsFlow=true;
res=SetCommState(m_hPort,&dcb);
// Configure serial port
GetCommState(m_hPort,&dcb);
if(dcb.fOutxCtsFlow==TRUE)
TRACE("TURNED OFF");
else if(dcb.fOutxCtsFlow==FALSE)
{
TRACE("TURNED ON");
}
dcb.fOutxCtsFlow is always true even the voltage level changes
S.Yamini
|
|
|
|
|
Did you read my message ? Where do I speak about GetCommState ? I even gave you the link to the documentation, did you have a look at them ?
|
|
|
|
|
Hey guys,
I develop applications using MFC and Visual C++ 6 and I am working on a particular application that needs to access data over the internet.
Can I do this using the MFC Framework or am I better just biting the bullet and get myself up to speed with Visual C# 2005?
Best Regards
Danny Nowlan
|
|
|
|
|
|
|
Yeah thats right,;) Hi Alok how are you?
I think its better I use of my name and also without any sig very simple.
|
|
|
|
|
|
can anyone tell me what is INT_PTR ?
thanks
|
|
|
|
|
A signed integral type that is the same size as a pointer. So 4 bytes in Win32, 8 bytes in Win64.
|
|
|
|
|
same size as a pointer, but its not a pointer. correct ?
|
|
|
|
|
you got it...
it's simply badly named. but it's an int...
|
|
|
|
|
How about pressing F12 on it, or at least open basetsd.h and search for it?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi all vc++ masters \
i use this code for cd rom open and close
but this gives
'OpenVolume' : local function definitions are illegal
'OpenVolume' : cannot convert parameter 1 from 'char [3]' to 'char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
NOTE:the line contain stars shows errors;
DWORD IOCTL_STORAGE_EJECT_MEDIA;
DWORD bytesreturned;
HANDLE OpenVolume(TCHAR cDriveLetter)
****{HANDLE hVolume;
UINT uDriveType;
TCHAR szVolumeName[8];
TCHAR szRootName[5];
DWORD dwAccessFlags;
wsprintf(szRootName, szRootFormat, cDriveLetter);
uDriveType = GetDriveType(szRootName);
switch(uDriveType) {
case DRIVE_REMOVABLE:
dwAccessFlags = GENERIC_READ | GENERIC_WRITE;
break;
case DRIVE_CDROM:
dwAccessFlags = GENERIC_READ;
break;
default:
_tprintf(TEXT("Cannot eject. Drive type is incorrect.\n"));
return INVALID_HANDLE_VALUE;
}
wsprintf(szVolumeName, szVolumeFormat, cDriveLetter);
hVolume = CreateFile( szVolumeName,
dwAccessFlags,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL );
if (hVolume == INVALID_HANDLE_VALUE)
ReportError(TEXT("CreateFile"));
return hVolume;
}
*****HANDLE hVolume = OpenVolume("D:");DeviceIoControl( hVolume, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &bytesreturned, NULL );
thanks
special thanks to MR Naveen
|
|
|
|
|
//the first error may be caused by placing function OpenVolume inside of another funtion.
//the second is, TCHAR cDriveLetter means just pass a single charecter (Driveletter ie, 'D' )
//DWORD IOCTL_STORAGE_EJECT_MEDIA allready defined in winioctl.h
DWORD bytesreturned ;
TCHAR szRootFormat[5] = {"%c:\\" } ;
TCHAR szVolumeFormat[9] = {"\\\\.\\%c:" } ;
HANDLE OpenVolume( TCHAR cDriveLetter )
{
HANDLE hVolume;
UINT uDriveType;
TCHAR szVolumeName[8];
TCHAR szRootName[5];
DWORD dwAccessFlags;
wsprintf(szRootName, szRootFormat, cDriveLetter);
uDriveType = GetDriveType(szRootName);
switch(uDriveType)
{
case DRIVE_REMOVABLE:
dwAccessFlags = GENERIC_READ | GENERIC_WRITE;
break;
case DRIVE_CDROM:
dwAccessFlags = GENERIC_READ;
break;
default:
_tprintf(TEXT("Cannot eject. Drive type is incorrect.\n"));
return INVALID_HANDLE_VALUE;
}
wsprintf(szVolumeName, szVolumeFormat, cDriveLetter);
hVolume = CreateFile( szVolumeName ,
dwAccessFlags,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL );
if ( hVolume == INVALID_HANDLE_VALUE )
{
_tprintf(TEXT("Error Creatfile ") ) ;
}
return hVolume ;
}
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hVolume = OpenVolume( 'D' ) ; //TCHAR Stands for a single charecter
DeviceIoControl( hVolume, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &bytesreturned, NULL );
return 0;
}
|
|
|
|
|
thanks sir
i us this code as u specify but problem is now as:
errors:
'OpenVolume' : local function definitions are illegal
main' : local function definitions are illegal
i use whole code inside this :
void CInoutDlg::OnButton3()
now please tell me where am i wrong
thanks
|
|
|
|
|
u should not place the HANDLE OpenVolume( TCHAR cDriveLetter ) definsion insde of "void CInoutDlg::OnButton3()" because this is another function, one function definition cant be place inside of another one.
//so put the code here
HANDLE OpenVolume( TCHAR cDriveLetter )
{
...
}
void CInoutDlg::OnButton3()
{
//call OpevVolume
HANDLE hVolume = OpenVolume( 'D' ) ; //TCHAR Stands for a single charecter
DeviceIoControl( hVolume, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &bytesreturned, NULL );
}
|
|
|
|
|
|
Hi all
Can we use windows filtering platform APIs in windows XP SP 2 and window 2000
Regards
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|