driver spb16ch: corretto sistema di attivazione schede
This commit is contained in:
@@ -59,7 +59,7 @@ function drv_spb16ch_init {
|
||||
echo "******** Number used board: $board_id - inizializzazione gpio $gpio_n"
|
||||
$GPIO -g mode $gpio_n out
|
||||
done
|
||||
drv_spb16ch_board_disable_all
|
||||
#drv_spb16ch_board_disable_all
|
||||
|
||||
# Esegue l'inizializzazione delle schede spb16ch trovate
|
||||
local address_num=""
|
||||
@@ -68,14 +68,16 @@ function drv_spb16ch_init {
|
||||
do
|
||||
address_num=${address_used[$i]}
|
||||
board_num=${SPB16CH_USED_ID[$i]}
|
||||
drv_spb16ch_board_enable $board_num
|
||||
drv_spb16ch_board_enable $board_num # Porto alto il reset della scheda e lo mantengo sempre alto
|
||||
echo "****** Inizializzazione address_num = $address_num - board_num = $board_num *******"
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num 0
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/gpo_init.py 25 255 0
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num 1
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/gpo_init.py 25 255 0
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num 0
|
||||
drv_spb16ch_board_disable $board_id
|
||||
# Disabilito il mux
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/mux_disable.py $address_num
|
||||
#drv_spb16ch_board_disable $board_id
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ function drv_spb16ch_rele_open {
|
||||
local rele_num=${rele_data:5:3}
|
||||
local board_id=${rele_data:9:1}
|
||||
|
||||
drv_spb16ch_board_enable $board_id
|
||||
#drv_spb16ch_board_enable $board_id
|
||||
|
||||
echo address_num=$address_num
|
||||
echo channel_num=$channel_num
|
||||
@@ -35,7 +35,9 @@ function drv_spb16ch_rele_open {
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num $channel_num
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/gpo_init.py $address_num $rele_num 0
|
||||
|
||||
drv_spb16ch_board_disable $board_id
|
||||
# Disabilito il mux
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/mux_disable.py $address_num
|
||||
#drv_spb16ch_board_disable $board_id
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +60,7 @@ function drv_spb16ch_rele_close {
|
||||
local rele_num=${rele_data:5:3}
|
||||
local board_id=${rele_data:9:1}
|
||||
|
||||
drv_spb16ch_board_enable $board_id
|
||||
#drv_spb16ch_board_enable $board_id
|
||||
|
||||
echo address_num=$address_num
|
||||
echo channel_num=$channel_num
|
||||
@@ -66,7 +68,9 @@ function drv_spb16ch_rele_close {
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num $channel_num
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/gpo_init.py $address_num $rele_num 1
|
||||
|
||||
drv_spb16ch_board_disable $board_id
|
||||
# Disabilito il mux
|
||||
$DIR_SCRIPT/drv/spb16ch/scripts/mux_disable.py $address_num
|
||||
#drv_spb16ch_board_disable $board_id
|
||||
|
||||
}
|
||||
|
||||
|
||||
37
drv/spb16ch/scripts/mux_disable.py
Executable file
37
drv/spb16ch/scripts/mux_disable.py
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/python
|
||||
# coding=utf-8
|
||||
|
||||
# Disable PCA9547 I2C multiplexer
|
||||
# I2C Address: 0xYY, where YY can be 70 through 77
|
||||
# sudo ./mux_channel.py ADDRESS CHANNEL
|
||||
# Example: sudo ./mux_disable.py 70
|
||||
|
||||
import time
|
||||
import argparse
|
||||
|
||||
import RPi.GPIO as GPIO
|
||||
import smbus
|
||||
|
||||
def I2C_setup(multiplexer_i2c_address):
|
||||
I2C_address = 0x70 + multiplexer_i2c_address % 10
|
||||
if GPIO.RPI_REVISION in [2, 3]:
|
||||
I2C_bus_number = 1
|
||||
else:
|
||||
I2C_bus_number = 0
|
||||
|
||||
bus = smbus.SMBus(I2C_bus_number)
|
||||
i2c_channel_setup=0x00
|
||||
#i2c_channel_setup=i2c_channel_setup + 0x08
|
||||
bus.write_byte(I2C_address, i2c_channel_setup)
|
||||
#time.sleep(0.1)
|
||||
|
||||
def menu():
|
||||
parser = argparse.ArgumentParser(description='Select Address of Disable PCA9547 Multiplexer')
|
||||
parser.add_argument('address', type=int)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
I2C_setup(args.address)
|
||||
|
||||
if __name__ == "__main__":
|
||||
menu()
|
||||
Reference in New Issue
Block a user