RCOM PROJ
File transfer via serial port
State_Machine

Data Structures

struct  stateMachineParams
 List of Parameters to Personalize the State Machine. More...
 

Enumerations

enum  stateMachineType { Supervision, Write, Read }
 
enum  stateMachineState {
  Start, FLAG_RCV, A_RCV, C_RCV,
  BCC_OK, DONE
}
 

Functions

void stateMachineSetUp (unsigned char control, unsigned char address, enum stateMachineState state, enum stateMachineType type)
 Function to easily change the State Machine. More...
 
int stateMachine (unsigned char byte, unsigned char **buf, int *size)
 The StateMachine function that processes a byte and updates it's state. More...
 
int processStart (unsigned char byte)
 Function to process a byte in case the state is Start. More...
 
int processFLAG_RCV (unsigned char byte)
 Function to process a byte in case the state is FLAG_RCV. More...
 
int processA_RCV (unsigned char byte)
 Function to process a byte in case the state is A_RCV. More...
 
int processC_RCV (unsigned char byte)
 Function to process a byte in case the state is C_RCV. More...
 
int processBCC_OK (unsigned char byte, unsigned char **buffer, int *buffersize)
 Function to process a byte in case the state is BCC_OK. More...
 

Variables

static unsigned checkBuffer [2]
 
static int frameIndex
 
static int wrongC
 
struct stateMachineParams state_machine
 

Detailed Description

Enumeration Type Documentation

◆ stateMachineState

Enumerator
Start 
FLAG_RCV 
A_RCV 
C_RCV 
BCC_OK 
DONE 

◆ stateMachineType

Enumerator
Supervision 
Write 
Read 

Function Documentation

◆ processA_RCV()

int processA_RCV ( unsigned char  byte)

Function to process a byte in case the state is A_RCV.

Parameters
bytebyte to be processed
Returns
int negative value in case of error, 0 otherwise

References C_I, C_RCV, C_REJ, checkBuffer, stateMachineParams::control, FLAG, FLAG_RCV, frameIndex, log_caution(), log_error(), Read, linkLayer::sequenceNumber, Start, stateMachineParams::state, state_machine, Supervision, TRUE, stateMachineParams::type, Write, and wrongC.

Referenced by stateMachine().

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

◆ processBCC_OK()

int processBCC_OK ( unsigned char  byte,
unsigned char **  buffer,
int *  buffersize 
)

Function to process a byte in case the state is BCC_OK.

Parameters
bytebyte to be processed
bufferbuffer to put data if stateMachineType is Read
buffersizevariable to keeo size of buf if stateMachineType is Read
Returns
int negative value in case of error, 0 otherwise

References DONE, FLAG, linkLayer::frame, frameIndex, generateErrorBCC2(), log_error(), PROBABILITY_BCC2, Read, linkLayer::sequenceNumber, Start, stateMachineParams::state, state_machine, Supervision, T_PROP_DELAY, stateMachineParams::type, and Write.

Referenced by stateMachine().

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

◆ processC_RCV()

int processC_RCV ( unsigned char  byte)

Function to process a byte in case the state is C_RCV.

Parameters
bytebyte to be processed
Returns
int negative value in case of error, 0 otherwise

References BCC, BCC_OK, checkBuffer, FLAG, FLAG_RCV, frameIndex, generateErrorBCC1(), log_caution(), log_error(), PROBABILITY_BCC1, Read, Start, stateMachineParams::state, state_machine, Supervision, TRUE, stateMachineParams::type, Write, and wrongC.

Referenced by stateMachine().

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

◆ processFLAG_RCV()

int processFLAG_RCV ( unsigned char  byte)

Function to process a byte in case the state is FLAG_RCV.

Parameters
bytebyte to be processed
Returns
int negative value in case of error, 0 otherwise

References A_RCV, stateMachineParams::address, checkBuffer, FLAG, frameIndex, Read, Start, stateMachineParams::state, state_machine, and stateMachineParams::type.

Referenced by stateMachine().

Here is the caller graph for this function:

◆ processStart()

int processStart ( unsigned char  byte)

Function to process a byte in case the state is Start.

Parameters
bytebyte to be processed
Returns
int negative value in case of error, 0 otherwise

References FALSE, FLAG, FLAG_RCV, frameIndex, Read, stateMachineParams::state, state_machine, stateMachineParams::type, and wrongC.

Referenced by stateMachine().

Here is the caller graph for this function:

◆ stateMachine()

int stateMachine ( unsigned char  byte,
unsigned char **  buf,
int *  size 
)

The StateMachine function that processes a byte and updates it's state.

Parameters
bytebyte to process
bufbuffer to put data if stateMachineType is Read
sizevariable to keeo size of buf if stateMachineType is Read
Returns
int negative value in case of error, 0 otherwise

References A_RCV, BCC_OK, C_RCV, DONE, FLAG_RCV, linkLayer::frame, frameIndex, log_error(), processA_RCV(), processBCC_OK(), processC_RCV(), processFLAG_RCV(), processStart(), Read, Start, stateMachineParams::state, state_machine, and stateMachineParams::type.

Referenced by readingCycle(), and writeCycle().

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

◆ stateMachineSetUp()

void stateMachineSetUp ( unsigned char  control,
unsigned char  address,
enum stateMachineState  state,
enum stateMachineType  type 
)

Function to easily change the State Machine.

Parameters
controlControl Byte that is suppossed to be received
addressAddress Byte that is suppossed to be received
stateState of the State Machine
typeType of State Machine

References stateMachineParams::address, stateMachineParams::control, stateMachineParams::state, state_machine, and stateMachineParams::type.

Referenced by llread(), llwrite(), receiver_DISC_UA(), receiver_UA(), transmitter_DISC_UA(), and transmitter_SET().

Here is the caller graph for this function:

Variable Documentation

◆ checkBuffer

unsigned checkBuffer[2]
static

◆ frameIndex

◆ state_machine

◆ wrongC

int wrongC
static