libftdi Archives

Subject: Re: python ftdi.read_data

From: "Lazarus Longitudis" <Lazarus-Long@xxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 19 Jan 2012 21:54:40 +0100
 Hi,

 Maybee I call the function wrong.
 Anyone with an example - the python examples do not include a read...
 If I do:
 new_data =3D ftdi.read_data(ftdic, wrote)
 I get a seg fault....


 best regards,
 Lazarus
-------- Original-Nachricht --------
> Datum: Wed, 18 Jan 2012 14:05:36 +0100
> Von: "Lazarus Longitudis" <Lazarus-Long@xxxxxx>
> An: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
> Betreff: python ftdi.read_data

>  
>  Hi,
>  
>  I am working with the current git code.
>  Was trying to use the python wrapper, it works mostly but the
> ftdi.read_data call seems to be messed up.
>  
>  Python says the function requires only two arguments, the context and an
> integer, obviously the target buffer pointer is missing.
>  
>  I have compared the swig generated ftdi_wrap.c against 0.19 and it is
> clear to see that the parameter parsing is broken here.
>  
>  any ideas?
>  
>  0.19:
>    if (!PyArg_ParseTuple(args,(char
> *)"OOO:ftdi_read_data",&obj0,&obj1,&obj2)) SWIG_fail;
>    res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ftdi_context, 0 |  0 );
>    if (!SWIG_IsOK(res1)) {
>      SWIG_exception_fail(SWIG_ArgError(res1), "in method '"
> "ftdi_read_data" "', argument " "1"" of type '" "struct ftdi_context *""'");
>    }
>    arg1 = (struct ftdi_context *)(argp1);
>    res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
>    if (!SWIG_IsOK(res2)) {
>      SWIG_exception_fail(SWIG_ArgError(res2), "in method '"
> "ftdi_read_data" "', argument " "2"" of type '" "unsigned char *""'");
>    }
>    arg2 = (unsigned char *)(buf2);
>    ecode3 = SWIG_AsVal_int(obj2, &val3);
>    if (!SWIG_IsOK(ecode3)) {
>      SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '"
> "ftdi_read_data" "', argument " "3"" of type '" "int""'");
>    }
>    arg3 = (int)(val3);
>    result = (int)ftdi_read_data(arg1,arg2,arg3);
>    resultobj = SWIG_From_int((int)(result));
>    return resultobj;
>  
>  git:
>    arg2 = &temp2;
>    if (!PyArg_ParseTuple(args,(char *)"OO:read_data",&obj0,&obj1))
> SWIG_fail;
>    res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ftdi_context, 0 |  0 );
>    if (!SWIG_IsOK(res1)) {
>      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "read_data"
> "', argument " "1"" of type '" "struct ftdi_context *""'");
>    }
>    arg1 = (struct ftdi_context *)(argp1);
>    ecode3 = SWIG_AsVal_int(obj1, &val3);
>    if (!SWIG_IsOK(ecode3)) {
>      SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "read_data"
> "', argument " "3"" of type '" "int""'");
>    }
>    arg3 = (int)(val3);
>    result = (int)ftdi_read_data(arg1,arg2,arg3);
>    resultobj = SWIG_From_int((int)(result));
>    if (SWIG_IsTmpObj(res2)) {
>      resultobj = SWIG_Python_AppendOutput(resultobj,
> SWIG_From_char((*arg2)));
>    } else {
>      int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN |  0 ) :  0 ;
>      resultobj = SWIG_Python_AppendOutput(resultobj,
> SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_unsigned_char, new_flags));
>    }
>    return resultobj;
>  fail:
>  
> -- 
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
> 
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx 
>  
> 

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread