manu-fwi / openlcb-gateway

Gateway from openlcb to cmri (and more)
GNU General Public License v3.0
3 stars 1 forks source link

RR_duino_net_serial.py: Illegal access to node not in managed_nodes #2

Closed ggee closed 4 years ago

ggee commented 4 years ago

Program crash accessing array element.

Something interesting noticed as well.

show_config= {"ADDRESS": 1, "FULLID": 2002003, "TURNOUTS": [], "VERSION": 1, "SENSORS": [[1, 9, 2], [2, 4, 0]]}
show_config= {"ADDRESS": 2, "FULLID": 2002003, "TURNOUTS": [], "VERSION": 2, "SENSORS": []}

Both these lines use the same FULLID but different content.

Reproduce: power off a node, wait a few seconds, then plug it back in. Does not always occur.

trying to wake dead nodes up dict_items([])
trying to wake dead nodes up dict_items([])
trying to wake dead nodes up dict_items([])
node of address 2 is down
1597183073.906517 1597183074.1066968 2
dict_items([(2002002, <__main__.RR_duino_node object at 0x7696fa90>), (2002003, <__main__.RR_duino_node object at 0x7696faf0>)])
node of address 1 is down
1597183074.1072824 1597183074.3074632 1
dict_items([(2002002, <__main__.RR_duino_node object at 0x7696fa90>)])
trying to wake dead nodes up dict_items([(2002002, <__main__.RR_duino_node object at 0x7696fa90>), (2002003, <__main__.RR_duino_node object at 0x7696faf0>)])
Getting config from node at  2
Sensors list= []
Turnouts list= []
show_config= {"ADDRESS": 2, "FULLID": 2002003, "TURNOUTS": [], "VERSION": 2, "SENSORS": []}
node of address 2 is down
1597183076.4287467 1597183076.6288822 2
dict_items([(2002003, <__main__.RR_duino_node object at 0x7696faf0>)])
trying to wake dead nodes up dict_items([(2002002, <__main__.RR_duino_node object at 0x7696fa90>), (2002003, <__main__.RR_duino_node object at 0x7696faf0>)])
Getting config from node at  1
Sensors list= [(1, 9, 2), (2, 4, 0)]
Turnouts list= []
show_config= {"ADDRESS": 1, "FULLID": 2002003, "TURNOUTS": [], "VERSION": 1, "SENSORS": [[1, 9, 2], [2, 4, 0]]}
node of address 1 is down
1597183081.4469879 1597183081.6471667 1
dict_items([(2002003, <__main__.RR_duino_node object at 0x7696fa90>)])
Traceback (most recent call last):
  File "RR_duino_net_serial.py", line 319, in <module>
    process()
  File "RR_duino_net_serial.py", line 104, in process
    del managed_nodes[ID]
KeyError: 2002002
ggee commented 4 years ago

Issues fixed.