ts-7000
[Top] [All Lists]

[ts-7000] Trying to encapsulate thread in class

To:
Subject: [ts-7000] Trying to encapsulate thread in class
From: "Richard" <>
Date: Tue, 22 Jan 2008 07:34:05 -0000
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




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<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