Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import time
import arq
listdata = ['this ', 'is', ' a', ' test', '.']
def transmitroutine(data):
print "Transmitting: ", data
# Create object
testtxsm = arq.TransmitArqStateMachine(listdata, transmitroutine)
# Insert new data
testtxsm.newdataqueue(listdata)
time.sleep(6)
testtxsm.ackreceived()
time.sleep(2)
testtxsm.ackreceived()
####################################
## Receive
##################################
# Create object
testrxsm = arq.ReceiveArqStateMachine(rx_transmitroutine, rx_receiveroutine)
# Set state machine to START
testrxsm.updatestate(arq.STATE_START)
####################################
## Transmit
##################################
# Create object
testtxsm = arq.TransmitArqStateMachine(tx_transmitroutine, tx_receiveroutine)
####################################
## Operations
##################################
print "Sleeping prior to transmit"
time.sleep(4)
# Insert new data for transmit
testtxsm.newdataqueue(tx_listdata)
return rx_item['message']
###################################
config = ConfigParser.RawConfigParser()
filename = os.path.abspath("hermes.ini")
config.read(filename)
localcallsign = config.get('UNIT0', 'CALLSIGN')
localnodeid = int(config.get('UNIT0', 'NODEID'))
destinationcallsign = config.get('UNIT1', 'CALLSIGN')
destinationnodeid = int(config.get('UNIT1', 'NODEID'))
# Create ARQ Transmit object
testtxsm = arq.TransmitArqStateMachine(tx_transmitroutine, tx_receiveroutine)
def getrxqueuesize(callsign, nodeid):
"""
:param callsign: Callsign of the local device being queried
:param nodeid: Node ID of the local device being queried
:return: The RX queue size
"""
payload = {'localcallsign': callsign, 'localnodeid': int(nodeid)}
queuelen = requests.get('http://127.0.0.1:8005/queuelen', params=payload)
queuesize = json.loads(base64.b64decode(queuelen.json()))
return queuesize['queuesize']
def main():