RCOM PROJ
File transfer via serial port
Data_Connection_Protocol

Data Structures

struct  linkLayer
 Struct to hold information about the Link Layer. More...
 

Functions

int llopen (int porta, int type)
 Opens a data connection with the serial port. More...
 
int llwrite (int fd, char *buffer, int lenght)
 Writes the content of buffer to fd. More...
 
int llread (int fd, unsigned char *buffer)
 Reads from fd to buffer. More...
 
int llclose (int fd)
 Closes the connection to the serial port. More...
 

Variables

static struct sigaction old_action
 sigaction to restore SIGALRN handler More...
 
int testSend =0
 
struct linkLayer linkLayer
 Data relative to the link layer. More...
 
struct termios oldtio
 used in llclose to reset termios More...
 
volatile int failed
 used in the alarm handler More...
 

Detailed Description

Function Documentation

◆ llclose()

int llclose ( int  fd)

Closes the connection to the serial port.

Parameters
fddata connection identifier
Returns
int positive value in case of sucess, -1 in case of error

References log_error(), log_success(), old_action, oldtio, RECEIVER, receiver_DISC_UA(), linkLayer::status, TRANSMITTER, and transmitter_DISC_UA().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ llopen()

int llopen ( int  porta,
int  type 
)

Opens a data connection with the serial port.

Parameters
portanumber of the port x in "/dev/ttySx"
typeTRANSMITTER|RECEIVER
Returns
int idata connection identifier or -1 in case of error

References atende(), initConnection(), log_error(), old_action, RECEIVER, receiver_UA(), linkLayer::status, TRANSMITTER, and transmitter_SET().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ llread()

int llread ( int  fd,
unsigned char *  buffer 
)

Reads from fd to buffer.

Parameters
fddata connection identifier
buffercharacter array of received data
Returns
int array's size or -1 in case of error

References A_ER, BCC, C_I, FLAG, log_error(), Read, readingCycle(), readR, linkLayer::sequenceNumber, Start, and stateMachineSetUp().

Referenced by receiverApp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ llwrite()

int llwrite ( int  fd,
char *  buffer,
int  lenght 
)

Writes the content of buffer to fd.

Parameters
fddata connection identifier
buffercharacter array of data to send
lenghtarray's size
Returns
int amount of characters read or -1 in case of error

References A_ER, BCC, C_I, C_RR, fillFinalBuffer(), FLAG, log_error(), MAX_SIZE, linkLayer::sequenceNumber, Start, stateMachineSetUp(), Write, writeCycle(), and writeR.

Referenced by transmitterApp().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ failed

volatile int failed

used in the alarm handler

Referenced by atende(), transmitter_DISC_UA(), transmitter_SET(), and writeCycle().

◆ linkLayer

Data relative to the link layer.

◆ old_action

struct sigaction old_action
static

sigaction to restore SIGALRN handler

Referenced by llclose(), and llopen().

◆ oldtio

struct termios oldtio

used in llclose to reset termios

Referenced by initConnection(), and llclose().

◆ testSend

int testSend =0