LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-03-2016, 06:03 AM   #1
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Rep: Reputation: 8
Read status of FT245RL pins


Sorry for my ignorance but I am very new in FTDI chip Linux software development.
I have module based on FT245RL chip, programmed to be 4 port output (relays) and 4 port opto isolated input unit.
I found out in Internet program in C to turn on/off relays connected to outputs D0 to D3. After compiling it works properly. Below draft of this working program:

Code:
/* switch4.c
 * # gcc -o switch4 switch4.c -L. -lftd2xx -Wl,-rpath,/usr/local/lib
 * Usage
 * # switch4 [0-15], for example # switch4 1
 * */
    #include <stdio.h>
    #include <stdlib.h>
    #include "./ftd2xx.h"

    int main(int argc, char *argv[])
    {
       FT_STATUS ftStatus;
       FT_HANDLE ftHandle0;
       int parametr;
       LPVOID pkod;
       DWORD   nBufferSize = 0x0001;
       DWORD dwBytesWritten;

              if(argc > 1) {
                      sscanf(argv[1], "%d", śmetr);
              }
              else {
                      parametr = 0;
              }  

         FT_SetVIDPID(0x5555,0x0001);  // id from lsusb
         FT_Open(0,&ftHandle0);
         FT_SetBitMode(ftHandle0,15,1);

         pkod=&parametr;

        ftStatus = FT_Write(ftHandle0,pkod,nBufferSize,&dwBytesWritten);
        ftStatus = FT_Close(ftHandle0);
    }
My question is. How can I read in the same program, status of D4 to D7 pins, programmed as inputs? I mean about "printf" to stdout the number representing status (zero or one) of input pins (or all input/output pins).
Can anybody help newbie ?
 
Old 09-08-2016, 11:50 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Zero experience with this chip, however have done similar stuff with other peripherals in the past and typically a function such as FT_Write() has a concurrent FT_Read(). I see that the ftd2xx.h file does contain a read function. I can't tell in your program how you addresses D0 through D3, except for the parameter. Therefore I would try using FT_Read() and see if I could specify the D4 through D7 bits using that function.
 
Old 09-08-2016, 01:03 PM   #3
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Finally I found out whats going wrong. The problem was the version od ftdi library. Correct and actual version dedicated for x86_64 platform is HERE

Last edited by mackowiakp; 09-08-2016 at 01:06 PM.
 
  


Reply

Tags
ftdi_sio, inputoutput, programing, usb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SD card change to read only status jonbvgood Linux - Hardware 3 10-12-2010 12:03 PM
can i use I/o Port pins of a processor as four SPI pins? i sunr2007 Linux - Embedded & Single-board computer 3 08-20-2009 01:23 AM
My USB-HD keep getting in read-only status xpucto Linux - Newbie 1 01-10-2008 03:49 AM
Can not read status from my network printer lproehl Linux - Networking 0 08-12-2007 02:53 PM
Unable to read battery status jayhel Linux - Laptop and Netbook 2 12-11-2005 08:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration