Hi dharan,
This code may be useful for u.
RtlInitUnicodeString( &ObjectName, L"\DosDevices\COM1");
status = IoGetDeviceObjectPointer( &ObjectName,
FILE_ALL_ACCESS,
&FileObject,
&COM_Object
);
if (status == STATUS_SUCCESS)
else
{
DbgPrint(“DeviceCreate:IoGetDeviceObjectPointer failed % X”, status);
return FALSE;
}
LineCntrl.StopBits = STOP_BIT_1;
LineCntrl.Parity = NO_PARITY;
LineCntrl.WordLength = SERIAL_DATABITS_8;
irp_l = IoBuildDeviceIoControlRequest(
IOCTL_SERIAL_SET_LINE_CONTROL,
COM_Object,
&LineCntrl,
sizeof(LineCntrl),
NULL,
0,
FALSE,
Event,
&IoStatusBlock
);
if(irp_l == NULL)
{
DbgPrint(“CreateDevice: IoBuildDeviceIoControlRequest Failed”);
return FALSE;
}
status = IoCallDriver( COM_Object, irp_l);
if(status != STATUS_SUCCESS)
{
DbgPrint(“CreateDevice: The Fail Status if IoCallDriver is :
%X”,status);
return FALSE;
}
status = KeWaitForSingleObject(
Event,
Executive ,
KernelMode ,
TRUE,
0
);
if (status != STATUS_SUCCESS)
{
DbgPrint(“CreateDevice:IRP for serial set LCR was Failed”);
return FALSE;
}
KeClearEvent(Event);
If u still find it difficult to solve the problem; send the code u’ve
written.
Regards,
-Naveen
On 01/03/02, “=?iso-8859-1?q?Vidhiyadharan=20Nadarajah?=
” wrote:
> Thankyou naveen,
> I followed the following 2 methods , but i could not
> solve the problem.
>
>
> Method 1
>
> Iam able to open & close the comm port using
> ZwCreateFile & ZwClose File.
> For setting the Baudrate one has to send an IRP with
> IOCTL_SET_SERIAL_BAUD.Here the DeviceObjectPointer of
> (target device)serial port is needed. Since I have
> already opened the comm port using ZwCreateFile , Iam
> getting STATUS_ACCESS_DENIED when I try to get the
> DeviceObjectPointer using IoGetDeviceObjectPointer(…)
> How can i get the deviceobjectpointer?..
>
> Then I followed method 2
>
> 1. Instead of ZwCreateFile, I opened comm using
> IoGetDeviceObjectPointer(serial0,…
> 2. Attach my device to the stack using
> LowerDeviceObject = IoAttachDevicetodeviceStack(…)
> 3. Create the irp using
> BuildIoDeviceControlRequest…with
> IOCTL_SET_SERIAL_BAUD.
> 4. Sending it to lower driver using
> IoCallDriver(LowerDeviceObject,Irp)
>
> Now the system hangs & the display is lost displaying
> uneven lines.How can i overcome this prob?.
>
> How to set the baud rate…?
>
>
> regards
> vdharan
>
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com