-139-
v6.3
Interacting with Waspmote
else
{
if (!sd)
{
sd = open(serialPort, O_RDWR | O_NOCTTY | O_NDELAY);
}
//fprintf(stderr,”Serial Port open at: %i\n”, sd);
fcntl(sd, F_SETFL, 0);
}
tcgetattr(sd, &opciones);
cfsetispeed(&opciones, B19200);
cfsetospeed(&opciones, B19200);
opciones.c_cflag |= (CLOCAL | CREAD);
/*No parity*/
opciones.c_cflag &= ~PARENB;
opciones.c_cflag &= ~CSTOPB;
opciones.c_cflag &= ~CSIZE;
opciones.c_cflag |= CS8;
/*raw input:
* making the applycation ready to receive*/
opciones.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
/*Ignore parity errors*/
opciones.c_iflag |= ~(INPCK | ISTRIP | PARMRK);
opciones.c_iflag |= IGNPAR;
opciones.c_iflag &= ~(IXON | IXOFF | IXANY | IGNCR | IGNBRK);
opciones.c_iflag |= BRKINT;
/*raw output
* making the applycation ready to transmit*/
opciones.c_oflag &= ~OPOST;
/*aply*/
tcsetattr(sd, TCSANOW, &opciones);
int j = 0;
while(1)
{
read(sd, &c, 1);
valor[j] = c;
j++;
// We start filling the string until the end of line char arrives
// or we reach the end of the string. Then we write it on the screen.
if ((c==’\n’) || (j==(MAX-1)))
{
int x;
for (x=0; x<j; x++)
{
write(2, &valor[x], 1);
valor[x] = ’\0’;
}
j = 0;
}
}
close(sd);
}
The code can be downloaded from:
Содержание Waspmote
Страница 1: ...Waspmote Technical Guide ...
Страница 11: ... 11 v6 3 Waspmote Kit Connect the battery in Waspmote Connect the sensor board Switch it on ...
Страница 59: ... 59 v6 3 Sensors Vibration Acceleration Free fall ...
Страница 79: ... 79 v6 3 LoRa Figure Channel frequencies in the 868MHz band Figure Channel frequencies in the 900MHz band ...
Страница 98: ... 98 v6 3 RFID NFC ...