Closes #37.
Started with an example mixed together from https://github.com/python-aprs/aprs3 and https://github.com/python-aprs/kiss3/blob/main/examples/tcp_async.py. The `await` was missing from the first example, so beware.
W1CDN
added the bug label 2023-08-26 19:26:28 -05:00
W1CDN
self-assigned this 2023-08-26 19:26:28 -05:00
Got local environment going again and maybe I'll have better luck debugging this. May create another branch to try readme example at https://github.com/python-aprs/aprs3.
Got local environment going again and maybe I'll have better luck debugging this. May create another branch to try readme example at https://github.com/python-aprs/aprs3.
Status
The host cannot ascertain the TNC status, there are no KISS commands that have a response, much less any that provide any known information.
Equally, the TNC cannot ascertain host status.
Well there's your problem:
https://owenduffy.net/blog/?p=2969
```
Status
The host cannot ascertain the TNC status, there are no KISS commands that have a response, much less any that provide any known information.
Equally, the TNC cannot ascertain host status.
```
Wes asked about keepalive on the TCP connection, and I can't see anything like that in the aprs3/kiss3 code, but that doesn't mean it's not another level down from where I'm looking.
But I'm wondering if I could send an empty packet (or one with no path) every x minutes and have that keep the connection alive?
[Wes asked](https://mastodon.radio/@w8wjb@mastodon.hams.social/111558683524663931) about keepalive on the TCP connection, and I can't see anything like that in the aprs3/kiss3 code, but that doesn't mean it's not another level down from where I'm looking.
But I'm wondering if I could send an empty packet (or one with no path) every x minutes and have that keep the connection alive?
But I can't seem to pip3 install the older kiss and aprs packages.
The older version of `kiss` does not use `asyncio` to handle the TCP connection: https://github.com/ampledata/kiss/blob/5c8baba2ceaa97a57fd93cab24a502011fd39e85/kiss/classes.py#L205
I don't know if switching back to this will fix the connection or break other things.
If this `import socket` refers to this, I think keepalive is included? https://docs.python.org/3/library/socket.html
But I can't seem to `pip3 install` the older `kiss` and `aprs` packages.
Started 11:50, seems to have quit/hung ~14:27 CST.
Seems hung after this. Packets came in after this, but nothing in log.
Is it telemetry that is causing issues?
This is where I am using aprslib instead of aprs3 for parsing into tabular format.
Started 11:50, seems to have quit/hung ~14:27 CST.
Seems hung after this. Packets came in after this, but nothing in log.
Is it telemetry that is causing issues?
This is where I am using `aprslib` instead of `aprs3` for parsing into tabular format.


Was fooling around with packages earlier and ran into this again. Had to reinstall stuff in right order, but first delete some things.
```
>~/.local/lib/python3.7/site-packages $ rm -R kiss-7.0.0.dist-info/
>~/.local/lib/python3.7/site-packages $ rm -R kiss3-8.0.0.dist-info/
>~/.local/lib/python3.7/site-packages $ rm -R aprs3-8.0.0.post1.dist-info/
>~/.local/lib/python3.7/site-packages $ pip3 install aprs3 --no-cache-dir
```
Same thing happening this morning. Breaking in between "Parsed ok" and when I attempt to log the
Also need to think about what characters may need to be escaped for SQLite.
Same thing happening this morning. Breaking in between "Parsed ok" and when I attempt to log the

Also need to think about what characters may need to be escaped for SQLite.
Now seeing this?
```
Parsed ok.
Frame could not be parsed.
```

Deployed code is a bit ahead what is in the repo right now.
Adding more errors (I think): https://www.freecodecamp.org/news/python-print-exception-how-to-try-except-print-an-error/
EDIT: Doesn't need to be? https://digi.w1cdn.net/aprs_api/packets?from=N0CBV-2
Example with a single quote? Can it be escaped?
`N0CBV-2>APNU3B,KB0UGF-3,WIDE2-1:!4636.05NS09641.52W#PHG7230W2 MNn Wolverton 932'`
https://stackoverflow.com/questions/3151146/replace-the-single-quote-character-from-a-string
Frame could not be parsed. is an overarching log message I added for failure and includes everything from parsing to DB insertion. It's not very helpful.
this code needs to be restructured, it shouldn't keep trying to put stuff in the database once the packet isn't parsed. Use try except else
try:
try:
a = aprslib.parse(str(frame))
except Exception as error:
logging.error("Error with aprslib:", error)
a['station_call'] = config['Settings']['station_call']
a['station_lat'] = config['Settings']['station_lat']
a['station_lon'] = config['Settings']['station_lon']
a['created_unix'] = int(time.time())
# Make this a string and deal with it later (probably a mistake)
a['path'] = str(a['path'])
if 'subpacket' in a:
a['subpacket'] = str(a['subpacket'])
#logging.debug(a['path'])
# Store true/false as 1/0
if 'alive' in a:
if a['alive'] == True:
a['alive'] = 1
else:
a['alive'] = 0
# Build an INSERT statement based on the fields we have from the frame
attrib_names = ', '.join('"%s"' % w for w in a.keys())
attrib_values = ", ".join("?" * len(a.keys()))
logging.debug(attrib_names)
`Frame could not be parsed.` is an overarching log message I added for failure and includes everything from parsing to DB insertion. It's not very helpful.
- [x] this code needs to be restructured, it shouldn't keep trying to put stuff in the database once the packet isn't parsed. Use `try except else`
https://amiok.net/gitea/W1CDN/aprs_tool/src/branch/fix-kiss/kiss_and_db.py#L75
```
try:
try:
a = aprslib.parse(str(frame))
except Exception as error:
logging.error("Error with aprslib:", error)
a['station_call'] = config['Settings']['station_call']
a['station_lat'] = config['Settings']['station_lat']
a['station_lon'] = config['Settings']['station_lon']
a['created_unix'] = int(time.time())
# Make this a string and deal with it later (probably a mistake)
a['path'] = str(a['path'])
if 'subpacket' in a:
a['subpacket'] = str(a['subpacket'])
#logging.debug(a['path'])
# Store true/false as 1/0
if 'alive' in a:
if a['alive'] == True:
a['alive'] = 1
else:
a['alive'] = 0
# Build an INSERT statement based on the fields we have from the frame
attrib_names = ', '.join('"%s"' % w for w in a.keys())
attrib_values = ", ".join("?" * len(a.keys()))
logging.debug(attrib_names)
```
Logging errors is not working correctly. These show up in the screen -r output, but not in the log file:
Logging errors is not working correctly. These show up in the `screen -r` output, but not in the log file:

Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #37.
Started with an example mixed together from https://github.com/python-aprs/aprs3 and https://github.com/python-aprs/kiss3/blob/main/examples/tcp_async.py. The
awaitwas missing from the first example, so beware.Doesn't seem like
test_async.pyis picking up anything from dw, even though dw reports the connection.Got local environment going again and maybe I'll have better luck debugging this. May create another branch to try readme example at https://github.com/python-aprs/aprs3.
Well there's your problem:
https://owenduffy.net/blog/?p=2969
Wes asked about keepalive on the TCP connection, and I can't see anything like that in the aprs3/kiss3 code, but that doesn't mean it's not another level down from where I'm looking.
But I'm wondering if I could send an empty packet (or one with no path) every x minutes and have that keep the connection alive?
/home/pi/.local/lib/python3.7/site-packages/kiss/classes.pyThe older version of
kissdoes not useasyncioto handle the TCP connection: https://github.com/ampledata/kiss/blob/5c8baba2ceaa97a57fd93cab24a502011fd39e85/kiss/classes.py#L205I don't know if switching back to this will fix the connection or break other things.
If this
import socketrefers to this, I think keepalive is included? https://docs.python.org/3/library/socket.htmlBut I can't seem to
pip3 installthe olderkissandaprspackages.Started 11:50, seems to have quit/hung ~14:27 CST.


Seems hung after this. Packets came in after this, but nothing in log.
Is it telemetry that is causing issues?
This is where I am using
aprslibinstead ofaprs3for parsing into tabular format.Was fooling around with packages earlier and ran into this again. Had to reinstall stuff in right order, but first delete some things.
Turned off periodic restart after the messages this afternoon, see also #37.
Same thing happening this morning. Breaking in between "Parsed ok" and when I attempt to log the

Also need to think about what characters may need to be escaped for SQLite.
Now seeing this?
Deployed code is a bit ahead what is in the repo right now.
Adding more errors (I think): https://www.freecodecamp.org/news/python-print-exception-how-to-try-except-print-an-error/
EDIT: Doesn't need to be? https://digi.w1cdn.net/aprs_api/packets?from=N0CBV-2
Example with a single quote? Can it be escaped?
N0CBV-2>APNU3B,KB0UGF-3,WIDE2-1:!4636.05NS09641.52W#PHG7230W2 MNn Wolverton 932'https://stackoverflow.com/questions/3151146/replace-the-single-quote-character-from-a-string
Frame could not be parsed.is an overarching log message I added for failure and includes everything from parsing to DB insertion. It's not very helpful.try except elsehttps://amiok.net/gitea/W1CDN/aprs_tool/src/branch/fix-kiss/kiss_and_db.py#L75
Logging errors is not working correctly. These show up in the

screen -routput, but not in the log file:Stub out fix-kiss.to Handle breaking errors in kiss_and_db.pyNow that errors are being logged in more detail, I can let this run and see if it keeps working. Then deal with other additions in a different branch.