Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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

by kschwab (Priest)
on Jan 16, 2014 at 14:18 UTC ( #1070804=note: print w/replies, xml ) Need Help??

in reply to Re^4: Problem Writing to FTDI COM Port using Win32::FTDI::FTD2XX
in thread Problem Writing to FTDI COM Port using Win32::FTDI::FTD2XX

<quote>Thinking about it, how are the two outputs (two DB9 com ports) represented on the one chip?</quote> It's an object, so it can keep the "previously selected output" in the internal state of the object. So, you do a OpenBySerial or OpenByIndex, and the calls to methods like SetBitMode operate on the port that was last opened. The docs for the perl module seem wrong with respect to SetBitMode. It wants a mask and mode. Within the source code are some constants for the mode:
# Get/Set BitMode use constant PFT_BITMODE_RESET => 0x00; use constant PFT_BITMODE_ASYNCBB => 0x01; use constant PFT_BITMODE_MPSSE => 0x02; use constant PFT_BITMODE_SYNCBB => 0x04; use constant PFT_BITMODE_MHBEM => 0x08; use constant PFT_BITMODE_FOISM => 0x10; use constant PFT_BITMODE_CBUSBB => 0x20;
The mask is telling it which pins are input and which are output. A 0 bit is an input, a 1 is an output. The lowest bit is D0 (TXD), next is D1 (RXD), and so forth. Google "FTDI2XX mask mode bitbang" and you'll find the whole mapping. So, to set all lines/outputs to output in async bitbang:
# # assuming you called OpenByIndex on this object already # $mode = $FTDIdev->SetBitMode(0xFF, 0x01);

Replies are listed 'Best First'.
Re^6: Problem Writing to FTDI COM Port using Win32::FTDI::FTD2XX
by PrfrrdUsrNm (Initiate) on Jan 17, 2014 at 03:27 UTC
    $FTDIdev->OpenDevByIndex(1); my $x = $FTDIdev->SetBitMode(0xFF, 0x01); print "$x"; #$x prints 1 my $mode = $FTDIdev->GetBitMode() || die "unable to get mode"; #fails here #GetBitMode(0x01) also fails

    The program now dies at GetBitMode.

      What's "OpenDevByIndex" ? Typo? I don't see any such method. Assuming it's a typo, does $FTDIdev->OpenByIndex(1) return 1? Did you try turning on PFT_DEBUG?

        Sorry typo, was correct in code.

        Found a way to use the rts lines, simplifies the solution to a single port.

        Thanks for the help.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2018-09-18 23:52 GMT
Find Nodes?
    Voting Booth?
    Eventually, "covfefe" will come to mean:

    Results (163 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!