Hardware Reference
In-Depth Information
Return Value
None.
Example
pinMode(13, OUTPUT);
This sets pin 13 as an output, which can be controlled with digitalWrite.
popen
This function from the C library is available within Galileo to execute a com-
mand in the Linux shell and get its output. See Example 6-3 for more infor-
mation.
Syntax
popen(command, mode);
Parameters
command
The Linux command to execute.
mode
Usually “r” for reading the response from the command, but can also
use “w”.
Return value
A pointer to a file.
Example
int getHours() {
char output[5];
FILE *fp;
fp = popen("curl http://nextmakemagazine.appspot.com/simple", "r");
if (fp == NULL) {
Serial.println("Couldn't run the curl command.");
return -1;
}
else {
fgets(output, sizeof(output), fp);
}
if (pclose(fp) != 0) {
Serial.println("The curl command returned an error.");
return -1;
}
return atoi(output);
}
Search WWH ::




Custom Search