kaamil1984 Posted October 4, 2021 Share Posted October 4, 2021 (edited) Hi guys, I'm messing around with some modem and I have lost FTDI uart to usb converter. Can I use WaveForms and Analog Discovery 2 to send uart data somehow without bit-banging digital out? If its possible - maybe someone has script example? Edited October 4, 2021 by kaamil1984 Link to comment Share on other sites More sharing options...
0 attila Posted October 5, 2021 Share Posted October 5, 2021 Hi @kaamil1984 Depending on your requirements you can use: 1. WaveForms application/ Protocol/ UART interface 2. WF app Script tool, see the following example: 3. WF SDK, see manual and examples/ py/ Digital_Uart.py Link to comment Share on other sites More sharing options...
0 kaamil1984 Posted October 6, 2021 Author Share Posted October 6, 2021 (edited) Thank you. This is what I needed: dwf.FDwfDigitalUartTx(hdwf, rgTX, c_int(sizeof(rgTX)-1)) # send text, trim zero ending Line above is from this example ( Digilent\WaveFormsSDK\samples\py\Digital_Uart.py """ DWF Python Example Author: Digilent, Inc. Revision: 2018-07-23 Requires: Python 2.7, 3 """ from ctypes import * import math import sys import time if sys.platform.startswith("win"): dwf = cdll.LoadLibrary("dwf.dll") elif sys.platform.startswith("darwin"): dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf") else: dwf = cdll.LoadLibrary("libdwf.so") hdwf = c_int() print("Opening first device") #dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) # device configuration of index 3 (4th) for Analog Discovery has 16kS digital-in/out buffer dwf.FDwfDeviceConfigOpen(c_int(-1), c_int(3), byref(hdwf)) if hdwf.value == 0: print("failed to open device") szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print(str(szerr.value)) quit() print("Configuring UART...") cRX = c_int(0) fParity = c_int(0) # configure the I2C/TWI, default settings dwf.FDwfDigitalUartRateSet(hdwf, c_double(9600)) # 9.6kHz dwf.FDwfDigitalUartTxSet(hdwf, c_int(0)) # TX = DIO-0 dwf.FDwfDigitalUartRxSet(hdwf, c_int(1)) # RX = DIO-1 dwf.FDwfDigitalUartBitsSet(hdwf, c_int(8)) # 8 bits dwf.FDwfDigitalUartParitySet(hdwf, c_int(0)) # 0 none, 1 odd, 2 even dwf.FDwfDigitalUartStopSet(hdwf, c_double(1)) # 1 bit stop length dwf.FDwfDigitalUartTx(hdwf, None, c_int(0))# initialize TX, drive with idle level dwf.FDwfDigitalUartRx(hdwf, None, c_int(0), byref(cRX), byref(fParity))# initialize RX reception time.sleep(1) rgTX = create_string_buffer(b'Hello\r\n') rgRX = create_string_buffer(8193) print("Sending on TX for 10 seconds...") dwf.FDwfDigitalUartTx(hdwf, rgTX, c_int(sizeof(rgTX)-1)) # send text, trim zero ending tsec = time.clock() + 10 # receive for 10 seconds print("Receiving on RX...") while time.clock() < tsec: time.sleep(0.01) dwf.FDwfDigitalUartRx(hdwf, rgRX, c_int(sizeof(rgRX)-1), byref(cRX), byref(fParity)) # read up to 8k chars at once if cRX.value > 0: rgRX[cRX.value] = 0 # add zero ending print(rgRX.value.decode(), end = '', flush=True) if fParity.value != 0: print("Parity error {}".format(fParity.value)) dwf.FDwfDeviceCloseAll() --- But it would be VERY VERY useful if I could just write and send data from here: Edited October 6, 2021 by kaamil1984 Link to comment Share on other sites More sharing options...
0 attila Posted October 7, 2021 Share Posted October 7, 2021 Hi @kaamil1984 It can be done. 1. You can use the "Send & Receive" tab of UART. 2. To automate things you can use the Script tool. 3. WF SDK for custom app/scripts. On 10/5/2021 at 10:45 AM, attila said: 3. WF SDK, see manual and examples/ py/ Digital_Uart.py Link to comment Share on other sites More sharing options...
Question
kaamil1984
Hi guys,
I'm messing around with some modem and I have lost FTDI uart to usb converter.
Can I use WaveForms and Analog Discovery 2 to send uart data somehow without bit-banging digital out?
If its possible - maybe someone has script example?
Edited by kaamil1984Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now