|
duo!@# wrote: I did some research and found out about virtual com ports which fools the program into thinking that the usb port is a com port but i'm not sure how to create one, do i need to do it this way or is there another way in which i could directly send data(binary) to the VB program
You're combining two different views of the same thing. Accessing your USB as a COM port is a user-mode view and sending data to the program is a kernel-mode view.
From the hardware's perspective, USB comms are not as simple as communication via a serial port. You can't just twiddle the signal lines and have that data auto-magically appear as input data from a COM port. As the hardware provider, you need to create a driver that exposes your USB devices as "something" and you determine whether that something is a COM port or a removable disk or a NIC.
From the using-software's perspective, you access whatever device type your hardware provider has given you.
It's not clear from your post whether you are trying to use a third-party USB device or are providing the USB device. If the former, you need to get the driver and documentation from your hardware provider that tell you how to access the device. If the latter, ... I haven't researched it but there may be some kits out there for hardware creators that provide the driver to convert your USB into a virtual COM port and specifiy what you need to do to the USB signals to use their product. Otherwise, you need to write a driver.
Judy
|
|
|
|
|
Hello there!
If you know how to read the USB device from usermode then perhaps you can just read the USB device normally and write it to a virtual bridged COM port pair. I am doing this with a modified version of the the Null-modem emulator located at:
http://com0com.sourceforge.net/[^]
I use it to create 100 virtual COM ports. You may be asking 'Why would you need 100 virtual COM ports?' and the answer is because on my project I have radar, wind sensors, gyro, VRU, DGPS,Laser fanbeam and other types of navigation hardware and they all need to communicate with multiple programs running on a single machine which required COM ports greater than was physically available!
Here are some links to some other serial port emulation drivers! All of which can be used to accomplish your goal.
http://developer.berlios.de/projects/n8vbvcomdriver/[^]
http://www.mixw.net/files/ComEmulDrv3.zip[^]
Good Luck!
-David Delaune
|
|
|
|
|
thanks guys i feel that i'm getting close to solving this problem, i made this device on my own. It's
a simple circuit which i wish to test. Using an ACD converter chip i intent to see the binary
conversion in my VB program this information is transmitted via USB this way i dont have to use a
microcontroller(c programming is troublesome). The binary conversion output pins are 8. Hmm i was so
focused on using the USB port that i didnt look at how to send the 8 pins data through USB cable which
has 4 pins (V+ D+ D- gnd).I bet theres someone out there who knows how to to it.
IN future USB interfaced devices will be the standard thats y i'm doing it this way.
|
|
|
|
|
you're going to have to multiplex your data to send it serially. V+ and gnd are power, you cna't send data over them. D+ and D- are data but carry reversed sign copies of the same data. ie if D+ is +5v D- is -5v. The higher voltage differential reduces the affect of noise on the line.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|
|
which multiplexing IC chip would u recommend I'm using ADC0804LCN. Theres also one more hurdle the VB
program how to i program the code to receive data from the USB.
Wow i didn know about the D+ D- function. I only know data travels through it
|
|
|
|
|
not a clue on the IC.
For your VB app your choices are to either make your device look like an exising device to use it's driver or to write your own. Writing drivers is really hard. You need to use C++, use the DDK (very badly documented, little tutorial info available), and write kernal mode code (will crash your OS when it errors).
If this is just a forfun project I'd strongly recomend getting a USB-RS232 dongle and implementing that (much simpler) interface.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|
|
I've read about microcontrollers(i'm only familiar with PIC series and i'm not good at programming it)
with USB engine(not certain) or USB support do u know of any such PIC's
And whts a driver
|
|
|
|
|
There are several PIC microcontrollers that have USB functionality... also, almost all have serial (USART) so a USB-to-serial converter (that has previously been mentioned) would also work.
16C745, 18F2455 both have USB.
Also... Most PICs have built-in A2D converters (the standard is 10 bit but some are 12 bit).
I've also found this site that may help... http://www.alanmacek.com/usb/[^]
Hope this helps.
Matthew Butler
|
|
|
|
|
A driver is a piece of software that runs in the OS kernel and interfaces with it and the hardware device. IF you don't even know what one is you have no business trying to write one. Either find something else you can implement the hardware for or just fall back to RS232. Unlike USB it's a very dumb interface (60's vintage) and is controlled by just setting voltages on both ends.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|
|
Thanks guys ur knowledge of this stuff is very useful. Well i done know anything about drivers, but i
want my device to be usable when plucked into different computers USB port. Is that done with driver
which part of the circuit would stores this information. Example like a USB keyboard u plug and play
one part of the circuit or microcontroller stores this infromation(its the driver right). I'm assuming
these from a logical point of view. I am sry if my driver questions are annoying, but i find it
interesting.
Which PIC would u recommend i use the PIC18 series or PIC16. theres also this red disc shaped
thing(complier) do they share the same USB connection or different.
|
|
|
|
|
Hi,
A driver is a program that communictes with the peripheral device (it isn't actually on the device, but on the computer).
A plug and play device doesn't remember the computer it connects to... the computer remembers the device that has connected to it.
(Usually peripheral devices don't have any memory).
To send information through the USB port an a PC you will need to find a method of using an existing (default) driver that is 'pre-installed'... or finding a driver (a .dll or similar) that you can 'take along with the program'.
Either way... Google will help.
As for the PICs... I used to use the 16 series but after going to 18s, they are much more powerful... I would use these.
The 'red disc shaped thing' is only a programmer (not a compiler)... It will probably say Microchip on it... This connects to your computer via USB and to the PIC via another method (not USB).
Once you have programmed the PIC... you can completely disconnect the programmer... you no longer need this to run the program (if you didn't already know this).
The PIC USB pins are seperate from the programming pins.
You will need to read the datasheet of the PIC you choose to use... there will be examples on how to both connect and use the USB 'port'.
Matthew Butler
|
|
|
|
|
Thanks Matthew, that link u provided was very useful,do u know of any links which have example circuits
using the PIC184550(are there any new versions )with the C code. I plan to use the PIC184550 chip(i
think its the latest).
|
|
|
|
|
There are loads of example circuits about.
Here's one (the 'Vusb' pin (connected to ground via a small capacitor) is important).
http://www.electronics-lab.com/blog/wp-content/uploads/2007/10/schematic.gif[^]
The PIC18F4550 is one of the newest versions in the 18 series (bearing in mind there are also PIC24, PIC30, PIC33 series).
Look at section 17.0 in this[^] datasheet (for the PIC18F4552)... there is also a small circuit example and the relevent code to use the USB port.
The PIC18F4550 is 'well known' so there is loads of examples (including C code) available after a few Google searches. (I prefer Assembler to C so I can't help with any sources).
Hope this helps.
Matthew Butler
modified on Friday, March 14, 2008 12:29 PM
|
|
|
|
|
I came across this while looking for something else on the internet. It probably qualifies as that support kit containing a generic driver I mentioned in my earlier reply (I haven't looked into it in detail to see how you can use it with a self-built device).
LibUSB-Win32[^]
Judy
|
|
|
|
|
|
Huh?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi
I Edit this for my friend question;my purpose is not for all;
Thanks
|
|
|
|
|
Hi there,
i am new to driver-programming and right now im trying to get into it, especially filter drivers, which turns out to be pretty hard for a newbie.
I try to discover if a file system filter driver or a minifilter in windows provides the possibility of returning more files than actually exist. As i found out, the IRP_MJ_CREATE request gets called whenever i try to open a folder, a file or a device. What i couldnt discover by now is, how i can detect to what type this request refers to(file/folder). What i also didnt get is: if a folder is requested, how and when does windows enumerate the files under the folder?
My approach for the "virtual elements" would be to set a filter, which detects when folder "A" wants to enumerate its children and just adds one that isnt actually there but i cant perceive how to hook into this request. Maybe someone can help me?
Some of you might wonder why i try to do this by a filter, if there already is such a thing as a shell namespace extension: I think that this could give me the possibility not even to have a virtual drive in the windows explorer but to have it actually inside my file system, so i can approch elements beneath it by file-paths. All in all it seems to be more powerful than the extension and i want to estimate if this desired benefit justifies the additional expenses that i expect in development.
I would be deeply grateful to any comment, that helps me understanding this technology or that discusses my intention.
|
|
|
|
|
gn0tto wrote: Hi there,
i am new to driver-programming and right now im trying to get into it, especially filter drivers, which turns out to be pretty hard for a newbie.
I try to discover if a file system filter driver or a minifilter in windows provides the possibility of returning more files than actually exist.
It would be easier to accomplish this by hooking ZwQueryDirectoryFile. If you look at the declaration of ZwQueryDirectoryFile you will see it is passed a constant named FileInformationClass. The return buffer may contain one of various structs depending on the FileInformationClass that was passed. Which can be one of the following values:
FileBothDirectoryInformation Return a FILE_BOTH_DIR_INFORMATION structure for each file.
FileDirectoryInformation Return a FILE_DIRECTORY_INFORMATION structure for each file.
FileFullDirectoryInformation Return a FILE_FULL_DIR_INFORMATION structure for each file.
FileIdBothDirectoryInformation Return a FILE_ID_BOTH_DIR_INFORMATION structure for each file.
FileIdFullDirectoryInformation Return a FILE_ID_FULL_DIR_INFORMATION structure for each file.
FileNamesInformation Return a FILE_NAMES_INFORMATION structure for each file.
FileObjectIdInformation Return a FILE_OBJECTID_INFORMATION structure for each file. This information class is valid only for NTFS volumes on Microsoft Windows 2000 and later.
FileReparsePointInformation Return a single FILE_REPARSE_POINT_INFORMATION structure for the directory.
More information here:
http://msdn2.microsoft.com/en-us/library/ms801001.aspx[^]
If you look at the declaration of each struct you will see they all contain a field named:
ULONG NextEntryOffset;
So essentially in your ZwQueryDirectoryFile hook if the FileInformationClass was 'FileFullDirectoryInformation' you would simply need to allocate a new FILE_FULL_DIR_INFORMATION struct and then walk the existing linked list. Once you have reached the end you could simply set the NextEntryOffset to the address of your newly allocated and populated struct.
gn0tto wrote: What i also didnt get is: if a folder is requested, how and when does windows enumerate the files under the folder?
if you wish to implement a filter driver you will need to implement:
pYourDriver->MajorFunction[IRP_MJ_DIRECTORY_CONTROL]=YourFilterDirectoryControl;
And within your control function you will need to set the I/O completion routine with IoSetCompletionRoutineEx. Thats where you can filter the FILE_INFORMATION_CLASS determined return values.
http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/NT%20Objects/File/FILE_INFORMATION_CLASS.html[^]
gn0tto wrote: My approach for the "virtual elements" would be to set a filter, which detects when folder "A" wants to enumerate its children and just adds one that isnt actually there but i cant perceive how to hook into this request.
Hooking ZwQueryDirectoryFile is a much easier approach if this was the only goal. The filter driver requires much more knowledge of driver implementation and internals.
gn0tto wrote: I think that this could give me the possibility not even to have a virtual drive in the windows explorer but to have it actually inside my file system, so i can approch elements beneath it by file-paths. All in all it seems to be more powerful than the extension and i want to estimate if this desired benefit justifies the additional expenses that i expect in development
Interesting idea... however it sounds to me like you want to take a hammer and smash a square block of wood into a round hole. Rather than implmenting a filter driver for an existing disk. What you are describing would be better implemented as a virtual disk driver.
You should begin by downloading the Microsoft IFS Kit.
http://www.microsoft.com/whdc/DevTools/IFSKit/default.mspx[^]
Good Luck,
-David Delaune
|
|
|
|
|
You're not supposed to hook kernel APIs, doing so has a strong risk of affecting system stability, and these APIs are subject to change without notice, leading to probable incompatibility with future service packs and operating systems.
File system filter drivers are the only supported way of doing this.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Yes, you are of course correct.
Neither proposal should be used in a commercial product. He should also not add non-existing objects to the return buffer within a filter driver. Filter drivers are generally there to filter-out, I have never seen or heard of an implementation which added.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi again,
at first i want to thank you for participating in that discussion. I think you are both right and it might be daring to try to do this by a filter driver. I have already thought so too, before even knowing anything about this stuff. Now that i have had at least a few days to get an overview, i still wonder if it is possible at all, though.
From my current understanding there is a request in IRP form, that gets passed across the highest filter driver down to the lowest device driver and back. So when i open a folder in windows-explorer for example, the request goes down, then a file system driver recognizes the request to be for a folder and THEN initiates requests for the underlying elements, which subsequently again get passed down the whole driver stack and back. Am i right with this?
If this was so, there wouldn't be any possibility for me to get in between the enumeration within the higher level filter, so i wouldn't even be able to expand the enumeration but only to filter (which explained the name ) out elements i don't want.
As you said, Randor, i could hook into ZwQueryDirectoryFile somehow, which i think, is also the routine that gets called from the low-level file system driver to enumerate the contents of a folder. Is that correct? (Just for my understanding. I think, you're both right that this would be too careless to actually do, so i dont even consider that being a possible solution)
The idea of a virtual disk driver sounds pretty interesting for my case. I guess ill get an overview about that, even though this sounds disgustingly like "writing your own file system driver" which might take a little bit of time to learn.
Thanks again for any comment on this topic
|
|
|
|
|
Thinking about it, you could take a leaf out of the Hierarchical Storage Manager's book and implement your own namespace under your own driver in the Object Manager. Then, you place a reparse point in the file system which causes the file system to return a REPARSE status code to the Object Manager, with the name of your driver object (IIRC). The object manager then passes the remainder of the path to your driver object in IRP_MJ_CREATE (I think).
Please take what I say with a pinch of salt as I'm an application developer who has a passing interest in kernel matters. I read about the reparse mechanism in "Windows Internals, 4th Edition".
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
I am posting this on the device driver forum because I think that this a Windows internal question and this about as a close of an area that I am going get
In Windows 32 bit were pointers are 32 bits there can conceptually be 2 process with the same address pointer e.g.
NorePad and outlook can both reference an address/pointer 12345678 and Windows/The OS would know to which process this pointer/address belongs
I was just wondering how this done is there some kind of selector/register (for lack of a better term) which qualfies an address/pointer
thankx
|
|
|
|
|
ForNow wrote: I was just wondering how this done is there some kind of selector/register (for lack of a better term) which qualfies an address/pointer
In the sense that you mean, given your questions in the other forum, the answer is NO.
In general terms, the OS internally maintains a set of page table mappings for each process that translate from the process's virtual address space to an actual physical address space. When a given process is scheduled for execution, the "current" page table pointers are adjusted to reference the page tables for that process. A virtual address goes in and a physical address comes out.
All the gory details (are there are lots of them!) can be found in Microsoft Windows Internals, 4th edition by Russinovich and Solomon
Judy
|
|
|
|