-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Milestone
Description
Summary
deviceconfiguration.py brute forces GPIO bitmask operations. This should be converted into a pragmatic function to reuse code and make the code cleaner to read.
Problem Explanation
This is being implemented in PR #219 so the link above will only work when that is pulled in. An example of the brute force includes the gpio variable fconfig.get() and fconfig.set() lines. This can be pragmatically cleaned up with a function that can arbitrarily change GPIO P3, GPIO P4, or GPIO P5 values.
# Detect and set GPIO P3 settings, create bitmask
if args.gpiop3on >= 0 and args.gpiop3on <= 7:
if args.gpiop3on is not None:
fconfig.set('BASIC', 'GPIO_P3_' + str(args.gpiop3on), 1)
if args.gpiop3off >= 0 and args.gpiop3off <= 7:
if args.gpiop3off is not None:
fconfig.set('BASIC', 'GPIO_P3_' + str(args.gpiop3off), 0)
gpiomask = [0] * 8
if not args.gpiop3clear:
gpio0 = fconfig.get('BASIC', 'GPIO_P3_0')
gpio1 = fconfig.get('BASIC', 'GPIO_P3_1')
gpio2 = fconfig.get('BASIC', 'GPIO_P3_2')
gpio3 = fconfig.get('BASIC', 'GPIO_P3_3')
gpio4 = fconfig.get('BASIC', 'GPIO_P3_4')
gpio5 = fconfig.get('BASIC', 'GPIO_P3_5')
gpio6 = fconfig.get('BASIC', 'GPIO_P3_6')
gpio7 = fconfig.get('BASIC', 'GPIO_P3_7')
gpiomask = [gpio7, gpio6, gpio5, gpio4, gpio3, gpio2, gpio1, gpio0]
if args.gpiop3clear:
fconfig.set('BASIC', 'GPIO_P3_0', 0)
fconfig.set('BASIC', 'GPIO_P3_1', 0)
fconfig.set('BASIC', 'GPIO_P3_2', 0)
fconfig.set('BASIC', 'GPIO_P3_3', 0)
fconfig.set('BASIC', 'GPIO_P3_4', 0)
fconfig.set('BASIC', 'GPIO_P3_5', 0)
fconfig.set('BASIC', 'GPIO_P3_6', 0)
fconfig.set('BASIC', 'GPIO_P3_7', 0)
gpiop3bitmask = eightBitListToInt(gpiomask)
fconfig.set('BASIC', 'GPIO_P3', gpiop3bitmask)
Environment
Software
Master branch Faraday Software after PR #219 is pulled in.
Hardware
N/A
Supporting Information
N/A
Reactions are currently unavailable