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.
|
#define | TIMEOUT 100 |
|
#define | DEFAULT_BAUD 115200 |
|
|
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...
|
|
|
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 |
|
Defines all the functions to connect to a serial USB/serial connection.
- Author
- Marcus Pham
bool SERCheck |
( |
int |
interface | ) |
|
checks and flushes the port by sending enter until seeing prompt
- Parameters
-
interface | the inteface type |
- Returns
- 0 on success, 1 otherwise
int SERClose |
( |
int |
interface | ) |
|
closes the port
- Parameters
-
interface | the inteface type |
- Returns
- 0 on success, 1 otherwise
int SERFlush |
( |
int |
interface | ) |
|
flushes the port
- Parameters
-
interface | the inteface type |
- Returns
- 0 on success, 1 otherwise
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
-
interface | the inteface type |
baud | the baud rate |
handshake | the handshake type |
- Returns
- 0 on success, 1 otherwise
int SERReceive |
( |
int |
interface, |
|
|
char * |
buf |
|
) |
| |
Receives a string from port handle.
- Parameters
-
interface | the inteface type |
buf | the string to store the received bytes |
size | the 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
-
interface | the inteface type |
- Returns
- the character received
int SERSend |
( |
int |
interface, |
|
|
char * |
buf |
|
) |
| |
Sends a string to the given port handle.
- Parameters
-
interface | the inteface type |
buf | the string to send |
size | the 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
-
interface | the inteface type |
ch | the character to send |
- Returns
- 0 on success, 1 otherwise