diff --git a/pypcc/testing/check_ip.py b/pypcc/testing/check_ip.py index 5dc0e134b299263d3286b660ac35fddfb76f28da..cb8ee62125d05dbd5c5fbf92632c1150f7bf94a0 100644 --- a/pypcc/testing/check_ip.py +++ b/pypcc/testing/check_ip.py @@ -3,20 +3,25 @@ IP_APSCT_TEST='10.99.100.100' #IP_APSCT_subrack='10.99.x.100' import logging -import RPi.GPIO as GPIO import subprocess -def get_LMP_ID(): - pins=[21,20,16,12,7,8] - Npins=len(pins); - GPIO.setmode(GPIO.BCM) - for i,pin in enumerate(pins): - GPIO.setup(pin,GPIO.IN) +try: + from .lmp_id import get_LMP_ID +except: + from lmp_id import get_LMP_ID - value=0; - for pin in pins: - value=2*value+1 if GPIO.input(pin) else 2*value - return value +#import RPi.GPIO as GPIO +#def get_LMP_ID(): +# pins=[21,20,16,12,7,8] +# Npins=len(pins); +# GPIO.setmode(GPIO.BCM) +# for i,pin in enumerate(pins): +# GPIO.setup(pin,GPIO.IN) +# +# value=0; +# for pin in pins: +# value=2*value+1 if GPIO.input(pin) else 2*value +# return value def get_eth0_ip_ifconfig(): result=subprocess.run(['ifconfig','eth0'],stdout=subprocess.PIPE).stdout.decode() diff --git a/pypcc/testing/lmp_id.py b/pypcc/testing/lmp_id.py new file mode 100644 index 0000000000000000000000000000000000000000..c0466c3a389e6f3f01e66d8b03ee76b6eea25ebc --- /dev/null +++ b/pypcc/testing/lmp_id.py @@ -0,0 +1,18 @@ +import RPi.GPIO as GPIO + +def get_LMP_ID(): + pins=[21,20,16,12,7,8] + Npins=len(pins); + GPIO.setmode(GPIO.BCM) + for i,pin in enumerate(pins): + GPIO.setup(pin,GPIO.IN) + + value=0; + for pin in pins: + value=2*value+1 if GPIO.input(pin) else 2*value + return value + +if __name__ in ['__main__','pypcc.testing.lmp_id']: + lmpid=get_LMP_ID() + print(lmpid) + exit(lmpid) diff --git a/setup.cfg b/setup.cfg index a176d71bad9216ec15c3d029657605721bc373b6..7463ac67a3ae651da73a1775c89329915a25e1fb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,7 @@ where=. console_scripts = hwtr = pypcc.pypcc pitr = pypcc.testing.pitr_main + read_lmp_id = pypcc.testing.lmp_id [options.package_data]