FreeRTOS Tetris
Functions | Variables
Opponent Module

Module handling incoming/outgoing messages to an "opponent". More...

Collaboration diagram for Opponent Module:

Functions

int iOpponentInit ()
 Initialize the opponent functionality. More...
 
static bool parseMode (const char *buffer, game_mode_t *mode)
 Parse buffer into the corresponding game_mode_t. More...
 
static bool parseTetrominoType (const char *buffer, tetromino_type_t *type)
 Parse buffer into the corresponding tetromino_type_t. More...
 
static bool selectGameMode (char *buf)
 Function that reads a game selection from the user. More...
 
static void UDPHandler (size_t readSize, char *buffer, void *args)
 Interrupt-Servie-Routine that handles incoming UDP messages. More...
 
static void vUDPControlTask ()
 Task that controls incoming/outgoing UDP messages.
 

Variables

TaskHandle_t UDPControlTask = NULL
 Task to control the UDP socket
 
static SemaphoreHandle_t HandleUDP = NULL
 Mutex for handling UDP
 
SemaphoreHandle_t NextTetrominoSignal = NULL
 Signal for the next Tetromino
 
QueueHandle_t TetrominoQueue = NULL
 Queue for receiving tetromino types from opponent
 
static aIO_handle_t UDPSocReceive = NULL
 AsyncIO Handle for receiving data via UDP
 

UDP Definitions

#define UDP_BUFFER_SIZE   1024
 Buffer size of the UDP connection.
 
#define UDP_RECEIVE_PORT   1234
 UDP port for receiving data.
 
#define UDP_TRANSMIT_PORT   1235
 UDP port for transmitting data.
 

Detailed Description

Module handling incoming/outgoing messages to an "opponent".

This module contains functionality to interact with the "opponent". The opponent is an executable, that generates Tetrominos. It can run in various modes. For more information on the opponent see.

Authors
Philipp Karg (phili.nosp@m.pp.k.nosp@m.arg@t.nosp@m.um.d.nosp@m.e)
Date
04.02.2021

Function Documentation

◆ iOpponentInit()

int iOpponentInit ( )

#include <opponent.h>

Initialize the opponent functionality.

Returns
(int): 0 if initialization was successful, -1 otherwise.

◆ parseMode()

static bool parseMode ( const char *  buffer,
game_mode_t mode 
)
static

#include <opponent.c>

Parse buffer into the corresponding game_mode_t.

Parameters
[in]buffer(const char*): String to parse.
[out]mode( game_mode_t *): Object to parse game mode into.
Returns
(bool): whether buffer could be parsed.

◆ parseTetrominoType()

static bool parseTetrominoType ( const char *  buffer,
tetromino_type_t type 
)
static

#include <opponent.c>

Parse buffer into the corresponding tetromino_type_t.

Parameters
[in]buffer(const char*): String to parse.
[out]type( tetromino_type_t *): Object to parse Tetromino type into.
Returns
(bool): whether buffer could be parsed.

◆ selectGameMode()

static bool selectGameMode ( char *  buf)
static

#include <opponent.c>

Function that reads a game selection from the user.

Parameters
[in]buf(char*): String to put the selected game mode in.
Returns
(bool): whether a game mode was selected.

◆ UDPHandler()

static void UDPHandler ( size_t  readSize,
char *  buffer,
void *  args 
)
static

#include <opponent.c>

Interrupt-Servie-Routine that handles incoming UDP messages.

Parameters
[in]readSize(size_t): Size of the buffer.
[in]buffer(char*): The UDP message.
[in]args(void*): Additional arguments.