1
0
Fork 0
mirror of https://github.com/pikvm/pikvm.git synced 2026-03-02 18:16:56 -05:00

API: Switch GPIO channel post call is failing with the message "This GPIO channel does not support switching" #696

Closed
opened 2026-02-20 14:04:07 -05:00 by deekerman · 1 comment
Owner

Originally created by @plia7 on GitHub (Jul 21, 2023).

Originally assigned to: @mdevaev on GitHub.

Describe the bug
API - Switch GPIO channel post call is failing with message "This GPIO channel does not support switching" (GpioChannelNotFoundError).

To Reproduce

  1. Prerequisite: Have your GPIO configured for ezcoo 4 switch based on this link: https://docs.pikvm.org/ezcoo/#adding-ui-elements-to-control-the-kvm-switch so you have in your GPIO 4 buttons that their corresponding channels are: ch0_button, ch1_button, ch2_button ch3_button.
  2. Ensure in pikvm web ui your current GPIO selected is the first button (ch0_button).
  3. Make an API POST call to https://pikvm-ip/api/gpio/switch
    using HTTP Basic Auth with the following parameters::
    channel=ch1_button
    state=1

Actual behavior
Getting a 400 HTTP Response Code:

{
    "ok": false,
    "result": {
        "error": "GpioSwitchNotSupported",
        "error_msg": "This GPIO channel does not support switching"
    }
}

Expected behavior
GPIO switches from channel ch0_button to ch1_button just like it allows you to do it from the Web UI.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
    API Call
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]
  • VNC client (if used)

PiKVM info:

  • Raspberry Pi board version [e.g. RPi 4]
  • PiKVM platform [e.g. v2-hdmi]
  • Video capture type [e.g. CSI bridge]
  • KVMD version: pacman -Q | grep kvmd
    kvmd-platform-v3-hdmi-rpi4 3.234-1
  • uStreamer version: pacman -Q | grep ustreamer
    ustreamer 5.41-1
  • Linux kernel: uname -a
    Linux pikvm 5.15.68-3-rpi-ARCH #1 SMP Mon Oct 31 20:56:54 MSK 2022 armv7l GNU/Linux

Additional context
I tried the same test with being on channel ch1_button and trying to switch to channel ch0_button and getting the same result.
It allows you to do it from the Web UI without any problems, there shouldn't be a reason why it gives you this error when doing it from the API.

For reference, here is the response I got when running an API GET call to: https://pikvm-ip/api/gpio

