I recently needed to create serial data strings in order to test a system, and did not want to dedicate a PC for the purpose. So I used the TrueArb function of my Siglent SDG1000X AWG to generate the serial data as a set of waveform points in the ARB memory.
This was done with a Python script that reads an input text file, expands each character into the proper bit sequence, then uploads the result to the AWG. The script can handle the usual serial parameters: baud rate, data length, parity, and stop bit count. It also can generate either a logic signal (swings from a positive voltage to ground and idles high), or an "EIA" signal (swings from a negative to a positive voltage and idles low).
The scope image attached shows the AWG delivering logic level data at 19200,8,N,1 from channel 1 (upper trace), and EIA level data at 9600,8,N,1 from channel 2 (lower trace). The scope is decoding the EIA data, just to confirm that things work as expected.
The script is named psag1.py. If invoked with no parameters, it returns this prompt:
usage: psag1.py [-h] [--name NAME_WAVE_FILE] [--chan CHANNEL] [--output OUTPUTFILE] [--baud BAUD] [--len CHR_LEN]
[--par CHR_PARITY] [--stop CHR_STOP] [--mode MODE] [--vmax VMAX]
inputfile
The trace at the top of the scope photo was generated by the command below, where "foo1.txt" is the 5-character input file. Note that many parameters are not specified, as their default values are used.
py psag1.py --chan 1 --name wave1 --mode TTL --baud 19200 foo1.txt
Converting 5 characters into 5.000V TTL serial format: 19200,8,NONE,1
Data conversion complete. Results stored in ./awg.dat.
Sent to AWG as wave1 on channel C1.
Script complete.
This version of the script uses a hard-coded IP address for the AWG, and it does not do any error checking on file names. There are a few other things that could be improved if anyone feels motivated, but it works well enough for my present purposes.
Although it has only been tested with an SDG1000X, it should run on the family mates SDG2000X and SDG6000X.
I hope others find this as useful as I have.