ts-7000
[Top] [All Lists]

Re: [ts-7000] Trying to encapsulate thread in class

To:
Subject: Re: [ts-7000] Trying to encapsulate thread in class
From: "Rich Wilson" <>
Date: Tue, 22 Jan 2008 08:36:05 -0800
Richard,

It seems to be complaining about the third parameter to pthread_create,
which is &resetWatchdog. I believe it's complaining because
you can't form a pointer to a class member, unless it's static, because
the pointer doesn't make sense without an object to go with it.

Translation: You need to make resetWatchdog into a static function
in order to pass it as a parameter to pthread_create.

Rich

On Jan 21, 2008 11:34 PM, Richard <> wrote:

Ok here is my source code, the first section is the implementation,
the second section is the declaration, and the third is the compiler
error. Any help on this would be appreciated.

/********************** Implementation **********************/
#include "WatchdogControl.h"
//Class Constructor, currently being used to set the default timer
watchdog.
WatchdogControl::WatchdogControl()
{
timerValue = 0x07;
}

WatchdogControl::~WatchdogControl()
{
}

void WatchdogControl::startWatchdogMonitor()
{
if (!WatchdogTimerOn);
pthread_t WatchdogMonitorId;
pthread_create (&WatchdogMonitorId, NULL, &resetWatchdog, NULL);
WatchdogTimerOn = true;
}

void* WatchdogControl::resetWatchdog(void* nothing)
{
sleep(300);
setWatchdogTimer();
return NULL;
}

void WatchdogControl::setWatchdogTimer()
{
int fd = open("/dev/mem", O_RDWR);
assert(fd != -1);

wdt_control = (unsigned char
*)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x23800000);
wdt_feed = (unsigned char
*)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x23C00000);

*wdt_feed = WATCHDOG_FEED_BYTE;
*wdt_control = timerValue;
}

/********************** Declaration **********************/
#ifndef WATCHDOGCONTROL_H_
#define WATCHDOGCONTROL_H_

//Classs Include Files
#include<unistd.h>
#include<sys/types.h>
#include<sys/mman.h>
#include<fcntl.h>
#include<assert.h>
#include <pthread.h>

//Class Definitions
#define WATCHDOG_FEED_BYTE 0x05

//Class Declaration
class WatchdogControl
{
public:
//Public Class Variables

//Public Class Functions
WatchdogControl();
virtual ~WatchdogControl();
void startWatchdogMonitor();


private:
//Private Class Variables
volatile unsigned char *wdt_control;
volatile unsigned char *wdt_feed;
int timerValue;
bool WatchdogTimerOn;

//Private Class Functions
void* resetWatchdog(void* nothing);
void setWatchdogTimer();

};

#endif /*WATCHDOGCONTROL_H_*/

/********************** Error **********************/
Severity and Description Path Resource Location Creation Time Id
error: cannot convert 'void* (WatchdogControl::*)(void*)' to 'void*
(*)(void*)' for argument '3' to 'int pthread_create(pthread_t*, const
pthread_attr_t*, void* (*)(void*), void*)' rbash/WatchdogControl
WatchdogControl.cpp line 16 1200986943638 391




--
Rich Wilson

425-337-7129 __._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU