- Timestamp:
- Jul 22, 2013, 11:45:45 PM (11 years ago)
- Location:
- branches/2.0-beta1
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/include/Pacpus/PacpusTools/PacpusSerialPort.h
r121 r122 65 65 QString stopChar; 66 66 67 int minPacketSize; 68 69 bool log; 70 67 71 68 72 }; -
branches/2.0-beta1/include/Pacpus/kernel/inputOutputInterface.h
r119 r122 43 43 PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event); 44 44 45 qDebug() << "Revever " << getSignature() << " thread " << QThread::currentThread() << " Data & " << & typedEvent->data_;45 //qDebug() << "Reciever " << getSignature() << " thread " << QThread::currentThread() << " Data & " << & typedEvent->data_; 46 46 47 47 //if(_component) get state … … 54 54 switch (readingMode_){ 55 55 case TimeBounded: 56 qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("Time bournded").leftJustified(15) << road_time()- typedEvent->t_ << "\t" << typedEvent->tr_;56 //qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("Time bournded").leftJustified(15) << road_time()- typedEvent->t_ << "\t" << typedEvent->tr_; 57 57 58 58 if(road_time() - typedEvent->t_> typedEvent->tr_) … … 63 63 64 64 case GetLast: 65 qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("GetLast").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_;65 //qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("GetLast").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_; 66 66 67 67 (dynamic_cast<C*>(_component)->*method)(typedEvent->data_); … … 70 70 71 71 case NeverSkip: 72 qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("NeverSkip").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_;72 //qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("NeverSkip").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_; 73 73 74 74 default: … … 138 138 for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it){ 139 139 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority()); // Event is delete by the event loop handler 140 qDebug() << "sender " << it->getInterface()->getSignature() << " thread " << QThread::currentThread() << " Data & " << &data << " ";141 // TODO D Ata SHAred140 //qDebug() << "sender " << it->getInterface()->getSignature() << " thread " << QThread::currentThread() << " Data & " << &data << " "; 141 // TODO Data Shared 142 142 } 143 143 } -
branches/2.0-beta1/src/PacpusTools/src/PacpusSerialPort.cpp
r121 r122 40 40 41 41 dataMode = ASCII; 42 sepChar = "\n"; 43 44 startChar = " $";42 sepChar = "\n"; // TODO remove 43 44 startChar = ""; 45 45 stopChar = "\n"; 46 minPacketSize=0; 47 48 log = false; // TODO remove when component ok 46 49 47 50 // Or threaded … … 109 112 if(param.hasProperty("stopChar")) 110 113 stopChar = param.getProperty("stopChar"); 114 115 if(param.hasProperty("minPacketSize")) 116 minPacketSize = (DataMode) param.getProperty("minPacketSize").toInt(); 111 117 112 118 serialPort->setPortName(portName); … … 135 141 { 136 142 143 buffer.clear(); 144 137 145 if(!serialPort->open((QSerialPort::OpenModeFlag)direction)) 138 146 { LOG_FATAL("device "<< serialPort->portName().toStdString() <<" failed to open: " << serialPort->errorString()); } … … 182 190 int n; 183 191 184 buffer.append(serialPort->readAll()); 192 if(dataMode == BINARY & minPacketSize >0) 193 if(serialPort->bytesAvailable() < minPacketSize) 194 return; 195 196 buffer += serialPort->readAll(); 185 197 186 198 while(true) // loop until no data to send … … 189 201 { 190 202 case ASCII : // Split the first line to send 191 192 n = buffer.indexOf(sepChar,1) + 1; 193 if(n<=0) 194 return; // end line char not found 203 { 204 if(startChar.size()>0) 205 { 206 int indexStart = buffer.indexOf(startChar,0); 207 if(indexStart < 0) 208 return; 209 else 210 buffer.remove(0,indexStart); 211 } 212 213 int indexStop = buffer.indexOf(stopChar,1); 214 if(indexStop < 1) 215 return; 216 217 n=indexStop; 195 218 break; 196 219 220 // This work but replace by previous code that need to be test 221 // n = buffer.indexOf(sepChar,1) + 1; 222 // if(n<=0) 223 // return; // end line char not found 224 // break; 225 } 197 226 case BINARY : // Get all data 198 199 227 n = buffer.size();//serialPort->bytesAvailable(); 200 228 if(n<=0) … … 218 246 GET_OUTPUT("pinOutSignal",PacpusSerialPort,quint16)->send(pinout); 219 247 setState(MONITOR_OK); 220 LOG_INFO("Signal Read " << n << " bytes, PinOut : " << pinout); 221 LOG_INFO(QString(data).toStdString()); 222 } 223 //LOG_INFO("Buffer " << buffer.data()); 248 LOG_DEBUG("Signal Read " << n << " bytes, PinOut : " << pinout); 249 LOG_DEBUG(data.data()); 250 251 if(log) 252 { 253 switch(dataMode) 254 { 255 case ASCII : 256 LOG_INFO("Buffer " << buffer.data()); 257 258 case BINARY : 259 { 260 QByteArray str; 261 for(int i =0;i<22 ;i++) 262 str+= QByteArray::number((uchar)buffer.data()[i],16).toUpper() + " "; 263 LOG_INFO("Value " << str.data()); 264 } 265 } 266 } 267 } 224 268 } 225 269
Note:
See TracChangeset
for help on using the changeset viewer.