Ignore:
Timestamp:
08/15/01 12:39:04 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/candrv
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/candrv/canopen.cc

    r732 r909  
    223223}
    224224
    225 WORD_t CanOpen::CobId(BYTE_t node, BYTE_t fcode)
     225WORD_t CanOpen::CobId(BYTE_t node, BYTE_t fcode) const
    226226{
    227227    return (fcode<<7) | node&0x1f;
  • trunk/MagicSoft/Cosy/candrv/network.cc

    r808 r909  
    66void Network::Start()
    77{
    8     StartReceiver();
     8    lout << "- Starting network." << endl;
     9
     10    VmodIcan::Start();
    911    InitNodes();
     12
     13    lout << "- Network started." << endl;
    1014}
    1115
    1216void Network::Stop()
    1317{
     18    lout << "- Stopping network." << endl;
     19
    1420    StopNodes();
    15     StopReceiver();
     21    VmodIcan::Stop();
    1622
    1723    lout << "- Network stopped." << endl;
     
    166172}
    167173
    168 bool Network::HasError()
     174bool Network::HasError() const
    169175{
    170176    for (int i=0; i<32; i++)
  • trunk/MagicSoft/Cosy/candrv/network.h

    r808 r909  
    3131    virtual void Stop();
    3232
    33     bool HasError();
     33    bool HasError() const;
    3434};
    3535
  • trunk/MagicSoft/Cosy/candrv/nodedrv.cc

    r808 r909  
    116116}
    117117
    118 void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx)
     118void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORD_t timeout)
    119119{
    120     while (fNetwork->WaitingForSdo(fId, idx, subidx))
    121         usleep(1);
     120    fNetwork->WaitForSdo(fId, idx, subidx, timeout);
    122121}
    123122
     123/*
    124124void NodeDrv::WaitForSdos()
    125125{
     
    127127        usleep(1);
    128128}
     129*/
    129130
    130131void NodeDrv::WaitForNextPdo1()
  • trunk/MagicSoft/Cosy/candrv/nodedrv.h

    r808 r909  
    2929    virtual void StopDevice() = 0;
    3030
    31     bool HasError()        { return fError; }
     31    bool HasError()       { return fError; }
    3232
    3333    virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
     
    6464    void WaitForNextPdo4();
    6565
    66     void WaitForSdos();
    67     void WaitForSdo(WORD_t idx, BYTE_t subidx=0);
     66    // void WaitForSdos();
     67    void WaitForSdo(WORD_t idx, BYTE_t subidx=0, WORD_t timeout=500);
    6868
    6969    void EnableCanMsg(BYTE_t fcode);
  • trunk/MagicSoft/Cosy/candrv/sdolist.cc

    r732 r909  
    8686}
    8787
    88 int PendingSDOList::IsPending()
     88int PendingSDOList::IsPending() const
    8989{
    9090    return (int)fFirst->Next;
  • trunk/MagicSoft/Cosy/candrv/sdolist.h

    r732 r909  
    3434    void DelAll();
    3535
    36     int IsPending();
     36    int IsPending() const;
    3737    int IsPending(BYTE_t node);
    3838    int IsPending(BYTE_t node, WORD_t idx, BYTE_t subidx);
  • trunk/MagicSoft/Cosy/candrv/vmodican.cc

    r732 r909  
    5252}
    5353
    54 void *VmodIcan::ReceiveThread(void *data)
    55 {
    56     VmodIcan *cal = (VmodIcan*)data;
    57 
    58     cal->lout << "- Starting Receiver Loop." << endl;
    59 
    60     //
    61     // set higher priority to make sure that no messages are lost.
    62     //
    63     setpriority(PRIO_PROCESS, 0, -10);
     54void *VmodIcan::Thread()
     55{
     56    lout << "- Starting Receiver Loop." << endl;
    6457
    6558    while (1)
     
    7063        //cout << "waiting..." << endl;
    7164
    72         const int n = read(cal->fd, &c, 1); // sleep until message arrive
     65        const int n = read(fd, &c, 1); // sleep until message arrive
    7366
    7467        gettimeofday(&tv, NULL);
     
    8982            FastMessage fmsg;
    9083
    91             if (cal->ReceiveFast(&fmsg) < 0)
     84            if (ReceiveFast(&fmsg) < 0)
    9285                return (void *)1;
    9386
     
    10598            Message msg;
    10699
    107             if (cal->Receive(&msg) < 0)
     100            if (Receive(&msg) < 0)
    108101                return (void *)1;
    109102
    110103            //cal->PrintMsg(&msg);
    111             cal->HandleMessage(&msg, &tv);
     104            HandleMessage(&msg, &tv);
    112105
    113106            break;
    114107        }
    115 
    116108    }
     109    return NULL;
    117110}
    118111
     
    765758}
    766759
    767 VmodIcan::VmodIcan(const char *dev, const int baud, ostream &out) : Log(out), fRxThrd(NULL)//: CanDriver(dev, baud)
    768 {
     760VmodIcan::VmodIcan(const char *dev, const int baud, ostream &out) : Log(out), MThread(false)//: CanDriver(dev, baud)
     761{
     762    //
     763    // Set priority of receiving thread and detach the receiving thread
     764    //
     765    SetPriority(-10);
     766    Detach();
     767
    769768    Open(dev);                         // open module
    770769    Reset();
     
    782781VmodIcan::~VmodIcan()
    783782{
    784     StopReceiver();
     783    Stop();
    785784    DisableCanBusConnection();
    786785    Close();
     
    794793    SendCanFrame(cobid, msg);
    795794}
    796 
     795/*
    797796void VmodIcan::StopReceiver()
    798797{
     
    804803    delete fRxThrd;
    805804    fRxThrd = NULL;
    806 
    807805    lout << "- Receiver Thread stopped." << endl;
    808806}
     807*/
     808
     809/*
    809810void VmodIcan::StartReceiver()
    810811{
    811     //**************************************
    812     //* create thread waiting for messages *
    813     //**************************************
     812    **************************************
     813    * create thread waiting for messages *
     814    **************************************
    814815    if (fRxThrd)
    815816    {
     
    823824    pthread_create(fRxThrd, NULL, ReceiveThread, this);
    824825}
    825 
     826*/
     827
  • trunk/MagicSoft/Cosy/candrv/vmodican.h

    r732 r909  
    99#include "gendef.h"
    1010
    11 class VmodIcan : public Log
     11#include "MThread.h"
     12/*
     13class VmodIcanRX : public MThread
    1214{
    1315private:
     16    VmodIcan *fModule;
     17
     18    void *Thread();
     19
     20public:
     21    MTGui(VmodIcan *mod) : MThread(false), fModule(mod)
     22    {
     23        SetPriority(-10);
     24        Detach();
     25    }
     26};
     27*/
     28class VmodIcan : public Log, protected MThread
     29{
     30    friend class VmodIcanRX;
     31
     32private:
    1433    int fd; // file descriptor for can module
    15     pthread_t *fRxThrd;
     34    //    pthread_t *fRxThrd;
    1635
    1736    int Ioctl(int msg, void *arg);
    1837
    19     static void *ReceiveThread(void *data);
     38    void *Thread();
    2039
    2140    void HandleMessage(Message *msg, struct timeval *tv);
     
    5271    virtual void TerminateApp() { exit(-1); }
    5372
    54 protected:
    55     void StartReceiver();
    56     void StopReceiver();
     73//protected:
     74//    void StartReceiver();
     75//    void StopReceiver();
    5776
    5877public:
Note: See TracChangeset for help on using the changeset viewer.