Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Problem Writing to FTDI COM Port using Win32::FTDI::FTD2XX

by kschwab (Priest)
on Jan 15, 2014 at 13:35 UTC ( #1070681=note: print w/replies, xml ) Need Help??

in reply to Problem Writing to FTDI COM Port using Win32::FTDI::FTD2XX

I don't see a write() call in the docs at all. I do see a Write() call, and it doesn't want the ID of the device as a parameter. You're passing $ID to other methods that don't want it as well, like GetBitMode() and SetBitMode(). I suspect you want:
And, you'll need to fix your call to SetBitMode (remove the $ID param), and check that you're sending the right params to other calls as well.

Replies are listed 'Best First'.
Re^2: Problem Writing to FTDI COM Port using Win32::FTDI::FTD2XX
by PrfrrdUsrNm (Initiate) on Jan 15, 2014 at 23:13 UTC

    Sorry, should have stripped back the code to what it was initially before i started using the FTDI Programers guide definitions. This causes an error @ SetBitMode(1); "Use of uninitialized value in subroutine entry at blib\lib\Win32\FTDI\ (autosplit into blib\lib\Win32\FTDI\FTD2XX\ line 2467.

    However, the code continues to run and it still gets stuck @
    FTDIdev->write($TrigOn, 1);

      Here's the source:
      sub SetBitMode { my $self = shift; my $mask = shift; my $mode = shift; unless( defined( $self->{_PFT_SetBitMode} ) ) { return( undef ) unless( _importDll( $self, "PFT_SetBitMode" ) ); } $self->{_PFT_STATUS} = $self->{_PFT_SetBitMode}->Call( $self->{_PFT_ +HANDLE}, $mask, $mode ); return( 0 ) if( $self->{_PFT_STATUS} ); return( 1 ); } # SetBitMode()
      It wants a mode and a mask, and if you're passing in the ID, it's interpreting that as the mask. Unless you've got an older version or something, passing in the ID may supress some error, but it's not likely doing the right thing.

        My thinking, after not having success with the CPAN definition, was to follow D2XX Programmer's Guide Version 1.3 definition and see if that worked (obviously it didn't and remained in the code, sorry about that).

        The definition in CPAN:

        SetBitMode Parameters: {$mode} Return Success: TRUE Return Failure: FALSE Purpose: API Method - See FT_SetBitMode(). Note: The following EXPORTS for BitModes are available for convenien +ce: PFT_BITMODE_RESET PFT_BITMODE_ASYNCBB PFT_BITMODE_MPSSE PFT_BITMODE_SYNCBB PFT_BITMODE_MHBEM PFT_BITMODE_FOISM PFT_BITMODE_CBUSBB

        Only asks for the $mode parameter, although I have tried this as:

        my $mode = FTDIdev->SetBitMode(0x03, 0x01); #also tried in dec with 3, + 1 print "My mode is: $mode\n";

        This changes the printed $mode to 244 (0xF4) (as opposed to 245 (0xF5), which may indicate we have eliminated one error...). But again the program gets stuck at the write stage.

        Thinking about it, how are the two outputs (two DB9 com ports) represented on the one chip? is this done with the mask? which would make require more than two bytes for masking the full 18 pins...

        This would imply that 0x03 is trying to mask/write from the port belonging to ComPort6...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1070681]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2018-08-14 15:13 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (152 votes). Check out past polls.