Scripting Flipper from a PC: CLI Automation
The Idea
Since Flipper's CLI is just a serial connection, anything that can talk to a serial port can drive it programmatically — Python with pyserial is the most common approach, letting you script repeatable test sequences, automate data collection, or build custom tooling around Flipper's capabilities without manually navigating on-device menus each time.
Basic Python Setup
pip install pyserialimport serial
import time
flipper = serial.Serial('/dev/ttyACM0', 115200, timeout=2)
# Windows: serial.Serial('COM5', 115200, timeout=2)
def send_command(cmd):
flipper.write((cmd + '\r\n').encode())
time.sleep(0.1)
return flipper.read(flipper.in_waiting or 1).decode(errors='ignore')
print(send_command('device_info'))
Practical Automation Example: Batch Signal Testing
signals = ['signal1.sub', 'signal2.sub', 'signal3.sub']
for sig in signals:
print(f"Testing {sig}...")
send_command(f'subghz tx_from_file /ext/subghz/{sig}')
time.sleep(2) # let the transmission complete
# log result, prompt for pass/fail, etc.
This pattern — loop through a list of saved captures, transmit each with a pause, log results — is exactly the kind of repetitive testing that's tedious through the on-device menu but trivial once scripted.
Reading Structured Output
Most CLI commands return plain text meant for human reading, not structured JSON/CSV — if you're building anything beyond simple trigger-and-wait automation, plan to parse text output with regex or string splitting rather than expecting clean structured data back.
GPIO Automation Example
def gpio_set(pin, state):
send_command(f'gpio set {pin} {state}')
def gpio_read(pin):
result = send_command(f'gpio read {pin}')
return result
# Toggle a pin every second, 10 times, logging state
for i in range(10):
gpio_set(2, 1)
time.sleep(1)
gpio_set(2, 0)
time.sleep(1)
Building a Real Tool Around This
A common pattern for anyone doing repeated RF/IR product testing: a small Python script with a menu (or even a simple local web UI via Flask) that wraps common CLI command sequences into single-click actions — turns Flipper into a scriptable bench instrument rather than a manually-operated handheld, without needing to write custom FAP firmware for the automation layer itself.
Where This Connects to FAP Development
If you're actively developing a custom app (see the "Writing Your First FAP App" guide), the log CLI command combined with a Python script that captures and timestamps output gives you a genuinely useful automated test log across development iterations, rather than manually watching the console each time.