Encompasses network connection functions and configuration settings. This group includes functions and structures related to establishing and managing network connections between the controller application and other components, such as servers or devices.
More...
Encompasses network connection functions and configuration settings. This group includes functions and structures related to establishing and managing network connections between the controller application and other components, such as servers or devices.
◆ initSockets()
int initSockets |
( |
Config * | config | ) |
|
Initializes UDP sockets and server address structures.
This function initializes UDP sockets and server address structures for communicating with the server. It creates separate sockets for controller and targets, and sets up the server address structures accordingly.
- Parameters
-
config | Pointer to the configuration structure containing network settings. |
- Returns
- EXIT_SUCCESS if sockets are initialized correctly, otherwise EXIT_FAILURE.
◆ ReceiveCalibrationsFromServer()
void ReceiveCalibrationsFromServer |
( |
char * | calibration_buffer, |
|
|
socklen_t * | serverAddrCalibrationInLen, |
|
|
CalibrationData * | calData, |
|
|
TaskParameters * | parameters ) |
Receives calibration UDP data packets from the server.
This function receives updated calibration data, for example on initialization or after the SendCalibrationCenterCommandToServer
function has been invoked.
- Parameters
-
calibration_buffer | Buffer to store the received calibration message bytes. |
serverAddrCalibrationInLen | Pointer to the length of the server address structure. |
calData | Pointer to the calibration data to update based on message contents. |
parameters | Pointer to the parameter data structure.
|
◆ ReceiveParameterUpdatesFromServer()
void ReceiveParameterUpdatesFromServer |
( |
char * | parameters_input_buffer, |
|
|
socklen_t * | serverAddrParametersInLen, |
|
|
TaskParameters * | parameters ) |
Receives parameter updates from the server via UDP socket.
This function receives parameter updates from the server using a UDP socket, unpacks the received data into a TaskParameters struct, and updates the UI accordingly.
- Parameters
-
parameters_input_buffer | Buffer to store the received parameter data. |
serverAddrParametersInLen | Pointer to the length of the server address structure. |
parameters | Pointer to parameter data structure. |
The parameter data is expected to be formatted according to the packing format used by the packParameters
function.
◆ ReceiveRequestsFromServer()
void ReceiveRequestsFromServer |
( |
char * | req_input_buffer, |
|
|
socklen_t * | serverAddrReqInLen ) |
Receives requests from the server via UDP socket.
This function receives requests from the server using a UDP socket, parses the received data, and performs corresponding actions or operations.
- Parameters
-
req_input_buffer | Buffer to store the received request data. |
serverAddrReqInLen | Pointer to the length of the server address structure. |
The request data is expected to be formatted as follows:
◆ ReceiveStateUpdatesFromServer()
void ReceiveStateUpdatesFromServer |
( |
char * | state_input_buffer, |
|
|
socklen_t * | serverAddrStateInLen ) |
Receives state updates from the server via UDP socket.
This function receives state updates from the server using a UDP socket, updates local variables accordingly, and performs necessary UI updates.
- Parameters
-
state_input_buffer | Buffer to store the received state data. |
serverAddrStateInLen | Pointer to the length of the server address structure. |
The state data is expected to be formatted as a comma-separated string with the following fields:
- Current successes (unsigned short)
- Current attempts (unsigned short)
- Total successes (unsigned short)
- Total attempts (unsigned short)
- Set index (unsigned short)
- Paused status (unsigned char, 0 or 1)
- Logging status (unsigned char, 0 or 1)
◆ SendCalibrationDataToServer()
int SendCalibrationDataToServer |
( |
CalibrationData * | calData | ) |
|
Sends the current calibration data to the server.
- Todo
- Implement SendCalibrationDataToServer
◆ SendCommandToServer()
int SendCommandToServer |
( |
Command | cmd | ) |
|
Sends a command to the server.
- Parameters
-
cmd | The command to be sent to the server. |
- Returns
- EXIT_SUCCESS if message sent successfully, else EXIT_FAILURE.
◆ SendDispenseCommandToRewardServer()
int SendDispenseCommandToRewardServer |
( |
| ) |
|
Sends a command to the reward device to issue the desired dispense.
- Todo
- Implement SendDispenseCommandToRewardServer
◆ SendNextTargetToServer()
Sends task target data to the server.
If there are no targets in the table, populates random targets before sending.
- Parameters
-
tSeq | Pointer to the TaskTargets structure containing target data. |
- Returns
- Returns EXIT_SUCCESS on successful sending, EXIT_FAILURE otherwise.
◆ SendTaskParametersToServer()
int SendTaskParametersToServer |
( |
TaskParameters * | params | ) |
|
Sends task parameters to the server.
- Parameters
-
params | Pointer to the task parameters structure to be sent. |
- Returns
- EXIT_SUCCESS if message sent successfully, else EXIT_FAILURE.
◆ calibration_buffer
char calibration_buffer[BYTES_STATE_CALIBRATION_BUFFER] |
|
extern |
Buffer for UDP calibration messages exchanged between server and application.
◆ config
Configuration struct used by the application.
◆ edit_buffer
Buffer that holds string inputs from parameter UI elements.
◆ parameters_output_buffer
char parameters_output_buffer[BYTES_STATE_PARAMETER_BUFFER] |
|
extern |
Buffer that is only used for exchanging parameters with server.
◆ prev_orientation
Orientation prev_orientation |
|
extern |
Global variable to save the orientation sent with previous parameters.
◆ prev_subject
Global buffer to save the name of the subject sent with previous parameters.
◆ reward_command_output_buffer
char reward_command_output_buffer[BYTES_REWARD_COMMAND_BUFFER] |
Buffer for UDP Control Commands to be sent to reward device.
◆ serverAddrCalibrationIn
struct sockaddr_in serverAddrCalibrationIn |
|
extern |
◆ serverAddrCalibrationOut
struct sockaddr_in serverAddrCalibrationOut |
|
extern |
◆ serverAddrCommandOut
struct sockaddr_in serverAddrCommandOut |
|
extern |
UDP socket addresses associated with each socket.
◆ serverAddrParametersIn
struct sockaddr_in serverAddrParametersIn |
|
extern |
◆ serverAddrParametersOut
struct sockaddr_in serverAddrParametersOut |
|
extern |
◆ serverAddrReqIn
struct sockaddr_in serverAddrReqIn |
|
extern |
◆ serverAddrRewardOut
struct sockaddr_in serverAddrRewardOut |
|
extern |
◆ serverAddrStateIn
struct sockaddr_in serverAddrStateIn |
|
extern |
◆ serverAddrTargetOut
struct sockaddr_in serverAddrTargetOut |
|
extern |
◆ state_command_output_buffer
char state_command_output_buffer[BYTES_STATE_COMMAND_BUFFER] |
|
extern |
Buffer for UDP Control Commands to be sent to server.
◆ target_output_buffer
char target_output_buffer[BYTES_STATE_TARGET_BUFFER] |
|
extern |
Buffer for UDP Target Locations to be sent to server.
◆ udpSockCalibrationIn
SOCKET udpSockCalibrationIn |
|
extern |
UDP socket to receive calibration updates from the server.
◆ udpSockCalibrationOut
SOCKET udpSockCalibrationOut |
|
extern |
UDP socket to send calibration data to the server.
◆ udpSockCommandOut
UDP socket to send "control" commands to the server.
◆ udpSockParametersIn
SOCKET udpSockParametersIn |
|
extern |
UDP socket to receive initial parameter state message from server.
◆ udpSockParametersOut
SOCKET udpSockParametersOut |
|
extern |
UDP socket to send parameter changes to the server.
◆ udpSockReqIn
UDP socket to receive requests from the server, such as to issue a reward or generate new targets.
◆ udpSockRewardOut
UDP socket to send commands to the reward dispenser.
◆ udpSockStateIn
UDP socket to receive state updates (trial counts etc) from the server.
◆ udpSockTargetOut
UDP socket to send updates in target positions to the server.