RCOM PROJ
File transfer via serial port
Data_Connection_Protocol_Specification

Enumerations

enum  readingType { openR, readR, closeDISC, closeUA }
 
enum  writingType { trans_SET, writeR, trans_DISC_UA }
 

Functions

int readingCycle (enum readingType type, int fd, unsigned char *c, unsigned char **dataBuf, int *retBufferSize)
 Function to read a byte from fd. More...
 
int writeCycle (enum writingType type, int fd, unsigned char *buf, int bufsize)
 Function used to write to fd. More...
 
int initConnection (int *fd, char *port)
 Estabelece ligação ao cabo e cria fd. More...
 
void atende ()
 Função handler do sinal de alarme. More...
 
int transmitter_SET (int fd)
 Função que envia Trama SET e recebe trama UA. More...
 
int receiver_UA (int fd)
 Função que recebe trama SET e envia trama UA. More...
 
int fillFinalBuffer (unsigned char *finalBuffer, unsigned char *headerBuf, unsigned char *footerBuf, int footerBufSize, unsigned char *dataBuffer, int dataSize)
 Stuffs the final buffer with the Information Packet. More...
 
int transmitter_DISC_UA (int fd)
 Transmitter sequence to Disconnect. More...
 
int receiver_DISC_UA (int fd)
 Receiver sequence to Disconnect. More...
 
void generateErrorBCC2 (unsigned char *frame, int frameSize)
 Generates a error on BCC2 based on PROBABILITY_BCC2. More...
 
void generateErrorBCC1 (unsigned int *checkBuffer)
 Generates a error on BCC based on PROBABILITY_BCC2. More...
 

Variables

int testSend1 =0
 

Detailed Description

Enumeration Type Documentation

◆ readingType

Enumerator
openR 
readR 
closeDISC 
closeUA 

◆ writingType

Enumerator
trans_SET 
writeR 
trans_DISC_UA 

Function Documentation

◆ atende()

void atende ( )

Função handler do sinal de alarme.

References DONE, failed, log_caution(), stateMachineParams::state, state_machine, and TRUE.

Referenced by llopen().

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

◆ fillFinalBuffer()

int fillFinalBuffer ( unsigned char *  finalBuffer,
unsigned char *  headerBuf,
unsigned char *  footerBuf,
int  footerBufSize,
unsigned char *  dataBuffer,
int  dataSize 
)

Stuffs the final buffer with the Information Packet.

Parameters
finalBufferpointer to the Information buffer
headerBufpointer to the header buffer [FLAG, A, C, BCC1]
footerBufpointer to the footer buffer [BCC2, FLAG]
footerBufSizesize of footer buffer
dataBufferpointer to the Data Buffer [D1, D2, ..., Dn]
dataSizesize of Data Buffer
Returns
int size of finalBuffer

Referenced by llwrite().

Here is the caller graph for this function:

◆ generateErrorBCC1()

void generateErrorBCC1 ( unsigned int *  checkBuffer)

Generates a error on BCC based on PROBABILITY_BCC2.

Parameters
checkBufferBuffer with Address Byte and Control Byte to generate error on

References checkBuffer, log_message(), and PROBABILITY_BCC1.

Referenced by processC_RCV().

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

◆ generateErrorBCC2()

void generateErrorBCC2 ( unsigned char *  frame,
int  frameSize 
)

Generates a error on BCC2 based on PROBABILITY_BCC2.

Parameters
frameframe to generate error on
frameSizesize of frame

References log_message(), and PROBABILITY_BCC2.

Referenced by processBCC_OK().

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

◆ initConnection()

int initConnection ( int *  fd,
char *  port 
)

Estabelece ligação ao cabo e cria fd.

Parameters
fdfile descriptor da ligação
port"/dev/ttySx"

References ATTEMPTS, BAUDRATE, linkLayer::baudRate, log_error(), log_success(), linkLayer::numTransmissions, oldtio, linkLayer::port, linkLayer::sequenceNumber, TIME_OUT, and linkLayer::timeout.

Referenced by llopen().

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

◆ readingCycle()

int readingCycle ( enum readingType  type,
int  fd,
unsigned char *  c,
unsigned char **  dataBuf,
int *  retBufferSize 
)

Function to read a byte from fd.

Parameters
typevariable to distinguish warning messages
fdfile descriptor
ccontroll byte, used with type readR
dataBufbuffer to read data, used with type readR
retBufferSizevariable to store dataBuf size, used with type readR
Returns
int

References C_REJ, C_RR, closeDISC, closeUA, DONE, FALSE, log_caution(), log_error(), openR, readR, linkLayer::sequenceNumber, stateMachineParams::state, state_machine, stateMachine(), and TRUE.

Referenced by llread(), receiver_DISC_UA(), and receiver_UA().

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

◆ receiver_DISC_UA()

int receiver_DISC_UA ( int  fd)

Receiver sequence to Disconnect.

Parameters
fdfile descriptor ot the connection
Returns
int -1 in case of errors, 0 otherwise

References A_ER, A_RE, BCC, C_DISC, C_UA, closeDISC, FLAG, log_error(), readingCycle(), Start, stateMachineSetUp(), SU_FRAME_SIZE, Supervision, and linkLayer::timeout.

Referenced by llclose().

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

◆ receiver_UA()

int receiver_UA ( int  fd)

Função que recebe trama SET e envia trama UA.

Parameters
fdidentificador da ligação de dados
Returns
int identificador da ligação de dados OU -1 em caso de erro

References A_ER, BCC, C_SET, C_UA, FLAG, log_error(), openR, readingCycle(), Start, stateMachineSetUp(), SU_FRAME_SIZE, and Supervision.

Referenced by llopen().

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

◆ transmitter_DISC_UA()

int transmitter_DISC_UA ( int  fd)

Transmitter sequence to Disconnect.

Parameters
fdfile descriptor ot the connection
Returns
int -1 in case of errors, 0 otherwise

References A_ER, A_RE, BCC, C_DISC, C_UA, failed, FLAG, log_error(), Start, stateMachineSetUp(), SU_FRAME_SIZE, Supervision, trans_DISC_UA, TRUE, and writeCycle().

Referenced by llclose().

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

◆ transmitter_SET()

int transmitter_SET ( int  fd)

Função que envia Trama SET e recebe trama UA.

Parameters
fdidentificador da ligação de dados
Returns
int identificador da ligação de dados OU -1 em caso de erro

References A_ER, BCC, C_SET, C_UA, failed, FLAG, log_error(), Start, stateMachineSetUp(), SU_FRAME_SIZE, Supervision, trans_SET, TRUE, and writeCycle().

Referenced by llopen().

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

◆ writeCycle()

int writeCycle ( enum writingType  type,
int  fd,
unsigned char *  buf,
int  bufsize 
)

Function used to write to fd.

Parameters
typevariable to distinguish warning messages
fdfile descriptor
bufbuffer of content to write
bufsizelenght of buffer in bytes
Returns
int negative in case of errors, 0 otherwise

References DONE, failed, FALSE, log_caution(), log_error(), linkLayer::numTransmissions, Start, stateMachineParams::state, state_machine, stateMachine(), linkLayer::timeout, trans_DISC_UA, trans_SET, TRUE, and writeR.

Referenced by llwrite(), transmitter_DISC_UA(), and transmitter_SET().

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

Variable Documentation

◆ testSend1

int testSend1 =0