pyftdi icon indicating copy to clipboard operation
pyftdi copied to clipboard

GPIO state reset when opening device

Open jsteinhofff opened this issue 1 year ago • 1 comments

Using pyftdi==0.55.0 .

As already mentioned in #218 , when a device gets opened, the state is reset and the last configured state cannot be retrieved anymore.

I was able to workaround this by temporarily monkey-patching out the set_bitmode function: image And i could verify that indeed this works for my use-case: I can set the GPIO state in one invocation of the script and i can retrieve the state with above workaround in another invocation of the script. I also verified that after a ftdi.reset(usb_reset=True) the approach still works but then obviously returns the default state (by which i mean that calling read() seems to be ok even if set_bitmode has not been called before on the device)

But obviously this is a quite nasty workaround and i wonder whether maybe it could be supported maybe as a special kind of GpioReadOnceController or something?

jsteinhofff avatar Feb 28 '24 12:02 jsteinhofff

I guess this is the right place to share my problem too. I use FTDI chip to control relays (direction=255) and the self.set_bitmode(0, Ftdi.BitMode.RESET) line in Ftdi.open_from_device() makes some of the relays twitch when my script opens the chip which isn't great.

steelman avatar Nov 07 '25 13:11 steelman