Yes, there is. Use the name given to you by the IOCTL directly. There is no guaranteed relationship between the com port number and the device object’s name that the com port name points to. Since you are getting a symbolic link name, you can preprent ??\ to it (e.g. ??\COM1) and then you do not have to assume anything about the device object’s name.
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mattias Br?ndstr?m
Sent: Monday, January 14, 2008 4:28 AM
To: Windows System Software Devs Interest List
Subject: SV: [ntdev] serenum problems
Thanks for your pointers!
I just wanted to double check that I am using doing anything out of the ordinary when opening the serial device. In my prepare hardware function I basically do the following:
- Get the serunum i/o target with WdfDeviceGetIoTarget().
- Get the serial port name using IOCTL_SERENUM_GET_PORT_NAME.
- Parse port name string to get the port number.
- Append (port number - 1) to the string \Device\Serial.
- Create a new i/o target with WdfIoTargetCreate().
- Open the serial port with a call to WdfIoTargetOpen() using the
string from step 4.
This is the most straightforward way I have found to do this. I guess this is the way to do it or can serenum help me even more than it already does?
:.:: mattias
-----Ursprungligt meddelande-----
Fr?n: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] F?r Doron Holan
Skickat: den 10 januari 2008 22:41
Till: Windows System Software Devs Interest List
?mne: RE:[ntdev] serenum problems
The serenum soures are in the WDK so you can look there as to how the pnp revision is interpreted. You have a issues though
-
you are writing a pnp driver but you do not have an AddDevice routine in your driver, if you want a loadable driver that is quick to write and does not ! out in device manager, write a KMDF one. Otherwise you will have to implement a lot of code that does nothing for you
-
DbgPrints not showing. what OS is this on? By default on vista DbgPrints are not shown in the debugger so your driver could very well be loading and you just don’t see it. Put a bp on your DriverEntry (using the ‘bu’ command so that you can set an unresolved breakpoint) before you enumerate your “device” and see if the bp fires
-
the device is not reported as missing when you disconnect. By design. Serenum just detects that something has been found and then enumerates it. since your driver does not open the com port nor does it actually start properly if you scan in device manager again, it will probably disappear. Once you get a functional driver up and running, the driver itself will need to detect that the attached device has been removed (the mouser example shows how to do this, it monitors one of the serial lines). Once your driver detects that its device has been disconnected, you tell serenum that it is gone (by sending IOCTL_INTERNAL_SERENUM_REMOVE_SELF to the stack below you) and it will be removed
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mattias Br?ndstr?m
Sent: Thursday, January 10, 2008 8:49 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] serenum problems
Hello!
I’m trying to write a smart card driver that will be loaded by serenum. As part of that effort I have written a small application that emulates the behavior of my device when reporting the COM Device ID.
The COM Device ID string I’m using right now is “\0x01\0x24TDS4242”. I have not been able to find a description on what PnP revisions I can use. My current ID has PnP revision 1.00 (I just picked a number that seemed as good as any other). What would be the correct PnP revision to use? Can someone perhaps point me to a document describing different PnP revisions?
When scanning for hardware changes via the Device Manager my PC detects my emulated device on COM1 and I can install my minimal driver using the hardware wizard. The driver does not do anything else than using DbgPrint to show that it has been loaded (and unloaded):
#include <ntddk.h>
void DriverUnload(PDRIVER_OBJECT pDriverObject)
{
DbgPrint(“Driver unloaded!!”);
}
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
DriverObject->DriverUnload = DriverUnload;
DbgPrint(“Driver loaded!!”);
return STATUS_SUCCESS;
}
However, when I install the driver (using the hardware wizard) nothing shows up in DbgView. The device shows up in the Device Manager with the name specified by me. The driver version and driver date seems to be correct and my sys file is installed.
Also, when unplugging my laptop (the computer I use when emulating the device), the device does not disappear from the Device Manager. When I have experimented with an old serial Microsoft mouse, unplugging it removes it from the Device Manager. I would have thought that serenum would monitor the comm port and unload my driver when the device is disconnected. Perhaps the problem is that my driver has not been loaded correctly?
I realize there are a lot of loose ends here. If someone has some ideas of why my DbgPrint messages don’t show and why the device isn’t removed from the Device Manager view it would be great!
Regards,
Mattias
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</ntddk.h>