Comments (4)
To make it clear, here's a minimal working program written in C using the D2xx library calls. I'd like to replicate this functionality using pyftdi:
/**
* Test CBUS bitbang interface on FT232 chip.
*
* Our goal is to wiggle CBUS bit 3, which in the FTDI USB-RS485 cable
* controls the 5V drive circuitry on the output wires.
*
* gcc -o bitbang bitbang.c -L. -lftd2xx -Wl,-rpath /usr/local/lib
* cc bitbang.c -o bitbang -Wall -Wextra -lftd2xx -lpthread -lobjc -framework IOKit -framework CoreFoundation -Wl,-rpath /usr/local/lib -L/usr/local/lib
*/
#include "ftd2xx.h"
#include <WinTypes.h>
#include <stdio.h>
#include <unistd.h>
const UCHAR Drive03Hi=0x88; /* CBUS03 configured as output, drive hi */
const UCHAR Drive03Lo=0x80; /* CBUS03 configured as output, drive lo */
int main() {
FT_HANDLE ftHandle;
FT_STATUS ftStatus = FT_Open(0, &ftHandle);
if(ftStatus != FT_OK) {
fprintf(stderr, "FT_Open failed => %d\n", ftStatus);
return 1;
}
// Repeatedly drive CBUS 03 high and then low
while(ftStatus == FT_OK) {
ftStatus = FT_SetBitMode(ftHandle, Drive03Hi, FT_BITMODE_CBUS_BITBANG);
sleep(3);
ftStatus = FT_SetBitMode(ftHandle, Drive03Lo, FT_BITMODE_CBUS_BITBANG);
sleep(3);
}
FT_Close(ftHandle);
}
from pyftdi.
Solved. But some documentation might help. Bitbang for CBUS is a bit strange, since the set_bitmode() mask argument defines the data direction and state of the bits -- there is no separate write function.
Working code example follows:
from pyftdi.ftdi import Ftdi
import time
ftdi = Ftdi()
ftdi.open_from_url('ftdi:///1')
while(True):
ftdi.set_bitmode(0x88, Ftdi.BITMODE_CBUS)
time.sleep(3)
ftdi.set_bitmode(0x80, Ftdi.BITMODE_CBUS)
time.sleep(3)
# never actually gets here...
ftdi.close()
from pyftdi.
@rdpoor I get: AttributeError: type object 'Ftdi' has no attribute 'BITMODE_CBUS' :(
from pyftdi.
Please do not comment on tickets that are 4 years old, the code has evolved quite a bit since.
If there is an issue that is related to an existing ticket, open a new one and add a reference to it. Thanks.
from pyftdi.
Related Issues (20)
- 0.55 Operation not supported or unimplemented on this platform (FT4232HA) Windows HOT 1
- 0.54.0 FT230x EEPROM API inaccuracies HOT 2
- 0.55.0 not on pypi.org HOT 3
- Low baudrates doesn't work with bit-banging.
- How to enable TXDEN on FT4232H?
- Intermittent errors when accessing FTDI HOT 5
- Specification issue in I2cController.exchange(self, out, readlen, relax, start)
- Timeout behaviour of read method not compatible with pyserial HOT 1
- clearing eeprom
- Unable to configure EEPROM: EEPROM does not support mirroring HOT 1
- UART lock up with FT4232H HOT 1
- GPIO state reset when opening device
- Error in class I2CBusScanner logic - if read success, skips write test HOT 1
- "Error: No backend available" during Mac OS instllation. HOT 1
- in_waiting and out_waiting in pyftdi/serialext/protocol_ftdi.py not implemented but return always 0 HOT 2
- Incorrect results when reading i2c with clock stretching
- No such device / 4 USB devices match URL 'ftdi:///2' HOT 2
- Default state for CBUS pins in GPIO mode?
- Trying to write `channel_a_type = 1` to EEPROM connected to FT232H causes `KeyError: '1'` exception HOT 1
- Bus C and D are used as serial ports and A and B are used as gpio, Will there be any conflict when the four are used together
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyftdi.