I have multiple Raspberry Pi(RPis) using which I have to send data (wireless,using Long Range modules connected to TX RX of RPi) on just one Rpi.
All the RPis(Ones sending data) use different frequency so I thought that if receiver could switch between these frequencies quickly, they could receive data and hence I used threads to switch the receiver frequencies.
This is the code:
#!/usr/bin/env python import loraset import gatewaydict import lorainit import threading import time def freq1(): while True: loraset.carrierfreq(gatewaydict.freqdict) data = lorainit.ser.read(100) print data return def freq2(): while True: loraset.carrierfreq(gatewaydict.freqdict) data = lorainit.ser.read(100) print data return def callthread(): if gatewaydict.freqdict != 'not assigned': t1 = threading.Thread(target = freq1) t1.start() if gatewaydict.freqdict != 'not assigned': t2 = threading.Thread(target = freq2) t2.start() return
But it shows the following error for each thread individually
1. 'device reports readiness to read but returned no data ' SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
This method has failed, is there some other way to receive the data with above mentioned constraints or can this code be improved to work?