Shop OBEX P1 Docs P2 Docs Learn Events
Forcing the Parallax Serial/USB adapter to a particular COM port number — Parallax Forums

Forcing the Parallax Serial/USB adapter to a particular COM port number

davejamesdavejames Posts: 4,047
edited 2008-11-29 02:13 in General Discussion
Hi All,

Has anyone attempted to force the Serial/USB adapter to a particular COM port number ala the FTDI application note:

"Configuring FTDI's VCP Drivers to use Location IDs (AN232B-07)"

I've emailed FTDI but have had no response.

Thanks,

DJ

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-18 22:28
    Yes, and it's a royal pain. It's easier just to use the Windows Device Manager and force a reassignment. That is, unless you're in a situation where you're testing hundreds of products that use FTDI's chips. In that case you either have to do the Location ID tango or use FTDI's MPROG program to make all the chips' serial numbers the same.

    I wish you luck.

    -Phil
  • davejamesdavejames Posts: 4,047
    edited 2008-11-18 22:51
    Phil,

    A bit 'o the why:· I have a "BS2-product" that requires input from the user.· The user will provide this info from a dialog box running on a PC.· The product communicates via USB using the FTDI Serial/USB converter chip.· This FTDI chip creates a 'virtual com port' (VCP) so I would never know which COM port is being assigned, and I seem to have the need to know which COM port is in use when opening a COM port on the PC·(did that make sense?).· I'm writing the dialog box in Visual C++ and the 'CreateFile" command used to setup the COM port requires a unique COM port number.· So, hence the problem.· My solution was to alter the '.inf' file that the FTDI chip uses upon startup and hard code the COM port to a high port number (99) so it wouldn't clash with other COM port usage.

    Pray tell...what's the 'royal pain' you've experienced?· Is changing the locids item in the .inf not the only thing one would have to do?

    Thanks,

    DJ
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-18 23:05
    davejames said...
    Is changing the locids item in the .inf not the only thing one would have to do?
    No, unfortunately not. IIRC, there were some registry changes to make as well. You also have to use a Microsoft-supplied program to get information from the USB ports to provide to the .inf file, making it impossible to script the whole process.

    In your case, though, I'd skip all that rigamarole and use the stampw.exe program to interrogate the available serial ports for a working BASIC Stamp. This you should be able to do from your C++ program, since stampw has a command line interface, in addition to being a GUI. Then just open whichever port it reports back with.

    -Phil
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-11-19 00:08
    Note that changing the information in the INF file will also cause the signature to be invalid. What happens then is that the person installing the drivers is presented with a dialogue box that informs them that the drivers were not digitally signed and asks if they wish to proceed or cancel.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • davejamesdavejames Posts: 4,047
    edited 2008-11-19 00:19
    ...hmmm, I'm starting (just ever-so-slightly) to get the idea that I'm headed down the wrong path.· That's ok.· If there's a better way I'm all for it.

    OK - so what do you do, then, if you're attempting to set up communication between a PC and a BS2 using the Serial/USB adapter?· If I need to know what COM port the FTDI has chosen, how do I detect that so I might set the C++ CreateFile statement correctly?

    Phil - you mentioned stampw.exe.· What's that?· I just finished perusing the Parallax site and couldn't locate any info on it.

    Mr. Savage - thanks for the warning.

    DJ
    ·
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-19 02:27
    Stampw.exe is the BASIC Stamp editor/compiler/loader. You already have it on your computer. The command line interface is described in the BASIC Stamp Syntax and Reference Manual (PDF).

    -Phil
  • davejamesdavejames Posts: 4,047
    edited 2008-11-19 06:15
    Found it...wow, this just keeps getting deeper and deeper.

    I suppose I could invoke stampw.exe via the C++ ShellExecute() command, detect the current BS2 com port, and then use that port to write data to the BS2 via CreateFile().

    I guess...?

    Thanks very much for the input.· I need to go away and think about this.

    DJ
    ·
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-19 06:29
    That's how I use it from Perl. Just remember to prepend \\.\ to the returned port name, in case it's bigger than COM9.

    -Phil
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-11-19 06:35
    Gents -

    Perhaps I don't understand piping as well as I should, but where in the documentation mentioned does STAMPW send anything back to the invoker?

    TIA

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-19 06:45
    Bruce,

    The invoker must be able to capture STDOUT, which is something most scriptable shell commands can do. At least that's the way it works for me. Even if STDOUT can't be captured directly, it can be piped to a temporary file for subsequent reading.

    -Phil
  • davejamesdavejames Posts: 4,047
    edited 2008-11-19 07:07
    ....errrrrr, but then·I would wind up having my C++ interface code execute stampw.exe with it's output redirected to a file, then the interface code would open the file, read the in-use COM port, and then use that number as its target port?

    In my bones, I know there must be a more straightforward approach.

    Now you see why I thought about forcing the FTDI chip to a particular port.

    What're you guys doing up so late anyway?

    DJ
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-19 07:25
    Trust me. That's a whole lot easier and more portable than messing with the FTDI stuff! You simply can't script the Location ID method. Each user would have to run USBView to get the location IDs for his particular machine and hand transcribe them to the .inf file, before installing the driver.

    -Phil
  • davejamesdavejames Posts: 4,047
    edited 2008-11-19 16:20
    OK - so, then, what method does the Stamp Editor use to detect which port a BS2 might be using?

    When I press the 'identify' button in the Stamp Editor, there's a bit of delay, the LEDs on the Serial/USB adapter flash, and then the info is displayed.· Obviously there is some sort of interrogatoin occuring.· It's that particular process in which I'm intrigued.

    If there are any Parallax apps people monitoring this thread, can you tell me what process is used to detect the USB port an FTDI chip uses on start-up?

    As always - much thanks.

    DJ
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-19 18:45
    DJ,

    The Stamp Editor doesn't know anything about USB ports — only serial ports, since that's how a properly-installed USB-to-serial adapter is registered. The Editor polls all the available non-occupied serial ports for a Stamp by sending a reset, followed by an ID request. Parallax used to publish the protocol details for this, IIRC, but I can't find it on their website anymore.

    -Phil

    Addendum: Have you looked at the docs in the "Developer" subdirectory to the Stampw program folder? Everything you need for communicating with Stampw is detailed there, including a /PIPE option I wasn't aware of. It renders the necessity for deep knowledge of the ID protocol unnecessary, IMO.

    Post Edited (Phil Pilgrim (PhiPi)) : 11/19/2008 6:56:18 PM GMT
  • davejamesdavejames Posts: 4,047
    edited 2008-11-19 18:51
    Phil,

    Ok - that's some insight as to the process.· Now I guess I have to pin down Parallax as to the particulars.

    So unless anyone reading this has "the particluars", I'm going to call this thread closed and go pester Parallax directly.

    Thanks to all for the involvement,

    DJ
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-19 18:54
    DJ,

    See my addendum above.

    -P.
  • davejamesdavejames Posts: 4,047
    edited 2008-11-19 19:05
    Phil - found it.· The attached document is packed into the zip file available in:

    ······· http://www.parallax.com/tabid/441/Default.aspx

    under:

    ······ BASIC Stamp Tokenizer Version: 1.16



    Time go read some more!

    Later,

    DJ
  • davejamesdavejames Posts: 4,047
    edited 2008-11-19 19:07
    ...oops!··I was posting while you were updating...

    OK - thanks again.· I'll go dig through and read those too.

    Later,

    DJ
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-11-28 01:45
    Hi Dave, I have a couple of routines from small projects I have been toying around with, more out of curiosity than anything practical.

    I had time to sit down today and string them together in a simple VB app, my comfort level with C++ is pretty low so I didn't try to convert it over but possibly you are able to do that.

    The attached doc is an Open Office document saved as an MS Office 6 document and contains the complete code for polling the available serial ports for a BS2. Although it will identify all ports it is unable to access a port that is in use.

    The way in which it works is guided by Parallax's Tokenizer documentation, this is also my main reason for posting the code, if you are creating your routines with reference to the Tokenizer docs it is possible you will come across an error in the reset sequence, the attached file has the error corrected.

    Jeff T.
  • davejamesdavejames Posts: 4,047
    edited 2008-11-29 02:13
    Hi Jeff,

    Thanks for the info.

    What I've found in the last week is that Microsoft Visual Studio 2005 C++ has been expanded with a new class specific to dealing with COM port issues. I've been using VS 6.0 C++ for the last 10 years which doesn't. I guess there's a lesson to be learned here concerning staying aware of a product's updates.

    The VS 2005 C++ code samples I've recently seen look similar to your VB app.

    I'll be bitin' the bullet and purchasing VS 2005 here in the next couple weeks for home use. I found out that I have acess to it at work so I have something to play with immediately.

    Thanks again and I trust you had a happy Thanksgiving Day (if you're in the states, that is...).

    Dave
Sign In or Register to comment.