Welcome to the FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

New USB passthough question

Steven Catani
Steven Catani Member ✭✭

I have a sainsmart USB relay board I control via a small python program locally in the shack. I would like to be able to conroling using the new pass through feature as I seem to do most of my operating on my laptop now away ffrom the shack. When I configure the passthough based on the discussion it seems to set up correcty but the program soesn't work. It tells be there are not ftdi devices. My radio can switch the relays without any problem. Any ideas

Answers

  • Steven Catani
    Steven Catani Member ✭✭

    btw here is the pyhon code that works locally

    import customtkinter as ctk
    import ftd2xx
    import os

    RELAY_COUNT = 8
    LABEL_FILE = "relay_labels.txt"

    relay_labels = []
    relay_states = [False] * RELAY_COUNT
    buttons = []
    ftdi = None

    def load_labels():
    labels = [f"Relay {i+1}" for i in range(RELAY_COUNT)]
    if os.path.exists(LABEL_FILE):
    with open(LABEL_FILE, "r") as f:
    lines = f.readlines()
    for i in range(min(RELAY_COUNT, len(lines))):
    clean = lines[i].****()
    if clean:
    labels[i] = clean
    return labels

    def connect_ftdi():
    global ftdi
    try:
    ftdi = ftd2xx.open(0)
    ftdi.setBitMode(0xFF, 0x01)
    status_label.configure(text="Connected to FTDI relay board")
    turn_all_off()
    for btn in buttons:
    btn.configure(state="normal")
    except Exception as e:
    status_label.configure(text=f"FTDI connection failed: {e}")
    for btn in buttons:
    btn.configure(state="disabled")

    def update_relay_outputs():
    if ftdi:
    mask = 0x00 # All OFF
    for i, state in enumerate(relay_states):
    if state:
    mask |= (1 << i) # HIGH = ON
    else:
    mask &= ~(1 << i) # LOW = OFF
    ftdi.write(bytes([mask]))

    def make_toggle(relay_id):
    def toggle():
    for i in range(RELAY_COUNT):
    relay_states[i] = (i == relay_id - 1)
    buttons[i].configure(fg_color="green" if relay_states[i] else "gray")
    update_relay_outputs()
    return toggle

    def turn_all_off():
    for i in range(RELAY_COUNT):
    relay_states[i] = False
    buttons[i].configure(fg_color="gray")
    update_relay_outputs()

    ctk.set_appearance_mode("dark")
    ctk.set_default_color_theme("blue")
    app = ctk.CTk()
    app.title("Antenna Relay Selector")
    app.geometry("400x650")

    relay_labels = load_labels()

    for i in range(RELAY_COUNT):
    btn = ctk.CTkButton(
    app,
    text=relay_labels[i],
    fg_color="gray",
    state="disabled",
    command=make_toggle(i + 1)
    )
    btn.pack(pady=6, padx=20, fill='x')
    buttons.append(btn)

    status_label = ctk.CTkLabel(app, text="Not connected")
    status_label.pack(pady=20)

    connect_ftdi()

    app.mainloop()

    if ftdi:
    ftdi.write(bytes([0x00])) # All relays OFF
    ftdi.close()

  • Eric-KE5DTO
    Eric-KE5DTO Administrator, FlexRadio Employee admin

    Sorry to be the bearer of bad news, but it looks like this script is talking directly to the FTDI drivers (e.g. not via the serial interface). As such, I'm don't think that this is going to work through the passthrough interface as what is exposed on the client side for passthrough cables is just a serial port (as opposed to a full USB device). I suspect this is why the script is complaining that there are no FTDI devices as this is accurate from the local point of view when the Sainsmart device is plugged into the radio.

  • Steven Catani
    Steven Catani Member ✭✭

    it seems the sainsmart cards that look exactly alike come with two different chips sets… one will except serial commands, the one I have onky excepts ftdi links with precludes the pass though…. looking at options

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.