Skip to content

Python error: Line36: IndexError: list index out of range #12

Description

@christophernies

[nies@localhost RaspberryPi]$ python serial_test.py
{'node_readings': [{'soil2': '1.3', 'soil3': '1.4', 'soil1': '[RF12demo.10] _ i31 g2 @ 915 MHz ', 'voltage': '1.4', 'temp': '58', 'timestamp': '2013-12-08 12:30:02', 'id': '1', 'channel': '001'}], 'site_id': '1'}
{'node_readings': [{'soil2': '1.3', 'soil3': '1.4', 'soil1': '0.00', 'voltage': '1.4', 'temp': '58', 'timestamp': '2013-12-08 12:30:14', 'id': '1', 'channel': '001'}], 'site_id': '1'}
{'node_readings': [{'soil2': '1.3', 'soil3': '1.4', 'soil1': '0.00', 'voltage': '1.4', 'temp': '58', 'timestamp': '2013-12-08 12:30:24', 'id': '1', 'channel': '001'}], 'site_id': '1'}
{'node_readings': [{'soil2': '1.3', 'soil3': '1.4', 'soil1': '142.00', 'voltage': '1.4', 'temp': '58', 'timestamp': '2013-12-08 12:30:35', 'id': '1', 'channel': '001'}], 'site_id': '1'}
{'node_readings': [{'soil2': '1.3', 'soil3': '1.4', 'soil1': '0.00', 'voltage': '1.4', 'temp': '58', 'timestamp': '2013-12-08 12:30:45', 'id': '1', 'channel': '001'}], 'site_id': '1'}
{'node_readings': [{'soil2': '1.3', 'soil3': '1.4', 'soil1': '0.00', 'voltage': '1.4', 'temp': '58', 'timestamp': '2013-12-08 12:30:56', 'id': '1', 'channel': '001'}], 'site_id': '1'}
{'node_readings': [{'soil2': '1.3', 'soil3': '1.4', 'soil1': '0.00', 'voltage': '1.4', 'temp': '58', 'timestamp': '2013-12-08 12:31:07', 'id': '1', 'channel': '001'}], 'site_id': '1'}
{'node_readings': [{'soil2': '1.3', 'soil3': '1.4', 'soil1': '370.00', 'voltage': '1.4', 'temp': '58', 'timestamp': '2013-12-08 12:31:17', 'id': '1', 'channel': '001'}], 'site_id': '1'}
Traceback (most recent call last):
File "serial_test.py", line 36, in
sensorData = analog[1].rstrip('\r\n')
IndexError: list index out of range

I believe this is occurring when the python script grabs a line from the JeeLink that does not contain any data.

I need to look into filtering out JeeLink lines that don't contain sensor data. Maybe we can generate a .log file with everything, and then only attempt to upload JeeLink lines we know contain valid data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions