Hardware Reference
In-Depth Information
46 for (int i = 0; i < 20; i++)
47 {
48 client = server.accept();
49 if (client)
50 {
51 client.print(dataString);
52 client.stop();
53 }
54 delay(1000);
55 }
56 }
57
58 boolean logResults(String dataString)
59 {
60 File dataFile = FileSystem.open("/mnt/sd/log.txt", FILE_APPEND);
61
62 if (dataFile)
63 {
64 dataFile.println(dataString);
65 dataFile.close();
66 return true;
67 }
68 return false;
69 }
70
71 // This function return a string with the time stamp
72 String getTimeStamp() {
73 Process time; // The process instance
74 String result; // The String the result will be stored to
75
76 time.begin("date"); // The command to run is "date"
77 time.addParameter("+%D-%T"); // The parameters to add
78 time.run(); // Run the command
79
80 delay(50); // Give the instruction some time to run
81
82 // Get the output from the command line
83 while (time.available() > 0) {
84 char c = time.read();
85 if (c != '\n')
86 result += c;
87 }
88
89 return result;
90 }
On lines 1 to 4, you import the necessary header i les. Bridge.h is used for
almost everything on the Arduino Yún. FileIO.h is used for saving data to
the SD card, and YunClient.h and YunServer.h are used to handle client/
Search WWH ::




Custom Search