Skip to content

Commit

Permalink
Make kvmd compatible with libgpiod 1.2.
Browse files Browse the repository at this point in the history
The singular default_val argument of gpiod.Line.request() method
was introduced in libgpiod 1.3.

For older versions of libgpiod, defailt_vals argument with list value
should be used.

This argument is available in newer versions of libgpiod as well
for compatibility.

This change is needed for Debian / Raspbian 10 that have libgpiod 1.2.

Signed-off-by: Oleg Girko <[email protected]>
  • Loading branch information
Oleg Girko committed Sep 20, 2020
1 parent c6b7b58 commit a8589e4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kvmd/plugins/atx/gpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ def sysprep(self) -> None:
self.__chip = gpiod.Chip(aiogp.DEVICE_PATH)

self.__power_switch_line = self.__chip.get_line(self.__power_switch_pin)
self.__power_switch_line.request("kvmd::atx-gpio::power_switch", gpiod.LINE_REQ_DIR_OUT, default_val=0)
self.__power_switch_line.request("kvmd::atx-gpio::power_switch", gpiod.LINE_REQ_DIR_OUT, default_vals=[0])

self.__reset_switch_line = self.__chip.get_line(self.__reset_switch_pin)
self.__reset_switch_line.request("kvmd::atx-gpio::reset_switch", gpiod.LINE_REQ_DIR_OUT, default_val=0)
self.__reset_switch_line.request("kvmd::atx-gpio::reset_switch", gpiod.LINE_REQ_DIR_OUT, default_vals=[0])

async def get_state(self) -> Dict:
return {
Expand Down
2 changes: 1 addition & 1 deletion kvmd/plugins/hid/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def open(self) -> None:
assert self.__reset_line is None
self.__chip = gpiod.Chip(aiogp.DEVICE_PATH)
self.__reset_line = self.__chip.get_line(self.__reset_pin)
self.__reset_line.request("kvmd::hid-serial::reset", gpiod.LINE_REQ_DIR_OUT, default_val=0)
self.__reset_line.request("kvmd::hid-serial::reset", gpiod.LINE_REQ_DIR_OUT, default_vals=[0])

def close(self) -> None:
if self.__chip:
Expand Down
4 changes: 2 additions & 2 deletions kvmd/plugins/msd/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ def open(self) -> None:
self.__chip = gpiod.Chip(aiogp.DEVICE_PATH)

self.__target_line = self.__chip.get_line(self.__target_pin)
self.__target_line.request("kvmd::msd-relay::target", gpiod.LINE_REQ_DIR_OUT, default_val=0)
self.__target_line.request("kvmd::msd-relay::target", gpiod.LINE_REQ_DIR_OUT, default_vals=[0])

self.__reset_line = self.__chip.get_line(self.__reset_pin)
self.__reset_line.request("kvmd::msd-relay::reset", gpiod.LINE_REQ_DIR_OUT, default_val=0)
self.__reset_line.request("kvmd::msd-relay::reset", gpiod.LINE_REQ_DIR_OUT, default_vals=[0])

def close(self) -> None:
if self.__chip:
Expand Down
2 changes: 1 addition & 1 deletion kvmd/plugins/ugpio/gpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def prepare(self) -> None:
self.__chip = gpiod.Chip(aiogp.DEVICE_PATH)
for (pin, initial) in self.__output_pins.items():
line = self.__chip.get_line(pin)
line.request("kvmd::ugpio-gpio::outputs", gpiod.LINE_REQ_DIR_OUT, default_val=int(initial or False))
line.request("kvmd::ugpio-gpio::outputs", gpiod.LINE_REQ_DIR_OUT, default_vals=[int(initial or False)])
self.__output_lines[pin] = line

async def run(self) -> None:
Expand Down

0 comments on commit a8589e4

Please sign in to comment.