FPP Output to Python Script

josephkoen

New member
I am looking for a way for a python script to read a output from FPP. I am running FPP on a raspi 3b+, and would like to port an output into python so I can control some RGB bluetooth flood lights. I am able to control the lights through python, I just don't know how to get the fpp sequence output into the script. Any help would be greatly appreciated.


PXL_20240307_134438016.jpg
 
What type of interface are the floods using? It is very likely that FPP can control them.
FPP also supports sending lighting data to local interfaces. You could simply open one and have python read from it. An offshoot of that would be to have python create a Com Interface and have FPP output to the COM port.
 
What type of interface are the floods using? It is very likely that FPP can control them.
FPP also supports sending lighting data to local interfaces. You could simply open one and have python read from it. An offshoot of that would be to have
The lights are bluetooth low energy (BLE), using GATT protocol. I have pulled all the color and lighting UUIDs for the lights. And am able to control them with gatttool on the rasbery pi. I just need a way to convert the FPP output to the GATT codes.

My first attempt was to try the USB port, but I either get a permissions denied error, or no such file or directory error. It looks like I am not setting up the COM port correctly.

Code:
import serial

with serial.Serial('/dev/ttyUSB0', 19200) as ser:
    while True:
        x = ser.read()

How would I go about sending data to local interfaces? I did not see anyting in the Channel Output/Other tab for that. Or do you know what I am doing wrong whith my COM connection?

Tanks again for the help.
 
You need to CREAT a com port and then use it. Your example only tries to use a com port. These are often called "Virtual" ports since they pretend to be a serial port but there is really no HW port involved.
  1. Use socat to create a set of ports (one for FPP and one for your application).
  2. Configure FPP serial output to send to your created port.
  3. Have your python app open the socat port and read data from it.
 
Ok, I am thick as mud, but feel like I am making some process. I have:

1. Used socat to create a set of ports (~/ttydevice and ~/ttyclient)
Code:
fpp@FPP:~ $ socat -d -d PTY,link=./ttydevice,raw,echo=0, PTY,link=./ttyclient,raw,echo=0
2024/03/07 15:03:58 socat[27960] N PTY is /dev/pts/2
2024/03/07 15:03:58 socat[27960] N PTY is /dev/pts/3
2024/03/07 15:03:58 socat[27960] N starting data transfer loop with FDs [5,5] and [7,7]

2. I was able to connect to one of the ~/ttyclient port using the script i posted previously.
Code:
fpp@FPP:~ $ python test-serial.py 
./ttyclient

But I am not able to find the ttydevice port in FPP. I only have the tree default options [ttyUSB0, ttyS0, and ttyAMA0]. Any idea on why the socat virtual port is not showing?
 
Awesome! Looks like I just needed to link the device to /dev/ttyS1 port, and I was able to connect to it through fpp.

Code:
fpp@FPP:~ $ sudo socat -d -d pty,rawer,echo=0,link=/dev/ttyS1 pty,rawer,echo=0,link=./ttyclient
2024/03/08 11:50:32 socat[26176] N PTY is /dev/pts/1
2024/03/08 11:50:32 socat[26176] N PTY is /dev/pts/2
2024/03/08 11:50:32 socat[26176] N starting data transfer loop with FDs [5,5] and [7,7]
1709929426533.png
I had some permission issues, but I just changed ownership of the /dev directory, and now for the fun task of paring the output and matting it to the GATT commands.

Once again, thanks a million. You were a huge help.
 
Back
Top