Results 1 to 26 of 26

Thread: modems - serial communication

  1. #1

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266

    modems - serial communication

    okay... anyone know if the .NET framework supplies any namespaces and classes that provide an easier way of enumerating modem devices into a list, and communicate with a remote server using serial communication, instead of me having to use TAPI and all sorts of goofy platform SDK stuff?
    jovton

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    There's nothing in VB .NET to support serial communications.

    MS has a sample application on MSDN, where they create a class that uses API. That class can easily be customized and used.
    Try searching there.

    Also, if you download and install VB .NET Resource Kit, you actually get a free RS232 control from SAX.

    All you need to do, to download the resource kit is to register your version of VB. (All versions, incl. Standard)
    Follow this link : http://msdn.microsoft.com/vbasic/vbrkit/

    There is also a lot of other controls. You actually get controls worth 10 times more than VB .NET Standard itself.

    Hope this is of any help to you.

    Good luck.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Thanks.

    Hmmmm, yes, communicating via the serial port won't be a problem I guess. This resource kit is huge. Takes a long time to download with my little 56k modem. heh.

    I actually need to list the modems installed, and also detect which port they're connected to. I see rasapi32.dll has many to offer, but I can't seem to find a way in it, that can show me which port the modem is connected to. All this nifty configuration settings must be stored in the registry somewhere. And if it is, it must be a standardized location, though different for each OS version (9x, ME, NT4, 2K, XP, etc.)

    YELP!
    Last edited by jovton; Jan 2nd, 2004 at 04:31 PM.
    jovton

  4. #4
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    You are right that it must be somewhere in the registry.
    I don't know where though.

    But if you have a modem installed, you could use the regedit to search for the modem name. Then you should find where modems are registered. Even better if you have more than one modem installed. Then you should be able to figure out the structure of the registry settings.

    I did a similar search on a project where I needed to figure out which comm.ports where installed, so my user would be able to select between all available comm.ports

    Hope this helps.
    Good luck.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  5. #5
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    The information you need may be found at some places in the registry including HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class

    Each class (Default) value represents the type of devices under that class, for example
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96E-E325-11CE-BFC1-08002BE10318}
    represents Monitors in my machine. Ofcourse this is XP, I don't know about others, but should be more or less the same.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  6. #6
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    I can't take credit for this, as I asked someone how to enumerate the modems - give some guy name Ken a thanks Thanks Ken.

    You will need to add a reference to System.Management.dll

    VB Code:
    1. Dim moReturn As Management.ManagementObjectCollection
    2.         Dim moSearch As Management.ManagementObjectSearcher
    3.         Dim mo As Management.ManagementObject
    4.  
    5.         moSearch = New Management.ManagementObjectSearcher("Select * from Win32_POTSModem")
    6.         moReturn = moSearch.Get
    7.  
    8.         For Each mo In moReturn
    9.             Debug.WriteLine(mo("Name") & " is attached to " & mo("AttachedTo"))
    10.         Next

    Check out all the members of Win32_POTSModem WMI class - wow.

  7. #7
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Thanks Mike and Ken.

    But this WMI class is not available in Win98 and ME.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  8. #8
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Yeah, I see that now. Shoot, I still have clients on 95 (not .NET). Gotta hate that.

    I guess you could force them to upgrade or I can ask Ken again. I'm not smart enough to figure it out myself.

  9. #9

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Nevertheless, it's a plus!

    Thanks Ken and Mike. I can detect the OS version with ease, and use the appropriate method. This one method will probably work for Win 2K, XP and up. Now we have to find the other one.

    There is one other problem I just realized that I will have... I can't just assume that a user's modem will be connected via a COM port. What about those that use USB modems. Will I still be able to use serial communication? From what I've heard, USB uses "serial" transmission, but I guess it differs a bit from RS232. It looks in the end like I will have use the "goofy" stuff.
    Last edited by jovton; Jan 3rd, 2004 at 05:23 AM.
    jovton

  10. #10

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    I think I found a very helpful link.

    http://www.codeproject.com/internet/...asandmodem.asp

    It seems that the key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Modem does hold the one important key to the answers of our prayers.

    Stay tuned... The very last problem would be detecting the ports the modems are connected to.
    Last edited by jovton; Jan 3rd, 2004 at 11:49 PM.
    jovton

  11. #11

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    As in the article link posted earlier, it seems that the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96D-E325-11CE-BFC1-08002BE10318} IS exactly the location that the WMI class exploits when enumerating modem devices into a list in Win32 NT based systems (NT4, 2K, XP, Server 2003).

    I don't have Windows 98 or ME. Can anyone with Win 98 or Win ME please tell me what values they can find under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Modem\0000? Is there any value like "AttachedTo"?

    Thanks.
    Last edited by jovton; Jan 3rd, 2004 at 11:52 PM.
    jovton

  12. #12

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Anyone? Someone must have Windows 98 or ME (with a registry editor installed )
    jovton

  13. #13
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    This is from a 98 machine. Didn't see an "AttachedTo"
    Attached Files Attached Files

  14. #14

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Thank you Mike.

    There may be no "AttachedTo" property, but I found two other interesting properties. PortSubClass and PortDriver. These two tell a lot.

    PortSubClass is in Hex format and it says 0x02. This is probably the COM port number, and not the port address.

    I've got a lot of learning to do before I can figure out how to use that PortDriver to to nifty things.
    jovton

  15. #15

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Wait ... I may be wrong about that PortSubClass. The same entry exists on Win32 NT systems. If this value is used on them, then why would they need two values for the same purpose? This value must be something else then.

    However... If this value IS used to indicate the port number, then 0x02 probably indicates... COM3? 0x00 for COM1, 0x01 for COM2, etc. Or maybe it IS the port address? Highly unlikely. Or maybe the port address in the "subclass"?

    In the event that this value is used to indicate the port number, I can test if it is serial by studying at the PortDriver entry. Perhaps, the modem configuration settings are always expressed in serial comm port expressions, except for the driver. And if the modem uses the USB port, then the OS might "bridge" these two differences by using some sort of "redirection" or something, if you know what I mean.

    These are just questions and possibilities raised in my mind, because I don't know exactly how these things work. If anyone out there has the answers, wouldst thou care to lend a hand ??

    Thanks.
    jovton

  16. #16

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    I must be still asleep. PortSubClass indicated the type of port. Silly me.
    00 = Parallel, 01 = Serial, 02 = Modem.

    Hmmmm, Modem? Hmmmmm.
    Last edited by jovton; Jan 5th, 2004 at 02:08 AM.
    jovton

  17. #17

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    That "Properties" value must have the answer. I KNOW IT !!
    jovton

  18. #18

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Perhaps the modem's port setting is stored in the driver's ini config file on Win 98 / ME ...
    jovton

  19. #19
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    jovton,

    Are you "delimiter" on microsoft.public.dotnet.language.vb? If not, then someone is asking the same questions you are

  20. #20

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Originally posted by Mike Hildner
    jovton, are you "delimiter" on microsoft.public.dotnet.language.vb? If not, then someone is asking the same questions you are
    Like... wanting to find the registry entries for modem port on 98, and c# or vb.net code is most welcome... and something like... someone feels sorry for me, and has the same problem, thinking its pretty poor... and had a previous newsgroup post, something about www.sealevel.com, and something about an internal network with site called www.ionetworks.com, and something about a one handed man and a ken tucker?
    jovton

  21. #21
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Booted up that 98 machine again and started to look at the registry settings. I saw "DCB" and that stirred up old memories, but alas, as interesting it is, it has nothing to do with your port (AFAICT).

    The system actually opens up a "file" when you open a com port, which needs your DBC struct and a file name - e.g. COM1. Made me think it must be stored elsewhere.

    Now I'll get to the point. My "InfPath" name in the registry has as it's data "3COM3C~1.INF". My modem is on COM5. Open up this file and the only instance of COM5 I see says:

    HKLM,System\CurrentControlSet\Control\ComAlias,COM3,,COM5

    So, I open up that and it says that name "COM3" has data of "COM5".

    I think we're getting close

  22. #22

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Hmmm, well... I have a Lucent Win Modem. But, my modem .inf file "mdmlt3.inf" contains absolutley nothing about any ports, and my modem is connected to COM3. *sigh*
    jovton

  23. #23
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Dang, that's too bad, thought we had something there. Wonder if there are any Win 98 groups around - probably starting to get off topic for VB.NET now. I know there are some Win 2000 groups out there - someone's gotta know how this is done.

  24. #24

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Guess what... I succeeded, where it involves "serial port" based modems, and that includes internal modems. I still have to figure out USB stuff though.

    And don't worry about going off topic. I'm developing a .NET class now for this. Let me try to explain how I figured this out.

    Okay... first things first: To absolutely make sure that our chances are good at finding modems, we must install WMI 1.5 or later on all 98 and NT4 computers (I heard ME already has it), and also install any other .NET prerequisites, then .NET framework (duh.... ). Okay, with that said, let's begin.


    I figured that external COM port connected modems, also exports a registry entry named: "AttachedTo". If this value is missing... then we have two options... Assume this is an internal modem, or, check to see if it is internal, and if not, then this modem is installed, but were not detected at startup, and is therefore either disconnected from the port, or powered off. Plainly said: The modem is not present at present . Right....

    All modems under HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Class\\Modem export a "MatchingDeviceID" setting. With this info, we can go and look for additional settings on this device.

    All we do now, is, check HKEY_LOCAL_MACHINE\\Enum\\PCI and HKEY_LOCAL_MACHINE\\Enum\\ISAPNP for ID's containing the MatchingDeviceID, and that includes subkeys and values. When a key is found, look for a value called "PORTNAME". And there you have it !!

    The amount of explaining I need to do is too much. What I'll do is, I will attach my partly developed class here. If you get any ideas, or wish to help out, we'll all be most greatful.

    P.S. Please excuse my coding style. I was a bit lazy and hasty.

    Class usage:
    VB Code:
    1. Dim myME As New ModemEnumerator
    2.  
    3. If myME.Modems.Count > 0 Then
    4.     Dim mt As Integer
    5.     For mt = 0 To (myME.Modems.Count - 1)
    6.         ComboBox1.Items.Add(myME.Modems.Item(mt).Name)
    7.     Next mt
    8. End If

    Stay tuned.
    Attached Files Attached Files
    Last edited by jovton; Jan 7th, 2004 at 07:11 AM.
    jovton

  25. #25
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Hope I don't double post here, little glitch the first time.

    I don't have access to any USB modems, so can't help there. Wish I had thought of this before, but maybe a tool like regmon from Sysinternals might help. I've used it in the past, wish I had thought about it before pouring over the registry.

    Anyway, Sysinternals has some really cool, free stuff.

    And, I must say, I think what you're doing is very cool. I'm amazed at how .NET allows one to build (just about?) anything that is not built in. Kudos to you, friend, rock on.

  26. #26

    Thread Starter
    Hyperactive Member jovton's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    266
    Alright, here's the beta version, if I may call it that. I also updated the previous post's attachment.

    It works a little different now. Now the class does not assume that the modem is internal, when it cannot find the "AttachedTo" property. It now looks for a port setting in both registry locations.

    The reason USB bothers me is because of daisy chaining and serial communication. This class might even enumerate USB modems, but they apply "ports" differently than COM port modems, so it might incorrectly return "<Modem Not Present>" when it enumerates USB modems.

    Can I ask someone with an ISA or USB modem to test this for me please? I only have an PCI and External modem on the COM port.

    Here is the updated class.
    Attached Files Attached Files
    Last edited by jovton; Jan 7th, 2004 at 10:04 AM.
    jovton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width