Changeset 909 for trunk/MagicSoft/Cosy/candrv
- Timestamp:
- 08/15/01 12:39:04 (24 years ago)
- Location:
- trunk/MagicSoft/Cosy/candrv
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/candrv/canopen.cc
r732 r909 223 223 } 224 224 225 WORD_t CanOpen::CobId(BYTE_t node, BYTE_t fcode) 225 WORD_t CanOpen::CobId(BYTE_t node, BYTE_t fcode) const 226 226 { 227 227 return (fcode<<7) | node&0x1f; -
trunk/MagicSoft/Cosy/candrv/network.cc
r808 r909 6 6 void Network::Start() 7 7 { 8 StartReceiver(); 8 lout << "- Starting network." << endl; 9 10 VmodIcan::Start(); 9 11 InitNodes(); 12 13 lout << "- Network started." << endl; 10 14 } 11 15 12 16 void Network::Stop() 13 17 { 18 lout << "- Stopping network." << endl; 19 14 20 StopNodes(); 15 StopReceiver();21 VmodIcan::Stop(); 16 22 17 23 lout << "- Network stopped." << endl; … … 166 172 } 167 173 168 bool Network::HasError() 174 bool Network::HasError() const 169 175 { 170 176 for (int i=0; i<32; i++) -
trunk/MagicSoft/Cosy/candrv/network.h
r808 r909 31 31 virtual void Stop(); 32 32 33 bool HasError() ;33 bool HasError() const; 34 34 }; 35 35 -
trunk/MagicSoft/Cosy/candrv/nodedrv.cc
r808 r909 116 116 } 117 117 118 void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx )118 void NodeDrv::WaitForSdo(WORD_t idx, BYTE_t subidx, WORD_t timeout) 119 119 { 120 while (fNetwork->WaitingForSdo(fId, idx, subidx)) 121 usleep(1); 120 fNetwork->WaitForSdo(fId, idx, subidx, timeout); 122 121 } 123 122 123 /* 124 124 void NodeDrv::WaitForSdos() 125 125 { … … 127 127 usleep(1); 128 128 } 129 */ 129 130 130 131 void NodeDrv::WaitForNextPdo1() -
trunk/MagicSoft/Cosy/candrv/nodedrv.h
r808 r909 29 29 virtual void StopDevice() = 0; 30 30 31 bool HasError() 31 bool HasError() { return fError; } 32 32 33 33 virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv); … … 64 64 void WaitForNextPdo4(); 65 65 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); 68 68 69 69 void EnableCanMsg(BYTE_t fcode); -
trunk/MagicSoft/Cosy/candrv/sdolist.cc
r732 r909 86 86 } 87 87 88 int PendingSDOList::IsPending() 88 int PendingSDOList::IsPending() const 89 89 { 90 90 return (int)fFirst->Next; -
trunk/MagicSoft/Cosy/candrv/sdolist.h
r732 r909 34 34 void DelAll(); 35 35 36 int IsPending() ;36 int IsPending() const; 37 37 int IsPending(BYTE_t node); 38 38 int IsPending(BYTE_t node, WORD_t idx, BYTE_t subidx); -
trunk/MagicSoft/Cosy/candrv/vmodican.cc
r732 r909 52 52 } 53 53 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); 54 void *VmodIcan::Thread() 55 { 56 lout << "- Starting Receiver Loop." << endl; 64 57 65 58 while (1) … … 70 63 //cout << "waiting..." << endl; 71 64 72 const int n = read( cal->fd, &c, 1); // sleep until message arrive65 const int n = read(fd, &c, 1); // sleep until message arrive 73 66 74 67 gettimeofday(&tv, NULL); … … 89 82 FastMessage fmsg; 90 83 91 if ( cal->ReceiveFast(&fmsg) < 0)84 if (ReceiveFast(&fmsg) < 0) 92 85 return (void *)1; 93 86 … … 105 98 Message msg; 106 99 107 if ( cal->Receive(&msg) < 0)100 if (Receive(&msg) < 0) 108 101 return (void *)1; 109 102 110 103 //cal->PrintMsg(&msg); 111 cal->HandleMessage(&msg, &tv);104 HandleMessage(&msg, &tv); 112 105 113 106 break; 114 107 } 115 116 108 } 109 return NULL; 117 110 } 118 111 … … 765 758 } 766 759 767 VmodIcan::VmodIcan(const char *dev, const int baud, ostream &out) : Log(out), fRxThrd(NULL)//: CanDriver(dev, baud) 768 { 760 VmodIcan::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 769 768 Open(dev); // open module 770 769 Reset(); … … 782 781 VmodIcan::~VmodIcan() 783 782 { 784 Stop Receiver();783 Stop(); 785 784 DisableCanBusConnection(); 786 785 Close(); … … 794 793 SendCanFrame(cobid, msg); 795 794 } 796 795 /* 797 796 void VmodIcan::StopReceiver() 798 797 { … … 804 803 delete fRxThrd; 805 804 fRxThrd = NULL; 806 807 805 lout << "- Receiver Thread stopped." << endl; 808 806 } 807 */ 808 809 /* 809 810 void VmodIcan::StartReceiver() 810 811 { 811 //**************************************812 //* create thread waiting for messages *813 //**************************************812 ************************************** 813 * create thread waiting for messages * 814 ************************************** 814 815 if (fRxThrd) 815 816 { … … 823 824 pthread_create(fRxThrd, NULL, ReceiveThread, this); 824 825 } 825 826 */ 827 -
trunk/MagicSoft/Cosy/candrv/vmodican.h
r732 r909 9 9 #include "gendef.h" 10 10 11 class VmodIcan : public Log 11 #include "MThread.h" 12 /* 13 class VmodIcanRX : public MThread 12 14 { 13 15 private: 16 VmodIcan *fModule; 17 18 void *Thread(); 19 20 public: 21 MTGui(VmodIcan *mod) : MThread(false), fModule(mod) 22 { 23 SetPriority(-10); 24 Detach(); 25 } 26 }; 27 */ 28 class VmodIcan : public Log, protected MThread 29 { 30 friend class VmodIcanRX; 31 32 private: 14 33 int fd; // file descriptor for can module 15 pthread_t *fRxThrd;34 // pthread_t *fRxThrd; 16 35 17 36 int Ioctl(int msg, void *arg); 18 37 19 static void *ReceiveThread(void *data);38 void *Thread(); 20 39 21 40 void HandleMessage(Message *msg, struct timeval *tv); … … 52 71 virtual void TerminateApp() { exit(-1); } 53 72 54 protected:55 void StartReceiver();56 void StopReceiver();73 //protected: 74 // void StartReceiver(); 75 // void StopReceiver(); 57 76 58 77 public:
Note:
See TracChangeset
for help on using the changeset viewer.