Welcome to the EyeBot  Version 7 - RPi1
A Controller For Various Hardware IO
Macros | Functions | Variables
serial.h File Reference

Defines all the functions to connect to a serial USB/serial connection. More...

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <time.h>
#include <stdbool.h>
#include "types.h"
#include "system.h"

Go to the source code of this file.

Macros

#define TIMEOUT   100
 
#define DEFAULT_BAUD   115200
 

Functions

int SERInit (int interface, int baud, int handshake)
 Initialises the port. More...
 
int SERSendChar (int interface, char ch)
 Sends a single character to the given port handle. More...
 
int SERSend (int interface, char *buf)
 Sends a string to the given port handle. More...
 
int SERReceive (int interface, char *ch)
 Receives a string from port handle. More...
 
char SERReceiveChar (int interface)
 Receives a single character from the given port handle. More...
 
bool SERCheck (int interface)
 checks and flushes the port by sending enter until seeing prompt More...
 
int SERFlush (int interface)
 flushes the port More...
 
int SERClose (int interface)
 closes the port More...
 
int SERGetPaths ()
 Obtains the system paths to the serial usb devices matching description in hdt.txt. More...
 

Variables

char USBPATH1 [HDT_MAX_PATHCHAR]
 
char USBPATH2 [HDT_MAX_PATHCHAR]
 
char USBPATH3 [HDT_MAX_PATHCHAR]
 
char USBPATH4 [HDT_MAX_PATHCHAR]
 
int SERPathInit
 
int SERType
 
int SERBaud [5]
 
int SERHandshake [5]
 
int fd
 

Detailed Description

Defines all the functions to connect to a serial USB/serial connection.

Author
Marcus Pham

Function Documentation

bool SERCheck ( int  interface)

checks and flushes the port by sending enter until seeing prompt

Parameters
interfacethe inteface type
Returns
0 on success, 1 otherwise
int SERClose ( int  interface)

closes the port

Parameters
interfacethe inteface type
Returns
0 on success, 1 otherwise
int SERFlush ( int  interface)

flushes the port

Parameters
interfacethe inteface type
Returns
0 on success, 1 otherwise
int SERGetPaths ( )

Obtains the system paths to the serial usb devices matching description in hdt.txt.

Returns
0 on success, 1 on failure/alerady initialised
int SERInit ( int  interface,
int  baud,
int  handshake 
)

Initialises the port.

Parameters
interfacethe inteface type
baudthe baud rate
handshakethe handshake type
Returns
0 on success, 1 otherwise
int SERReceive ( int  interface,
char *  buf 
)

Receives a string from port handle.

Parameters
interfacethe inteface type
bufthe string to store the received bytes
sizethe length of the string to receive
Returns
n the length of the received string
char SERReceiveChar ( int  interface)

Receives a single character from the given port handle.

Parameters
interfacethe inteface type
Returns
the character received
int SERSend ( int  interface,
char *  buf 
)

Sends a string to the given port handle.

Parameters
interfacethe inteface type
bufthe string to send
sizethe length of the string to send
Returns
0 on success, 1 otherwise
int SERSendChar ( int  interface,
char  ch 
)

Sends a single character to the given port handle.

Parameters
interfacethe inteface type
chthe character to send
Returns
0 on success, 1 otherwise