Output selection
parent
a74e14e6ce
commit
bfc9c945ee
12
loramon
12
loramon
|
@ -526,10 +526,12 @@ def device_probe():
|
||||||
else:
|
else:
|
||||||
raise IOError("Got invalid response while detecting device")
|
raise IOError("Got invalid response while detecting device")
|
||||||
|
|
||||||
|
console_output = False
|
||||||
write_to_disk = False
|
write_to_disk = False
|
||||||
write_dir = None
|
write_dir = None
|
||||||
def packet_captured(data, rnode_instance):
|
def packet_captured(data, rnode_instance):
|
||||||
RNS.log("["+str(rnode_instance.r_stat_rssi)+" dBm] ["+str(len(data))+" bytes]\t"+data.encode("string_escape"));
|
if console_output:
|
||||||
|
RNS.log("["+str(rnode_instance.r_stat_rssi)+" dBm] ["+str(len(data))+" bytes]\t"+data.encode("string_escape"));
|
||||||
if write_to_disk:
|
if write_to_disk:
|
||||||
try:
|
try:
|
||||||
filename = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S.%f")+".pkt"
|
filename = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S.%f")+".pkt"
|
||||||
|
@ -566,10 +568,15 @@ if __name__ == "__main__":
|
||||||
parser.add_argument("port", nargs="?", default=None, help="Serial port where RNode is attached", type=str)
|
parser.add_argument("port", nargs="?", default=None, help="Serial port where RNode is attached", type=str)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.console:
|
||||||
|
console_output = True
|
||||||
|
|
||||||
if args.W:
|
if args.W:
|
||||||
if not os.path.isdir(args.W):
|
if not os.path.isdir(args.W):
|
||||||
try:
|
try:
|
||||||
os.mkdir(args.W)
|
os.mkdir(args.W)
|
||||||
|
write_to_disk = True
|
||||||
|
write_dir = args.W
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not open or create specified directory")
|
RNS.log("Could not open or create specified directory")
|
||||||
else:
|
else:
|
||||||
|
@ -649,6 +656,9 @@ if __name__ == "__main__":
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
RNS.log("RNode in LoRa promiscuous mode and listening")
|
RNS.log("RNode in LoRa promiscuous mode and listening")
|
||||||
|
|
||||||
|
if not args.W and not args.console:
|
||||||
|
RNS.log("Warning! No output destination specified! You won't see any captured packets.")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
raw_input()
|
raw_input()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue