lifted - wait until write is completed

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

lifted - wait until write is completed

Oliver Rademaker
Hello,

I try to write some (DMX) data to my FTDI Device. But if I got right the ftdi_write_data method do not wait, right? So I tried to use fetid_write_data_submit, but when I do the compilation I get error that the method is not declared in this scope:

‘ftdi_write_data_submit’ was not declared in this scope
  ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset, 1));
                                                                            ^
dmxbridger.cpp:62:77: error: ‘ftdi_transfer_data_done’ was not declared in this scope
  ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset, 1));





Complete Code are:

//Reset line
ftdi_set_baudrate(this->pFtdi, 96000);
ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset, 1));

//Send data
ftdi_set_baudrate(this->pFtdi, 250000);
ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->buffer, 512));

Has Anyone an Idea?

BR, Oliver



signature.asc (507 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: lifted - wait until write is completed

Chris Morgan
Missing ftdi.h include line?

Chris


On Wed, Nov 30, 2016 at 11:42 AM, Oliver Rademaker
<[hidden email]> wrote:

> Hello,
>
> I try to write some (DMX) data to my FTDI Device. But if I got right the
> ftdi_write_data method do not wait, right? So I tried to use
> fetid_write_data_submit, but when I do the compilation I get error that the
> method is not declared in this scope:
>
> ‘ftdi_write_data_submit’ was not declared in this scope
>   ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset,
> 1));
>
> ^
> dmxbridger.cpp:62:77: error: ‘ftdi_transfer_data_done’ was not declared in
> this scope
>   ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset,
> 1));
>
>
>
>
>
> Complete Code are:
>
> //Reset line
> ftdi_set_baudrate(this->pFtdi, 96000);
> ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset,
> 1));
>
> //Send data
> ftdi_set_baudrate(this->pFtdi, 250000);
> ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->buffer,
> 512));
>
> Has Anyone an Idea?
>
> BR, Oliver
>
>

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: lifted - wait until write is completed

Oliver Rademaker
No, ftdi.h is included. The other methods are working. The method ftdi_write_data instead is working. That’s my complete code for now:

#include <iostream>
#include <stdio.h>
#include <ftdi.h>
#include <unistd.h>

using namespace std;

class Dmxbridge {
public:
        Dmxbridge();
        int open();
        int send(unsigned char data[]);
        int find_all();
private:
        struct ftdi_context *pFtdi;
        unsigned char buffer[512];
        unsigned char reset[1];
        struct ftdi_transfer_control *transfer_control;
};

Dmxbridge::Dmxbridge(void) {
        this->reset[0] = 0x00;

        if ((this->pFtdi = ftdi_new()) == false) {
                fprintf(stderr, "ftdi_new context FAILURE\n");
        } else {
                fprintf(stderr, "ftdi_new context SUCCESS\n");
        }
}

int Dmxbridge::open() {
        cout << "Try to open usb ... \n";
        int ret = EXIT_SUCCESS;

        ret = ftdi_usb_open(this->pFtdi, 0x0403, 0x6001);

        if(ret < 0) {
                fprintf(stderr, "USB open FAILURE: %s (%s)\n", ret, ftdi_get_error_string(this->pFtdi));
        } else {
                fprintf(stderr, "USB open SUCCESS: %s (%s)\n", ret, ftdi_get_error_string(this->pFtdi));
        }

        ftdi_set_line_property(this->pFtdi, BITS_8, STOP_BIT_2, NONE);

        return ret;
}

int Dmxbridge::send(unsigned char data[]) {
        //this->buffer[2] = 0xFF;
        //this->buffer[9] = 0xFF;
        //this->buffer[11] = 0xFF;

        //Reset line
        ftdi_set_baudrate(this->pFtdi, 96000);
        ftdi_write_data(this->pFtdi, this->reset, 1);
        //ftdi_write_data_submit(this->pFtdi, this->reset, 1);
        //ftdi_transfer_data_done();

        //Send data
        ftdi_set_baudrate(this->pFtdi, 250000);
        ftdi_write_data(this->pFtdi, data, 512);
        //ftdi_write_data_submit(this->pFtdi, this->buffer, 512);
        //ftdi_transfer_data_done();

        return 0;
}

