I am new to play with LoRaWAN and using Microchip RN 2903 to repeat packet transmission after every minute or two for 30 packets to check the packet delivery rate in the presence of an RF transmitter operating on the same co bands as the end devices. Now, I am using Termite terminal utility to communicate through a serial port to send a packet using the command: mac tx uncnf 1 payload.
I send 30 packets in total with 1 or 2 minutes delay. How can I write a script to automate this transmission so the device keeps on sending messages without my manual issuance of command? Any idea would be appreciated.
Since you really shouldn’t be transmitting that frequently, why should anyone help you?
Perhaps before running experiments you should put some more thought into the nature of this interfering transmitter and why you expect it to be an issue.
We are actually checking the interference of data packet communication with the power of RF chargers in the vicinity to operate on the same frequencies. We are trying to gauge how does it impact the standard communication (in the absence of RF transmitter). Any problem?
why we should not be transmitting as long as we comply with fair access policy?
I would write a python script. What you’re suggesting shouldn’t take more than 40 lines or so.
If you’re developing on a system with linux on it, you probably already have python on it.
I could write a quick example of such a script, maybe I’ll post something later today.
Something like this, I believe the code is self-explaining and should be easy to customise.
By default, it expects to be run on Linux with a USB-serial converter on /dev/ttyUSB0 and as a user which has write access to the serial port (e.g. in ‘dialout’ group). On Windows, I think you can use parameter -s COMx. This depends on python serial port support, so you have to install that too, it’s usually called ‘python3-serial’ I think.
#!/usr/bin/env python3
import time
import argparse
import serial
def send(serialport, bitrate, text, iterations, interval):
print(f'Sending "{text}" with interval {interval} to {serialport} @ {bitrate}"')
with serial.Serial(serialport, bitrate) as ser:
for i in range(iterations):
print(f'Iteration {i}/{iterations}')
ser.write(text.encode('ascii'))
ser.write('\n'.encode('ascii'))
time.sleep(interval)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--serialport", help="The serial port", default="/dev/ttyUSB0")
parser.add_argument("-b", "--bitrate", help="Serial port bit rate", default=57600)
parser.add_argument("-t", "--text", help="The text to send", default="mac tx uncnf 1")
parser.add_argument("-n", "--iterations", help="The number of iterations", default=30)
parser.add_argument("-i", "--interval", help="The poll interval (seconds)", default=10.0)
args = parser.parse_args()
send(args.serialport, args.bitrate, args.text, int(args.iterations), float(args.interval))
if __name__ == "__main__":
main()