I am designing a simple LoRaWAN UDP server based upon Twisted's plugin method. It gives me different results in two PCs.
- Aliyun ECS, Ubuntu 12.04(32bit), Python 2.7.3, Twisted 15.0.0
- Physical PC, Ubuntu 18.04(64bit), Python 2.7.15, Twisted 17.9.0
I have following plug in trees in my project.
$ tree lorawan_server/
lorawan_server/
├── LoRaWANPktFwd.py
├── run.sh
├── shutdown_twistd.sh
├── start_plugin_twistd.sh
└── twisted
└── plugins
└── LoRaWANPktFwd_plugin.py
LoRaWANPktFwd.py:
#!/usr/bin/env python
#coding: utf-8
from __future__ import print_function
import getopt
import os
import sys
import string
import struct
import binascii
import time
import uuid
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor, protocol, defer
from twisted.python import log
from twisted.enterprise import adbapi
class LoRaWANPktFwd(DatagramProtocol):
def datagramReceived(self, data, addr):
# A simple echo server
self.transport.write(data, addr)
def main():
log.startLogging(sys.stdout)
reactor.listenUDP(1700, LoRaWANPktFwd())
reactor.run()
if __name__ == "__main__":
main()
LoRaWANPktFwd_plugin.py:
from zope.interface import implements
from twisted.application.service import IServiceMaker
from twisted.application import internet
from twisted.plugin import IPlugin
from twisted.python import usage
from LoRaWANPktFwd import LoRaWANPktFwd
class Options(usage.Options):
optParameters = [["port","p", 1700, "The port number to listen on."]]
class LoRaWANPktFwdServiceMaker(object):
implements(IServiceMaker, IPlugin)
tapname = "LoRaWAN"
description = "A Raw UDP-based LoRaWAN Packet Forwarder server."
options = Options
def makeService(self, options):
return internet.UDPServer(int(options["port"]), LoRaWANPktFwd())
serviceMaker = LoRaWANPktFwdServiceMaker()
If I type:
twistd LoRaWAN
then Ubuntu 18.04 will complain following:
/usr/bin/twistd: Unknown command: LoRaWAN
And Ubuntu 12.04 will start to run, with twistd.pid and twistd.log created in same folder.
I have no idea why this happens. Any plugin update in latest twisted? or is it related to systemd or something?