int Dmxbridge::find_all() {

}

int main() {
        int ret = EXIT_SUCCESS;

        Dmxbridge * db = new Dmxbridge;

        if((ret = db->open()) < 0) {
                delete db;
                return ret;
        }

        unsigned char data[512];

        for(int i = 0; i < 255; i++) {
                data[10] = 0xFF;
                data[12] = 0xFF - i;

                if(( ret = db->send(data)) < 0) {
                        delete db;
                        return ret;
                }

                usleep(20000);
        }

        delete db;

        cout << "Finished! :-)\n";

        return ret;
}

> Am 30.11.2016 um 18:03 schrieb Chris Morgan <[hidden email]>:
>
> Missing ftdi.h include line?
>
> Chris
>
>
> On Wed, Nov 30, 2016 at 11:42 AM, Oliver Rademaker
> <[hidden email]> wrote:
>> Hello,
>>
>> I try to write some (DMX) data to my FTDI Device. But if I got right the
>> ftdi_write_data method do not wait, right? So I tried to use
>> fetid_write_data_submit, but when I do the compilation I get error that the
>> method is not declared in this scope:
>>
>> ‘ftdi_write_data_submit’ was not declared in this scope
>>  ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset,
>> 1));
>>
>> ^
>> dmxbridger.cpp:62:77: error: ‘ftdi_transfer_data_done’ was not declared in
>> this scope
>>  ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset,
>> 1));
>>
>>
>>
>>
>>
>> Complete Code are:
>>
>> //Reset line
>> ftdi_set_baudrate(this->pFtdi, 96000);
>> ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->reset,
>> 1));
>>
>> //Send data
>> ftdi_set_baudrate(this->pFtdi, 250000);
>> ftdi_transfer_data_done(ftdi_write_data_submit(this->pFtdi, this->buffer,
>> 512));
>>
>> Has Anyone an Idea?
>>
>> BR, Oliver
>>
>>
>
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to [hidden email]
>


signature.asc (507 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: lifted - wait until write is completed

Chris Morgan
On Wed, Nov 30, 2016 at 12:59 PM, Oliver Rademaker
<[hidden email]> wrote:
> No, ftdi.h is included. The other methods are working. The method ftdi_write_data instead is working. That’s my complete code for now:
>

Can you confirm that those functions are declared in your ftdi.h file?
For instance mine has:

   struct ftdi_transfer_control *ftdi_write_data_submit(struct
ftdi_context *ftdi, unsigned char *buf, int size);

And can you list more of the error output? Is this at link time or compile time?

Chris

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: lifted - wait until write is completed

Oliver Rademaker
Holy ….., you are right. The methods are not included in the ftdi.h on the pi.  I installed libftdi on raspbian by apt. No I checked the version and it is 0.20-2. On my desktop, where I read the fdti.h, I have the latest version from the webpage (1.3). So, I have to find out how I get the latest version to raspbian. :-/

> Am 30.11.2016 um 19:13 schrieb Chris Morgan <[hidden email]>:
>
> On Wed, Nov 30, 2016 at 12:59 PM, Oliver Rademaker
> <[hidden email]> wrote:
>> No, ftdi.h is included. The other methods are working. The method ftdi_write_data instead is working. That’s my complete code for now:
>>
>
> Can you confirm that those functions are declared in your ftdi.h file?
> For instance mine has:
>
>   struct ftdi_transfer_control *ftdi_write_data_submit(struct
> ftdi_context *ftdi, unsigned char *buf, int size);
>
> And can you list more of the error output? Is this at link time or compile time?
>
> Chris
>
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to [hidden email]
>


signature.asc (507 bytes) Download Attachment
Loading...