Comments (5)
Okay, so KISS over TCP… that's not something I've tried, although in truth it's definitely something that should be implemented.
I'll have to look at how to achieve this. I don't think using socket
directly is the answer, the aim of aioax25
is to use non-blocking I/O where possible and asyncio
has native support for doing this with TCP connections, so it'd make better sense to use that.
That said, it should still be possible to use the synchronous socket
library directly as you are doing. On Unix-like platforms, there'll be a method there to get the file handle (much like there is on the serial version), and that is what you'll want to pass to the IOLoop
's add_reader
method, so that it can notify the loop that something is waiting to be read.
In your test script, I note you don't seem to create any sort of IOLoop
instance or try to launch any coroutines. I think for something asyncio
based, you need to have an IOLoop
running or else it will just fall though, doing nothing, which is indeed what you are seeing. aioax25
is an asynchronous library, and thus requires an IOLoop
to run to perform its tasks.
This is what I have in my code:
# main.py
def main(): # pragma: no cover
# Okay, this is for pulling settings from a command line and config file… adapt for your needs
ap = argparse.ArgumentParser(description='aioax25 example')
ap.add_argument('config', help='Path to configuration file')
args = ap.parse_args()
config = yaml.load(open(args.config, 'r'))
# Event loop
loop = asyncio.get_event_loop()
# Set up logging
logging.config.dictConfig(config.pop('logging'))
log = logging.getLogger('rfidterm')
log.info('Starting up')
# Set up TNC interface
kiss_port = config['kiss'].pop('port', 0)
kiss = SerialKISSDevice( # in your case, TCPKISSDevice would be used.
loop=loop, log=log.getChild('kiss'),
**config['kiss']
)
kiss.open() # This starts the "open" process, which will continue when the IOLoop is started.
# Set up AX.25 interface
ax25int = AX25Interface(
kissport=kiss[kiss_port],
loop=loop, log=log.getChild('ax25'),
**config.get('ax25', {})
)
# Set up APRS message handler
aprs = APRSInterface(
ax25int,
log=log.getChild('aprs'),
**config['aprs']
)
# Set up digipeating handler (optional)
digi_enable = config.get('digi', {}).pop('enable', False)
digi = APRSDigipeater(log=log.getChild('digi'),
**config.get('digi', {}))
if digi_enable:
digi.connect(aprs)
# Set up signal handlers
def _shutdown():
log.info('Shut-down signal received')
# Do whatever you have to here to clean everything up!
kiss.close()
log.info('Waiting 5 seconds for final shut-down')
loop.call_later(5, loop.stop)
for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGQUIT):
loop.add_signal_handler(sig, _shutdown)
# Enter the event loop
log.info('Entering event loop')
try:
loop.run_forever()
except KeyboardInterrupt:
# Perform whatever shutdown steps needed here.
pass
# in __main__.py
from .main import main
if __name__ == '__main__':
main()
That loop.run_forever()
is the key here… that starts an IOLoop
instance to run continuously; if we get a KeyboardInterrupt
exception; or we receive a suitable signal, we shut everything down (cleanly)… otherwise it just keeps on trucking.
from aioax25.
Ohh, and the above, would use a configuration file that looks like this:
aprs:
mycall: VK4MSL-1
#aprs_path: []
kiss: # here, you would put the parameters used by TCPKISSInterface… in this case, it's a serial interface to a port on a PocketBeagle which connects to a KPC3
device: /dev/ttyS4
baudrate: 9600
# Logging settings
# See https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
logging:
version: 1
formatters:
detail:
format: '%(asctime)s %(name)s[%(filename)s:%(lineno)4d] %(levelname)s %(message)s'
handlers:
console:
formatter: detail
class: logging.StreamHandler
level: DEBUG
stream: ext://sys.stdout
root:
level: DEBUG
handlers:
- console
from aioax25.
Any chance you can do a formal release so I can use aioax25 from pypi with the new tcpkiss support?
from aioax25.
I'll have to schedule some time to give it a shot at some point. The last few weeks have been a bit of a battle getting free time to work on these projects.
from aioax25.
Release 0.0.10 includes these changes.
from aioax25.
Related Issues (14)
- APRS module does not de-duplicate messages HOT 1
- seeing problems decoding aprs packets from direwolf HOT 8
- Error on create HOT 11
- Sending message packet with msg number HOT 10
- queued messages never go out sometimes HOT 6
- SABM and SABME swapped in frame.py HOT 1
- Get official APRS TOCALL allocated
- Exception handling help? HOT 3
- Digipeating should wait a randomised delay before relaying HOT 2
- Handle garbage data at the end of message IDs in APRS messages HOT 1
- `None` being appended to APRS message frames HOT 1
- README is out of date? HOT 2
- sender header callsign gets a * causes aprslib to fail to decode packet HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aioax25.