SRK Version of mDot LoRa_Sensormode_SRK
Dependencies: libmDot mbed-rtos mbed
Fork of mDot_LoRa_Sensornode by
TaskGPS.cpp
00001 /* 00002 * TaskGPS.cpp 00003 * 00004 * Created on: May 30, 2016 00005 * Author: Adrian 00006 */ 00007 00008 #include "TaskGPS.h " 00009 00010 TaskGPS::TaskGPS(uBlox* uBlox,Mutex* mutexUART, Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>* queue){ 00011 this->mUBlox = uBlox; 00012 setMutex(mutexUART); 00013 setQueue(queue); 00014 } 00015 00016 TaskGPS::TaskGPS(uBlox* uBlox,rtos::Mutex* mutexUART, 00017 rtos::Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>* queue, 00018 osPriority priority, uint32_t stackSize, unsigned char *stackPointer){ 00019 this->mUBlox = uBlox; 00020 setMutex(mutexUART); 00021 setQueue(queue); 00022 setPriority(priority); 00023 setStackSize(stackSize); 00024 setStackPointer(stackPointer); 00025 setState(SLEEPING); 00026 } 00027 00028 TaskGPS::~TaskGPS() { 00029 // TODO Auto-generated destructor stub 00030 } 00031 00032 osStatus TaskGPS::start(){ 00033 setState(RUNNING); 00034 this->thread = new rtos::Thread(callBack,this); 00035 } 00036 00037 osStatus TaskGPS::stop(){ 00038 thread->terminate(); 00039 setState(SLEEPING); 00040 delete this->thread; 00041 } 00042 00043 void TaskGPS::callBack(void const* data){ 00044 // WOODHAMMER METHOD of Casting! 00045 const TaskGPS* constInstance = static_cast<const TaskGPS* >(data); 00046 TaskGPS* instance = const_cast<TaskGPS*>(constInstance); 00047 00048 instance->measureGps(); 00049 } 00050 00051 void TaskGPS::measureGps(){ 00052 UBloxGPSMessage uBloxGPSMessage; 00053 00054 while(true){ 00055 mutexUART->lock(osWaitForever); 00056 uBloxGPSMessage.setLongitude(mUBlox->getLongitude()); 00057 uBloxGPSMessage.setLatitude(mUBlox->getLatitude()); 00058 mutexUART->unlock(); 00059 00060 queue->put(&uBloxGPSMessage,osWaitForever); 00061 osDelay(GPS_TASK_DELAY_MS); 00062 } 00063 00064 00065 } 00066 00067 void TaskGPS::setQueue(Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>* queue){ 00068 this->queue = queue; 00069 } 00070 00071 void TaskGPS::setMutex(Mutex* mutex){ 00072 this->mutexUART = mutex; 00073 } 00074 00075 void TaskGPS::setPriority(osPriority priority){ 00076 this->priority = priority; 00077 } 00078 00079 void TaskGPS::setStackSize(uint32_t stacksize){ 00080 this->stack_size = stacksize; 00081 } 00082 00083 void TaskGPS::setStackPointer(unsigned char* stackPointer){ 00084 this->stack_pointer = stackPointer; 00085 } 00086 00087 void TaskGPS::setState(TASK_STATE state){ 00088 this->state = state; 00089 } 00090 00091 TASK_STATE TaskGPS::getState(){ 00092 return state; 00093 } 00094
Generated on Wed Jul 13 2022 09:23:48 by 1.7.2