Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range in sdr input routine (pocsagDecoder) #111

Open
wattenre opened this issue Sep 13, 2023 · 6 comments
Open

Comments

@wattenre
Copy link

Hello together,

i'm sometimes faced with the following issue:

28.08.2023 08:18:23,683 - MainThread      packet          printInfo          [INFO    ] [pocsag]
28.08.2023 08:18:36,865 - MainThread      bw_client       <module>           [INFO    ] get data from queue (waited 0.004 sec.)
28.08.2023 08:18:36,866 - MainThread      packet          printInfo          [INFO    ] [pocsag]
28.08.2023 08:18:55,987 - inputThread     sdrInput        _runThread         [ERROR   ] error in sdr input routine
Traceback (most recent call last):
  File "/opt/boswatch3/boswatch/inputSource/sdrInput.py", line 65, in _runThread
    self.addToQueue(line)
  File "/opt/boswatch3/boswatch/inputSource/inputBase.py", line 66, in addToQueue
    bwPacket = Decoder.decode(data)
  File "/opt/boswatch3/boswatch/decoder/decoder.py", line 38, in decode
    return PocsagDecoder.decode(data)
  File "/opt/boswatch3/boswatch/decoder/pocsagDecoder.py", line 43, in decode
    message = data.split('Alpha:   ')[1].strip()
IndexError: list index out of range
28.08.2023 08:37:56,114 - inputThread     sdrInput        _runThread         [INFO    ] start decoding
28.08.2023 08:40:42,143 - inputThread     pocsagDecoder   decode             [WARNING ] no valid POCSAG
28.08.2023 08:40:42,155 - MainThread      bw_client       <module>           [INFO    ] get data from queue (waited 0.009 sec.)
28.08.2023 08:40:42,156 - MainThread      packet          printInfo          [INFO    ] [pocsag]

After this occurs, i have to manually restart the client service and everything is fine again.

Is it maybe due to the following code in boswatch/decoder/pocsagDecoder.py:

            if "Alpha:" in data:
                message = data.split('Alpha:   ')[1].strip()

Checking for "Alpha:" is not enough if split function is trying to split 'Alpha: ' (with whitespace)?

Thanks in advance

Greetings René

@Schrolli91
Copy link
Member

Schrolli91 commented Sep 14, 2023

Is a split with whitespaces necessary at all?
.strip() will remove this anywhere, or I am wrong here?

@wattenre Maybe you can try this as following?

if "Alpha:" in data:
    try:
        message = data.split('Alpha:')[1].strip()
    except IndexError:
        logging.warning("index out of range: %s", data)

@wattenre
Copy link
Author

@Schrolli91 Oh, I completely overlooked the "strip" call. You are right, this also removes leading spaces, so your code is the solution.

By the way: The dev channel contains some bugfixes, as I saw. We could merge this in there. Is this currently stable so that I can switch to it without problems?

@Schrolli91
Copy link
Member

As far as i know - the dev should as stable as the master is

@Luflosi
Copy link
Contributor

Luflosi commented Jan 25, 2024

Why was this closed? Looking at the code, this doesn't seem to be fixed yet.

@Schrolli91
Copy link
Member

Schrolli91 commented Jan 25, 2024

You,re right! Sorry for that.
Maybe its possible, that you create a PR for this?

@Schrolli91 Schrolli91 reopened this Jan 25, 2024
@Luflosi
Copy link
Contributor

Luflosi commented Jan 25, 2024

Sure, I can do that when I find some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants