RCOM PROJ
File transfer via serial port
dcp_spec.h
Go to the documentation of this file.
1 
4 #ifndef PLD_SPEC_HEADER
5 #define PLD_SPEC_HEADER
6 
7 #include "dcp.h"
8 
9 enum readingType {openR, readR, closeDISC, closeUA}; // Enum of possible modifications to readingCycle()
10 enum writingType {trans_SET, writeR, trans_DISC_UA}; // Enum of possible modifications to writeCycle()
11 
22 int readingCycle(enum readingType type, int fd, unsigned char *c, unsigned char **dataBuf, int *retBufferSize);
32 int writeCycle(enum writingType type, int fd, unsigned char *buf, int bufsize);
33 
40 int initConnection(int *fd, char *port);
45 void atende();
52 int transmitter_SET(int fd);
59 int receiver_UA(int fd);
60 
72 int fillFinalBuffer(unsigned char* finalBuffer, unsigned char* headerBuf, unsigned char* footerBuf, int footerBufSize, unsigned char* dataBuffer, int dataSize);
73 
80 int transmitter_DISC_UA(int fd);
81 
88 int receiver_DISC_UA(int fd);
89 
96 void generateErrorBCC2(unsigned char *frame, int frameSize);
97 
103 void generateErrorBCC1(unsigned int *checkBuffer);
104 
105 #endif // PLD_SPEC_HEADER
106 
TRUE
#define TRUE
Definition: macros.h:41
readingType
readingType
Definition: dcp_spec.h:9
FALSE
#define FALSE
Definition: macros.h:40
stateMachineSetUp
void stateMachineSetUp(unsigned char control, unsigned char address, enum stateMachineState state, enum stateMachineType type)
Function to easily change the State Machine.
Definition: statemachine.c:9
Start
@ Start
Definition: statemachine.h:12
trans_DISC_UA
@ trans_DISC_UA
Definition: dcp_spec.h:10
oldtio
struct termios oldtio
used in llclose to reset termios
Definition: dcp.h:39
C_DISC
#define C_DISC
(0x0B) Campo de Controlo - DISC (disconnect)
Definition: macros.h:31
A_ER
#define A_ER
(0x03) Campo de Endereço (A) de commandos do Emissor, resposta do Receptor
Definition: macros.h:27
log_caution
void log_caution(char *arr)
Outputs a message in yellow.
Definition: logs.c:13
C_RR
#define C_RR(r)
(0x05 OU 0x85) Campo de Controlo - RR (receiver ready / positive ACK))
Definition: macros.h:33
receiver_UA
int receiver_UA(int fd)
Função que recebe trama SET e envia trama UA.
Definition: dcp_spec.c:237
transmitter_SET
int transmitter_SET(int fd)
Função que envia Trama SET e recebe trama UA.
Definition: dcp_spec.c:223
transmitter_DISC_UA
int transmitter_DISC_UA(int fd)
Transmitter sequence to Disconnect.
Definition: dcp_spec.c:277
closeDISC
@ closeDISC
Definition: dcp_spec.h:9
dcp_spec.h
atende
void atende()
Função handler do sinal de alarme.
Definition: dcp_spec.c:215
state_machine
struct stateMachineParams state_machine
Definition: statemachine.h:24
BAUDRATE
#define BAUDRATE
Definition: macros.h:9
DONE
@ DONE
Definition: statemachine.h:12
BCC
#define BCC(a, c)
XOR entre a e c.
Definition: macros.h:37
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.
Definition: dcp_spec.c:257
writeCycle
int writeCycle(enum writingType type, int fd, unsigned char *buf, int bufsize)
Function used to write to fd.
Definition: dcp_spec.c:72
initConnection
int initConnection(int *fd, char *port)
Estabelece ligação ao cabo e cria fd.
Definition: dcp_spec.c:178
TIME_OUT
#define TIME_OUT
Definition: macros.h:10
openR
@ openR
Definition: dcp_spec.h:9
receiver_DISC_UA
int receiver_DISC_UA(int fd)
Receiver sequence to Disconnect.
Definition: dcp_spec.c:300
C_UA
#define C_UA
(0x07) Campo de Controlo - UA (Unnumbered Acknowledgement)
Definition: macros.h:32
FLAG
#define FLAG
(0x7E) flag de inicio e fim
Definition: macros.h:25
failed
volatile int failed
used in the alarm handler
Definition: dcp.h:40
dcp.h
log_message
void log_message(char *arr)
Outputs a message in white.
Definition: logs.c:25
C_SET
#define C_SET
(0x03) Campo de Controlo - SET (set up)
Definition: macros.h:30
writingType
writingType
Definition: dcp_spec.h:10
log_error
void log_error(char *arr)
Outputs a message in red.
Definition: logs.c:7
generateErrorBCC2
void generateErrorBCC2(unsigned char *frame, int frameSize)
Generates a error on BCC2 based on PROBABILITY_BCC2.
Definition: dcp_spec.c:328
A_RE
#define A_RE
(0x01) Campo de Endereço (A) de commandos do Receptor, resposta do Emissor
Definition: macros.h:28
generateErrorBCC1
void generateErrorBCC1(unsigned int *checkBuffer)
Generates a error on BCC based on PROBABILITY_BCC2.
Definition: dcp_spec.c:339
stateMachineParams::state
enum stateMachineState state
Definition: statemachine.h:20
C_REJ
#define C_REJ(r)
(0x01 OU 0x81) Campo de Controlo - REJ (reject / negative ACK))
Definition: macros.h:34
readingCycle
int readingCycle(enum readingType type, int fd, unsigned char *c, unsigned char **dataBuf, int *retBufferSize)
Function to read a byte from fd.
Definition: dcp_spec.c:7
log_success
void log_success(char *arr)
Outputs a message in green.
Definition: logs.c:19
trans_SET
@ trans_SET
Definition: dcp_spec.h:10
ATTEMPTS
#define ATTEMPTS
Definition: macros.h:11
checkBuffer
static unsigned checkBuffer[2]
Definition: statemachine.c:6
Supervision
@ Supervision
Definition: statemachine.h:11
writeR
@ writeR
Definition: dcp_spec.h:10
PROBABILITY_BCC1
#define PROBABILITY_BCC1
Definition: macros.h:16
SU_FRAME_SIZE
#define SU_FRAME_SIZE
Enum com Valores para a Máquina de Estados de SET-UA.
Definition: macros.h:23
PROBABILITY_BCC2
#define PROBABILITY_BCC2
Definition: macros.h:15
readR
@ readR
Definition: dcp_spec.h:9
stateMachine
int stateMachine(unsigned char byte, unsigned char **buf, int *size)
The StateMachine function that processes a byte and updates it's state.
Definition: statemachine.c:16
testSend1
int testSend1
Definition: dcp_spec.c:5
closeUA
@ closeUA
Definition: dcp_spec.h:9