while(TRUE){ f<-file("/dev/ttyUSB0","r+") Sys.sleep(0.1) cat("G0000\n",file=f) Sys.sleep(0.1) d<-scan(f,quiet=TRUE) Sys.sleep(0.1) close(f) Sys.sleep(1) }