CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2014

    Two PIC micros over two FTDI UM232R modules to PC.

    Any idea about this.
    I have two EasyPIC development boards with pic micros on them attached to PC by two UM232R modules. They boot up properly and had connected to their respective COM ports. When I put two serial ports on a form and manually assign COM ports to them everything works fine.
    But, I do not want to do it manually. I want my application to find the ports (which my code does: find the COM ports, serial numbers and device types), create serial ports and then assign them to desired COM ports.
    And my application even does that.
    The problem is in that when I try to open COM ports I have message "... access denied..." because the com ports are (probably) already open by FT modules.
    I tried to open another two threads and to create COM ports in them but the "... access denied..." - again.
    Than I made another approach: I am not creating serial ports on a form and write directly to FT device but the result is that what ever I do (usually open FT modules by serial number) my write is always going to last device on list.
    What to do to "force" the application to separate modules and to allow me to independently work with them.
    My code has a lot of comments and at a time I am not posting it here - just waiting for ideas. When we resolve the problem - the whole code with comments in English will be posted!
    Thanks in advance.

  2. #2
    Join Date
    Apr 2000
    Belgium (Europe)

    Re: Two PIC micros over two FTDI UM232R modules to PC.

    Only one process can open a COMx port at a time. When you're done you should properly close the handle.

    Because of the nature of how COM ports work, it is not usually a smart idea to try and do autodetection unless you can be 100% sure that no "unexpected" devices can possibly be connected to the COM ports (which you can typically only get if you are desinging or "hard" restricting the hardware).

    Suppose someone attached something as simple as a printer on COM1.
    Every time your autodetect fires, it could result in the printer spitting out a sheet of paper (or worse).

    it may be more doable if you work via the USB enumeration and detect via USB which ones have a PIC then retrive the associated COM port number to do the actual communication. I don't know EasyPIC so I can't tell if this is even feasible for that PIC. I have used others where it was possible to safely detect over USB.

  3. #3
    Join Date
    Nov 2003

    Re: Two PIC micros over two FTDI UM232R modules to PC.

    One approach I can think of is to use the Setup API to find all the UM232R instances (by HW/PNP ID), then find the virtual COM port # those devices are linked to. May be able to do this with WMI as well.

    Or just have the UI allow the user to configure the COM ports to use and leave it at that.


Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.