本文整理汇总了C++中Mail::put方法的典型用法代码示例。如果您正苦于以下问题:C++ Mail::put方法的具体用法?C++ Mail::put怎么用?C++ Mail::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail
的用法示例。
在下文中一共展示了Mail::put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendToMail
// Send speed, accelerometer and brake values to a 100 element MAIL queue
// car mail semaphore used to protect messages
// average speed and input semphore used to fix vales
// Repetition rate 0.2 Hz = 5 seconds
void sendToMail(void const *args){
while(true){
mail_t *mail = mail_box.alloc();
CAR_MAIL_SEM.wait();
AVR_SPEED_SEM.wait();
mail->speedVal = averageSpeed;
AVR_SPEED_SEM.release();
INPUT_SEM.wait();
mail->accelerometerVal = accelerationValue;
mail->breakVal = brakeValue;
INPUT_SEM.release();
write++;
mail_box.put(mail);
CAR_MAIL_SEM.release();
Thread::wait(5000);
}
}
示例2: adcISR
// Call this on precise intervals
void adcISR() {
//Read sample - make a copy
float sample = adcIn;
//Grab switch state
uint32_t switch1State = sw1;
uint32_t switch2State = sw2;
//Allocate a block from the memory pool
message_t *message = mail_box.alloc();
if (message == NULL) {
//Out of memory
printf("Out of memory\n\r");
redLED = 1;
return;
}
//Fill in the data
message->adcValue = sample;
message->sw1State = switch1State;
message->sw2State = switch2State;
//Write to queue
osStatus stat = mail_box.put(message); //Note we are sending the "pointer"
//Check if succesful
if (stat == osErrorResource) {
redLED = 1;
printf("queue->put() Error code: %4Xh, Resource not available\r\n", stat);
mail_box.free(message);
return;
}
}