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 uint16_t l1BuildAndSendSlotIndication();
29 /*******************************************************************
31 * @brief Generates slot indications
35 * Function : GenerateTicks
37 * Functionality: Generates slot indications
40 * @return ROK - success
43 * ****************************************************************/
44 void *GenerateTicks(void *arg)
46 int milisec = 1; /* 1ms */
47 struct timespec req = {0};
50 req.tv_nsec = milisec * 1000000L;
54 nanosleep(&req, (struct timespec *)NULL);
56 /* Send Slot indication indication to lower mac */
57 l1BuildAndSendSlotIndication();
59 return((void *)NULLP);
62 /*******************************************************************
64 * @brief Create/cancel thread for generating slot indication
68 * Function : l1HdlSlotIndicaion
70 * Functionality: Create/cancel thread for generating slot indication
73 * @return ROK - success
76 * ****************************************************************/
77 void l1HdlSlotIndicaion(bool stopSlotInd)
83 ret = pthread_create(&thread, NULL, GenerateTicks, NULL);
86 DU_LOG("\nERROR --> PHY_STUB: Unable to create thread");
91 ret = pthread_cancel(thread);
94 DU_LOG("\nERROR --> PHY_STUB: Unable to stop thread");
99 /*******************************************************************
101 * @brief Handles Console input
105 * Function : l1ConsoleHandler
107 * Functionality: Handles Console input
110 * @return ROK - success
113 * ****************************************************************/
114 void *l1ConsoleHandler(void *args)
119 /* Send UL user data to DU when user enters 'd' on console */
120 if((ch = getchar()) == 'd')
122 /* Start Pumping data from PHY stub to DU */
123 DU_LOG("\nDEBUG --> PHY STUB: Sending UL User Data");
129 /*******************************************************************
131 * @brief Creates thread for handling console input
135 * Function : l1StartConsoleHandler
137 * Functionality: Creates thread for handling console input
140 * @return ROK - success
143 * ****************************************************************/
144 void l1StartConsoleHandler()
150 /* Start thread to receive console input */
151 pthread_attr_init(&attr);
152 pthread_attr_setstacksize(&attr, (size_t)NULLD);
153 pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
154 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
155 retVal = pthread_create(&conThrdId, &attr, l1ConsoleHandler, NULLP);
158 DU_LOG("\nERROR --> PHY STUB : Thread creation failed. Cause %d", retVal);
160 pthread_attr_destroy(&attr);
164 /**********************************************************************
166 **********************************************************************/