Welcome to the EyeBot  Version 7 - RPi1
A Controller For Various Hardware IO
Functions
serial.c File Reference

Defines functions to communicate via serial. More...

#include "serial.h"
#include <stdlib.h>

Functions

int SERGetPaths ()
 Obtains the system paths to the serial usb devices matching description in hdt.txt. More...
 
int set_interface_attribs (int fd, int speed, int parity, int handshake)
 sets the attributes for the port More...
 
void set_blocking (int fd, int should_block)
 Sets the blocking flags for the serial port. More...
 
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 *buf)
 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...
 

Detailed Description

Defines functions to communicate via serial.

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
void set_blocking ( int  fd,
int  should_block 
)

Sets the blocking flags for the serial port.

Parameters
fdthe port handle
should_blockan boolean whether to block port or not
int set_interface_attribs ( int  fd,
int  speed,
int  parity,
int  handshake 
)

sets the attributes for the port

Parameters
fdthe port handle
speedthe baud rate
paritythe parity of the port
handshakethe handshake type
Returns
0 on success, -1 otherwise