controller.py AttributeError: 'bound_method' object has no attribute 'low'
davefes opened this issue · 5 comments
When I tried your suggestion in issue:
#14
to toggle reset pin (connected with all transceivers):
controller.reset_pin(controller.pin_reset)then transceiver.init()
I get:
File "controller.py", line 120, in reset_pin
AttributeError: 'bound_method' object has no attribute 'low'
Not sure how you came into this.
You may need to trace controller.py:line37
-> controller_esp.py:line49
.
I came into it by adding those lines to your LoRaReceiver.py example:
controller = config_lora.Controller()
#controller.reset_pin(controller.reset_pin)
#transceiver.init()
lora = controller.add_transceiver(sx127x.SX127x(name = 'LoRa'),
pin_id_ss = config_lora.Controller.PIN_ID_FOR_LORA_SS,
pin_id_RxDone = config_lora.Controller.PIN_ID_FOR_LORA_DIO0)
receive(lora)
I am not a Python expert but at line 57 in controller_esp.py I see:
if in_out == Pin.OUT:
new_pin.low = lambda : pin.value(0)
new_pin.high = lambda : pin.value(1)
else:
new_pin.irq = pin.irq
Does controller.py recognise low and high?
new_pin
is a Python mock object for attaching the low
lambda function.
pin
is a MicroPython machine.Pin object.
So, new_pin.low()
=== pin.value(0)
You had the error because it should be controller.reset_pin(controller.pin_reset)
.
O dear, I should have done a copy/paste! Thank you for pointing out my error.
Just to clarify in the example LoRaReceiver.py and when you want to reset the SX127x:
controller = config_lora.Controller()
controller.reset_pin(controller.pin_reset)
# transceiver.init() is run when you do controller.add_transceiver()
lora = controller.add_transceiver(sx127x.SX127x(name = 'LoRa'),
pin_id_ss = config_lora.Controller.PIN_ID_FOR_LORA_SS,
pin_id_RxDone = config_lora.Controller.PIN_ID_FOR_LORA_DIO0)
receive(lora)