1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file handles slot indication */
21 #include "common_def.h"
22 #include "lphy_stub.h"
25 uint8_t l1SendUlUserData();
26 uint8_t l1SendStatusPdu();
27 uint16_t l1BuildAndSendSlotIndication();
30 /*******************************************************************
32 * @brief Generates slot indications
36 * Function : GenerateTicks
38 * Functionality: Generates slot indications
41 * @return ROK - success
44 * ****************************************************************/
45 void *GenerateTicks(void *arg)
48 int milisec = 0.5; /* 0.5ms */
50 int milisec = 1; /* 1ms */
52 struct timespec req = {0};
55 req.tv_nsec = milisec * 1000000L;
59 clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL);
60 /* Send Slot indication indication to lower mac */
61 l1BuildAndSendSlotIndication();
63 return((void *)NULLP);
66 /*******************************************************************
68 * @brief Create/cancel thread for generating slot indication
72 * Function : l1HdlSlotIndicaion
74 * Functionality: Create/cancel thread for generating slot indication
77 * @return ROK - success
80 * ****************************************************************/
81 void l1HdlSlotIndicaion(bool stopSlotInd)
87 ret = pthread_create(&thread, NULL, GenerateTicks, NULL);
90 DU_LOG("\nERROR --> PHY_STUB: Unable to create thread");
95 ret = pthread_cancel(thread);
98 DU_LOG("\nERROR --> PHY_STUB: Unable to stop thread");
103 /*******************************************************************
105 * @brief Handles Console input
109 * Function : l1ConsoleHandler
111 * Functionality: Handles Console input
114 * @return ROK - success
117 * ****************************************************************/
118 void *l1ConsoleHandler(void *args)
123 /* Send UL user data to DU when user enters 'd' on console */
124 if((ch = getchar()) == 'd')
126 /* Start Pumping data from PHY stub to DU */
127 DU_LOG("\nDEBUG --> PHY STUB: Sending UL User Data");
130 else if((ch = getchar()) == 'c')
132 /* Send Control PDU from PHY stub to DU */
133 DU_LOG("\nDEBUG --> PHY STUB: Sending Status PDU");
139 /*******************************************************************
141 * @brief Creates thread for handling console input
145 * Function : l1StartConsoleHandler
147 * Functionality: Creates thread for handling console input
150 * @return ROK - success
153 * ****************************************************************/
154 void l1StartConsoleHandler()
160 /* Start thread to receive console input */
161 pthread_attr_init(&attr);
162 pthread_attr_setstacksize(&attr, (size_t)NULLD);
163 pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
164 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
165 retVal = pthread_create(&conThrdId, &attr, l1ConsoleHandler, NULLP);
168 DU_LOG("\nERROR --> PHY STUB : Thread creation failed. Cause %d", retVal);
170 pthread_attr_destroy(&attr);
174 /**********************************************************************
176 **********************************************************************/