Hi all,
I'm stuck on compiling a small program. Due to my bad knowledge of C I'm struggling half a week with the folling error:
-----------------------------------------------------------------------------------------------------------------------------
/home/hinschj/Openwrt/trunk/build_mipsel/smusbutil/smusbutil.c: In function `main':
/home/hinschj/Openwrt/trunk/build_mipsel/smusbutil/smusbutil.c:35: error: storage size of 'ftdic' isn't known
make[2]: *** [/home/hinschj/Openwrt/trunk/build_mipsel/smusbutil/.built] Error 1
-----------------------------------------------------------------------------------------------------------------------------
The program itself I like to get compiled for mips on kamikaze is called smusbutil which should give you the option to select frequency on a so called smartmouse from wb-electronics.
Code:
/*******************************************************************************
*
* smusbutil : A simple configuration utility for the WB Electronics
* Smartmouse USB Phoenix Smartmouse interface.
*
* WB Electronics Homepage: http://www.wbe.dk
*
* History :
* Version 1.0 - Initial release.
*
* Carsten Sprung <carsten@carsten-sprung.de>
* Many thanks to Martin <martin@wbe.dk> for providing the necessary infos.
*
*******************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <usb.h>
#include <ftdi.h>
static void print_usage(void)
{
fprintf(stderr, "Usage: smusbutil clockrate mode\n\n");
fprintf(stderr, " <3580 | 3680 | 6000> Set smartcard clock in kHz\n");
fprintf(stderr, " <phoenix | smartmouse> Set operation mode\n");
fprintf(stderr, "\n");
fprintf(stderr, " Note: When you get a -5 error, make sure the kernel ftdi_sio driver is unloaded.\n You will need root privileges!\n\n");
}
int main(int argc, char *argv[])
{
struct ftdi_context ftdic;
int f,i,e;
char buf[1];
buf[0] = 0;
e = 0;
char frq, opmode;
if (argc != 3)
{
print_usage();
exit(-1);
}
switch(atoi(argv[1])) {
case 3580: //3,58 = 10 = 2
frq = 2;
break;
case 3680: //3,68 = 11 = 3
frq = 3;
break;
case 6000: //6,00 = 01 = 1
frq = 1;
break;
default:
print_usage();
exit(-1);
}
buf[0] |= frq<<4;
if(strcmp(argv[2], "smartmouse") == 0) {
buf[0] |= 1<<6;
e = 1;
}
if(strcmp(argv[2], "phoenix") == 0) {
e = 1;
}
if(!e) {
print_usage();
exit(-1);
}
ftdi_init(&ftdic);
f = ftdi_usb_open(&ftdic, 0x104f, 0x0002);
if(f < 0 && f != -5) {
fprintf(stderr, "can't find any Smartmouse USB (VID:0x104f/PID:0x0002): %d\n",f);
exit(-1);
}
printf("Smartmouse USB found: %d\n",f);
printf("enabling bitbang mode\n");
ftdi_enable_bitbang(&ftdic, 0xFF);
f = ftdi_write_data(&ftdic, buf, 1);
if(f < 0) exit(-1);
f = ftdi_write_data(&ftdic, buf, 1);
if(f < 0) exit(-1);
buf[0] |= 0x80; //RI
f = ftdi_write_data(&ftdic, buf, 1);
if(f < 0) exit(-1);
printf("disabling bitbang mode\n");
ftdi_disable_bitbang(&ftdic);
ftdi_usb_close(&ftdic);
ftdi_deinit(&ftdic);
}
---------------------------------------------------------------------------------------------------------------------------
I already replaced the include statements for usb.h and ftdi.h with full qualified pathnames and also replaced the ftdi_sio.h and ftdi_sio.c in the build_mipsel subdir with the one provied with this program.
Maybe one of you all with much better knowledge can help me / give a hint what to do with this error...?
Thanks in advance
Joachim
PS: The Makefile seems to work...I copied and modified it from the io-package...