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 <chmorgan@xxxxxxxxx>:
>
> Missing ftdi.h include line?
>
> Chris
>
>
> On Wed, Nov 30, 2016 at 11:42 AM, Oliver Rademaker
> <oli.rademaker@xxxxxxxxx> 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 libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
>
signature.asc
Description: Message signed with OpenPGP using GPGMail
|