From b98dbc71a350ada42869edae7ea94f77771a1da3 Mon Sep 17 00:00:00 2001 From: Alexandre Bard Date: Thu, 13 Jun 2019 13:45:17 +0200 Subject: [PATCH] ublox-config: Use libgpiod for sim switch BugzID: 57325 --- .../ublox-configuration/files/ublox-config.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/recipes-connectivity/ublox-configuration/files/ublox-config.py b/recipes-connectivity/ublox-configuration/files/ublox-config.py index 673d586..2330f32 100755 --- a/recipes-connectivity/ublox-configuration/files/ublox-config.py +++ b/recipes-connectivity/ublox-configuration/files/ublox-config.py @@ -12,14 +12,6 @@ SERIAL_DEV = '/dev/ttyACM0' WWAN_DEV = '/sys/class/net/wwan0' SIM_CONFIG = '/etc/sim.conf' APN_CONFIG = '/etc/apn.conf' -GPIO_PATH = '/sys/class/gpio/' -GPIO_SIM_SW = '44' -APN_CONFIG = '/etc/apn.conf' - -def write_to_file(file, value): - f = open(file, 'w') - f.write(value) - f.close() def execute_and_check(ser, cmd): tries = 0 @@ -40,9 +32,9 @@ def execute_and_check(ser, cmd): tries = 0 def switch_sim(): - write_to_file(GPIO_PATH + 'export', GPIO_SIM_SW) - write_to_file(GPIO_PATH + 'gpio' + GPIO_SIM_SW + '/direction', 'out') - write_to_file(GPIO_PATH + 'gpio' + GPIO_SIM_SW + '/value', '0') + line = gpiod.find_line('SIM_SW') + line.request(consumer='ublox-config', type=gpiod.LINE_REQ_DIR_OUT) + line.set_value(0) def sim_present(ser): cmd = b'AT+CCID?'