Skip to content

Commit

Permalink
delay for no connection fixed-again and again:)
Browse files Browse the repository at this point in the history
  • Loading branch information
emrekaankocoglu committed Aug 9, 2022
1 parent 5606f47 commit e43c660
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/agent/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
while(input.decode("utf-8"))!="s":
read=read+input.decode("utf-8")
input=ser.read()
if(count==100):
if(count==(timeInterval*10)):
connStatus=checkConnection() #check every 100 cycles the status of the c8y connection
count=0
if((not connStatus) and (count%(timeInterval*10)!=0)):
if((not connStatus) and (count%(timeInterval*5)!=0)):
print("No connection")
else:
ti=datetime.datetime.now().astimezone().replace(microsecond=0).isoformat() #create a measurement with the timestamp as the filename
Expand All @@ -38,7 +38,6 @@
f.close()
base = os.path.splitext(ti+".temp")[0]
os.rename(ti+".temp", base + ".m") #changing the file extension to avoid IO errors
time.sleep(0.1)
count+=1
except:
print("Transmission error, retrying...")
Expand Down

0 comments on commit e43c660

Please sign in to comment.