Jonathan,
sorry about the delay as I haven't picked up email on this account for
a week.
I also haven't written code using the bindings for a while as my
immediate need is done and dusted.
The swig typedef solution works (have used it before) as does using
ctypes module. I normally avoid doing this unless absolutely necessary
as it necessitates more manual intervention in the glue for maintenance.
I've just whittled down some code as way of example of how I have it
working.
The main difference appears to be that I am using ftdi_write_data not
ftdi_write to write serial string...this avoids all the hassles you are
likely having.
eg a crude snippet to talk to matrox orbital LCD could be
[I'm used pyusb for enumeration at the time. Typically on linux its also
quite easy to use the /sys interface]
import time, usb, ftdi
class lcd:
def __init__(self, context, ftdi):
self.ftdi=ftdi
self.context=context
def text(self, text):
self.ftdi.ftdi_write_data(self.context, text, len(text))
def connectScreen():
#lets try for usb enum
found=None
dev=None
bus=None
while not found:
print "finding dev"
for bus in usb.busses():
for dev in bus.devices:
if dev.idVendor==0x1b3d and dev.idProduct==0x157:
found=bus, dev
break
if found: break
time.sleep(0.5)
print "dev found"
#we now connect via ftdi
context=ftdi.ftdi_context()
ftdi.ftdi_init(context)
ftdi.ftdi_usb_open(context, 0x1b3d, 0x157 )
ftdi.ftdi_set_baudrate(context, 19200)
ftdi.ftdi_set_line_property( context, ftdi.BITS_8, ftdi.EVEN,
ftdi.STOP_BIT_1)
return lcd(context, ftdi)
lcdconn=connectScreen()
lcdconn.text("hello world")
On 03/17/10 12:16, Jonathan Moreton wrote:
> Thank you Thomas that was helpful, but not what I am trying to do.
>
> What i am trying to do is send a serial string out using the
> ftdi_write() method.
>
> can I do the following with out breaking anything?
>
> Change the function to take a string instead of unsigned char *
> see:
> http://www.contactor.se/~matsl/HowtoReturnUnsignedCharFromPythonUsingSwig.html
>
> Many Thanks
>
> Jonathan Moreton
> On Tue, 2010-03-16 at 22:58 +0100, Thomas Jarosch wrote:
>
>> Hello Jonathan,
>>
>> On 03/13/2010 05:20 PM, Jonathan Moreton wrote:
>>
>>> I am using the python bindings for libftdi what type do i need to set
>>> the buf to when using ftdi_write_data as I get
>>>
>>> TypeError: in method 'ftdi_write_data', argument 2 of type 'unsigned
>>> char *'
>>>
>> I found a small piece of python code using the wrapper
>> on this german speaking website:
>> http://www.auxnet.de/blog/blog-post/2010/02/23/usb-geraet-per-libftdi-in-c-und-python-ansprechen-debianubuntu.html
>>
>> Scroll down for the code. Maybe it helps.
>>
>> Cheers,
>> Thomas
>>
>> --
>> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
>> To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
>>
>>
>
>
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
>
>
>
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|