{
    "ok": true,
    "result": {
        "model": {
            "scheme": {
                "inputs": {
                    "ch0_led": {
                        "hw": {
                            "driver": "ez",
                            "pin": "0"
                        }
                    },
                    "ch1_led": {
                        "hw": {
                            "driver": "ez",
                            "pin": "1"
                        }
                    },
                    "ch2_led": {
                        "hw": {
                            "driver": "ez",
                            "pin": "2"
                        }
                    },
                    "ch3_led": {
                        "hw": {
                            "driver": "ez",
                            "pin": "3"
                        }
                    }
                },
                "outputs": {
                    "__v3_usb_breaker__": {
                        "hw": {
                            "driver": "__gpio__",
                            "pin": "5"
                        },
                        "pulse": {
                            "delay": 0.0,
                            "max_delay": 0.0,
                            "min_delay": 0.0
                        },
                        "switch": true
                    },
                    "ch0_button": {
                        "hw": {
                            "driver": "ez",
                            "pin": "0"
                        },
                        "pulse": {
                            "delay": 0.1,
                            "max_delay": 0.1,
                            "min_delay": 0.1
                        },
                        "switch": false
                    },
                    "ch1_button": {
                        "hw": {
                            "driver": "ez",
                            "pin": "1"
                        },
                        "pulse": {
                            "delay": 0.1,
                            "max_delay": 0.1,
                            "min_delay": 0.1
                        },
                        "switch": false
                    },
                    "ch2_button": {
                        "hw": {
                            "driver": "ez",
                            "pin": "2"
                        },
                        "pulse": {
                            "delay": 0.1,
                            "max_delay": 0.1,
                            "min_delay": 0.1
                        },
                        "switch": false
                    },
                    "ch3_button": {
                        "hw": {
                            "driver": "ez",
                            "pin": "3"
                        },
                        "pulse": {
                            "delay": 0.1,
                            "max_delay": 0.1,
                            "min_delay": 0.1
                        },
                        "switch": false
                    },
                    "jiggle_off": {
                        "hw": {
                            "driver": "unjiggle",
                            "pin": "None"
                        },
                        "pulse": {
                            "delay": 0.1,
                            "max_delay": 0.1,
                            "min_delay": 0.1
                        },
                        "switch": false
                    },
                    "jiggle_on": {
                        "hw": {
                            "driver": "jiggle",
                            "pin": "None"
                        },
                        "pulse": {
                            "delay": 0.1,
                            "max_delay": 0.1,
                            "min_delay": 0.1
                        },
                        "switch": false
                    }
                }
            },
            "view": {
                "header": {
                    "title": [
                        {
                            "text": "GPIO",
                            "type": "label"
                        }
                    ]
                },
                "table": [
                    [
                        {
                            "text": "XXX",
                            "type": "label"
                        },
                        {
                            "channel": "ch0_led",
                            "color": "green",
                            "type": "input"
                        },
                        {
                            "channel": "ch0_button",
                            "confirm": false,
                            "text": "Click",
                            "type": "output"
                        }
                    ],
                    [
                        {
                            "text": "YYY",
                            "type": "label"
                        },
                        {
                            "channel": "ch1_led",
                            "color": "green",
                            "type": "input"
                        },
                        {
                            "channel": "ch1_button",
                            "confirm": false,
                            "text": "Click",
                            "type": "output"
                        }
                    ],
                    [
                        {
                            "text": "AAA",
                            "type": "label"
                        },
                        {
                            "channel": "ch2_led",
                            "color": "green",
                            "type": "input"
                        },
                        {
                            "channel": "ch2_button",
                            "confirm": false,
                            "text": "Click",
                            "type": "output"
                        }
                    ],
                    [
                        {
                            "text": "BBB",
                            "type": "label"
                        },
                        {
                            "channel": "ch3_led",
                            "color": "green",
                            "type": "input"
                        },
                        {
                            "channel": "ch3_button",
                            "confirm": false,
                            "text": "Click",
                            "type": "output"
                        }
                    ],
                    [
                        {
                            "text": "Mouse Jiggler",
                            "type": "label"
                        }
                    ],
                    [
                        {
                            "channel": "jiggle_off",
                            "confirm": false,
                            "text": "disable",
                            "type": "output"
                        },
                        {
                            "channel": "jiggle_on",
                            "confirm": false,
                            "text": "enable",
                            "type": "output"
                        }
                    ]
                ]
            }
        },
        "state": {
            "inputs": {
                "ch0_led": {
                    "online": true,
                    "state": true
                },
                "ch1_led": {
                    "online": true,
                    "state": false
                },
                "ch2_led": {
                    "online": true,
                    "state": false
                },
                "ch3_led": {
                    "online": true,
                    "state": false
                }
            },
            "outputs": {
                "__v3_usb_breaker__": {
                    "busy": false,
                    "online": true,
                    "state": true
                },
                "ch0_button": {
                    "busy": false,
                    "online": true,
                    "state": true
                },
                "ch1_button": {
                    "busy": false,
                    "online": true,
                    "state": false
                },
                "ch2_button": {
                    "busy": false,
                    "online": true,
                    "state": false
                },
                "ch3_button": {
                    "busy": false,
                    "online": true,
                    "state": false
                },
                "jiggle_off": {
                    "busy": false,
                    "online": true,
                    "state": false
                },
                "jiggle_on": {
                    "busy": false,
                    "online": true,
                    "state": false
                }
            }
        }
    }
}
Originally created by @plia7 on GitHub (Jul 21, 2023). Originally assigned to: @mdevaev on GitHub. **Describe the bug** API - Switch GPIO channel post call is failing with message "This GPIO channel does not support switching" (GpioChannelNotFoundError). **To Reproduce** 1. Prerequisite: Have your GPIO configured for ezcoo 4 switch based on this link: https://docs.pikvm.org/ezcoo/#adding-ui-elements-to-control-the-kvm-switch so you have in your GPIO 4 buttons that their corresponding channels are: ch0_button, ch1_button, ch2_button ch3_button. 2. Ensure in pikvm web ui your current GPIO selected is the first button (ch0_button). 3. Make an API POST call to https://pikvm-ip/api/gpio/switch using HTTP Basic Auth with the following parameters:: channel=ch1_button state=1 **Actual behavior** Getting a 400 HTTP Response Code: ``` { "ok": false, "result": { "error": "GpioSwitchNotSupported", "error_msg": "This GPIO channel does not support switching" } } ``` **Expected behavior** GPIO switches from channel ch0_button to ch1_button just like it allows you to do it from the Web UI. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: [e.g. iOS] API Call - Browser [e.g. chrome, safari] - Version [e.g. 22] - VNC client (if used) **PiKVM info:** - Raspberry Pi board version [e.g. RPi 4] - PiKVM platform [e.g. v2-hdmi] - Video capture type [e.g. CSI bridge] - KVMD version: `pacman -Q | grep kvmd` kvmd-platform-v3-hdmi-rpi4 3.234-1 - uStreamer version: `pacman -Q | grep ustreamer` ustreamer 5.41-1 - Linux kernel: `uname -a` Linux pikvm 5.15.68-3-rpi-ARCH #1 SMP Mon Oct 31 20:56:54 MSK 2022 armv7l GNU/Linux **Additional context** I tried the same test with being on channel ch1_button and trying to switch to channel ch0_button and getting the same result. It allows you to do it from the Web UI without any problems, there shouldn't be a reason why it gives you this error when doing it from the API. For reference, here is the response I got when running an API GET call to: https://pikvm-ip/api/gpio ``` { "ok": true, "result": { "model": { "scheme": { "inputs": { "ch0_led": { "hw": { "driver": "ez", "pin": "0" } }, "ch1_led": { "hw": { "driver": "ez", "pin": "1" } }, "ch2_led": { "hw": { "driver": "ez", "pin": "2" } }, "ch3_led": { "hw": { "driver": "ez", "pin": "3" } } }, "outputs": { "__v3_usb_breaker__": { "hw": { "driver": "__gpio__", "pin": "5" }, "pulse": { "delay": 0.0, "max_delay": 0.0, "min_delay": 0.0 }, "switch": true }, "ch0_button": { "hw": { "driver": "ez", "pin": "0" }, "pulse": { "delay": 0.1, "max_delay": 0.1, "min_delay": 0.1 }, "switch": false }, "ch1_button": { "hw": { "driver": "ez", "pin": "1" }, "pulse": { "delay": 0.1, "max_delay": 0.1, "min_delay": 0.1 }, "switch": false }, "ch2_button": { "hw": { "driver": "ez", "pin": "2" }, "pulse": { "delay": 0.1, "max_delay": 0.1, "min_delay": 0.1 }, "switch": false }, "ch3_button": { "hw": { "driver": "ez", "pin": "3" }, "pulse": { "delay": 0.1, "max_delay": 0.1, "min_delay": 0.1 }, "switch": false }, "jiggle_off": { "hw": { "driver": "unjiggle", "pin": "None" }, "pulse": { "delay": 0.1, "max_delay": 0.1, "min_delay": 0.1 }, "switch": false }, "jiggle_on": { "hw": { "driver": "jiggle", "pin": "None" }, "pulse": { "delay": 0.1, "max_delay": 0.1, "min_delay": 0.1 }, "switch": false } } }, "view": { "header": { "title": [ { "text": "GPIO", "type": "label" } ] }, "table": [ [ { "text": "XXX", "type": "label" }, { "channel": "ch0_led", "color": "green", "type": "input" }, { "channel": "ch0_button", "confirm": false, "text": "Click", "type": "output" } ], [ { "text": "YYY", "type": "label" }, { "channel": "ch1_led", "color": "green", "type": "input" }, { "channel": "ch1_button", "confirm": false, "text": "Click", "type": "output" } ], [ { "text": "AAA", "type": "label" }, { "channel": "ch2_led", "color": "green", "type": "input" }, { "channel": "ch2_button", "confirm": false, "text": "Click", "type": "output" } ], [ { "text": "BBB", "type": "label" }, { "channel": "ch3_led", "color": "green", "type": "input" }, { "channel": "ch3_button", "confirm": false, "text": "Click", "type": "output" } ], [ { "text": "Mouse Jiggler", "type": "label" } ], [ { "channel": "jiggle_off", "confirm": false, "text": "disable", "type": "output" }, { "channel": "jiggle_on", "confirm": false, "text": "enable", "type": "output" } ] ] } }, "state": { "inputs": { "ch0_led": { "online": true, "state": true }, "ch1_led": { "online": true, "state": false }, "ch2_led": { "online": true, "state": false }, "ch3_led": { "online": true, "state": false } }, "outputs": { "__v3_usb_breaker__": { "busy": false, "online": true, "state": true }, "ch0_button": { "busy": false, "online": true, "state": true }, "ch1_button": { "busy": false, "online": true, "state": false }, "ch2_button": { "busy": false, "online": true, "state": false }, "ch3_button": { "busy": false, "online": true, "state": false }, "jiggle_off": { "busy": false, "online": true, "state": false }, "jiggle_on": { "busy": false, "online": true, "state": false } } } } } ```
Author
Owner

@mdevaev commented on GitHub (Jul 21, 2023):

For buttons without fixed state you should use the pulse API: https://docs.pikvm.org/api/#pulse-gpio-channel

@mdevaev commented on GitHub (Jul 21, 2023): For buttons without fixed state you should use the pulse API: https://docs.pikvm.org/api/#pulse-gpio-channel
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pikvm-pikvm#696
No description provided.