Sensorian  1.0
C API Reference Guide Library
main.c
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2015 Sensorian
3  * *
4  * This file is part of Sensorian. *
5  * *
6  * Sensorian is free software: you can redistribute it and/or modify it *
7  * under the terms of the GNU Lesser General Public License as published *
8  * by the Free Software Foundation, either version 3 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * Sensorian is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with Sensorian. *
18  * If not, see <http://www.gnu.org/licenses/>. *
19  ****************************************************************************/
20 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include "Serial.h"
32 
33 int main(int argc, char* argv[])
34 {
35  unsigned int ser = SerialOpen(115200); //Open serial port with a 115200 baud rate
36  SerialFlush(ser); //Clear TX and RX buffers
37 
38  SerialPuts(ser,"Serial communication over using the Sensorian Shield.\r\n");
39  SerialPrintf(ser,"You are using device number %d.\r\n",ser);
40 
41  SerialPrintf(ser,"Closing serial port ...");
42  SerialClose(ser); //Close serial port
43 
44  return 0;
45 }
46 
void SerialPuts(int fd, char *s)
Send a string to the serial port.
Definition: Serial.c:157
int SerialOpen(int baud)
Open and initialise the serial port with a specific baud rate.
Definition: Serial.c:51
void SerialClose(int fd)
Closes the serial port characterized by device number fd.
Definition: Serial.c:135
Serial port driver header.
void SerialPrintf(int fd, char const *message,...)
Printf over Serial Port.
Definition: Serial.c:168
int main(int argc, char **argv)
Definition: main.c:34
void SerialFlush(int fd)
Flush the serial buffers (both tx & rx)
Definition: Serial.c:125