On 11/19/2012 11:21 AM, Garrido Xavier wrote:
Dear libftiusers,
We recently buy this device
http://www.controlanything.com/Relay/Device/UPOT8PROXR which has poor
documentation and all piece of software are done for Windows. Since we
would like to control via Ubuntu machines, I then came accros your library.
First, I have used the |simple.c| program to test USB communication
(everything got fine) and then, following the programs given in
|libftdi| examples directory, I made this piece of code
|#include<stdio.h>
#include<unistd.h>
#include<ftdi.h>
int main(int argc, char **argv)
{
struct ftdi_context ftdic;
int f, i;
unsigned char buf[3];
if (ftdi_init(&ftdic)< 0)
{
fprintf(stderr,"ftdi_init failed\n");
return EXIT_FAILURE;
}
f = ftdi_usb_open(&ftdic,0x0403,0x6001);
if (f< 0 && f != -5)
{
fprintf(stderr,"unable to open ftdi device: %d (%s)\n", f,
ftdi_get_error_string(&ftdic));
return EXIT_FAILURE;
}
printf("ftdi open succeeded: %d\n",f);
ftdi_set_bitmode(&ftdic,0xFF, BITMODE_RESET);
ftdi_set_baudrate(&ftdic,9600);
ftdi_write_data_set_chunksize(&ftdic,3);
printf("turning every potentiometer on\n");
buf[0] =0xFE;
buf[1] =0xAB;
buf[2] =128;
while (1)
{
f = ftdi_write_data(&ftdic,buf,3);
if (f< 0)
{
fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[2],f,
ftdi_get_error_string(&ftdic));
}
}
f = ftdi_usb_close(&ftdic);
if (f< 0)
{
fprintf(stderr,"unable to close ftdi device: %d (%s)\n", f,
ftdi_get_error_string(&ftdic));
return EXIT_FAILURE;
}
ftdi_deinit(&ftdic);
}|
I do not get any errors but when measuring the electrical resistance
with a ohmmeter, I do not get any change. Help will be greatly
appreciated, so thanks in advance for any kind of advices/comments.
Xavier Garrido
------------------------------------------------------------------------
*libftdi* - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to
libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
<mailto:libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx>
I had a quick glance at your code, and I noticed that the baud rate you
are setting (9600) differs from the specifications of your device (115200).
//Pelle
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|