Cvoid Thread::rBins(){ QByteArray buf(1212,0); int cnt=0; QSerialPort port; port.Open(3,115200); usleep(100); if(port.IsOpened()){ if(!port.Read(buf.data(),buf.size(),&cnt)){ //TextOut->append("пЫЙВЛБ ЮФЕОЙС"); } port.Close(); } if (cnt>0){ QByteArray Bbuf1(buf); QByteArray pack1; int ind = 0,ind1 = 0; cnt = Bbuf1.count(203); while(ind < Bbuf1.length()){ if (ind1 = Bbuf1.indexOf(203),ind){ if(Bbuf1.at(ind1+1) == 15){ pack1 = Bbuf1.mid(ind1,36); break; } } ind += ind1+1; } int ikj = pack1.size(); QByteArray Bbuf2(buf); QByteArray pack2; ind = 0; int ind2 = 0; cnt = Bbuf2.count(205); while(ind < Bbuf2.length()){ if (ind2 = Bbuf2.indexOf(205),ind){ if(Bbuf2.at(ind2+1) == 15){ pack2 = Bbuf2.mid(ind2,32); break; } } ind += ind2+1; } ikj = pack2.size(); QByteArray Bbuf3(buf); QByteArray pack3; ind = 0; int ind3 = 0; cnt = Bbuf3.count(204); while(ind < Bbuf3.length()){ if (ind3 = Bbuf3.indexOf(204),ind){ if(Bbuf3.at(ind3+1) == 15){ pack3 = Bbuf3.mid(ind3,466); break; } } ind += ind3+1; } ikj = pack3.size(); QByteArray Bbuf4(buf); QByteArray pack4; ind = 0; int ind4 = 0; cnt = Bbuf4.count(202); while(ind < Bbuf4.length()){ if (ind4 = Bbuf4.indexOf(202),ind){ if(Bbuf4.at(ind4+1) == 15){ pack4 = Bbuf4.mid(ind4,72); break; } } ind += ind4 + 1; } ikj = pack4.size(); QDataStream stream1(&pack1,QIODevice::ReadOnly); stream1.setByteOrder(QDataStream::LittleEndian); stream1 >> dnss.head >> dnss.time >> dnss.wx >> dnss.wy >> dnss.wz >> dnss.ax >> dnss.ay >> dnss.az >> dnss.altitude >> dnss.sum; QDataStream stream2(&pack2,QIODevice::ReadOnly); stream2.setByteOrder(QDataStream::LittleEndian); stream2 >> odd.head >> odd.index >> odd.indicator >> odd.speed >> odd.scale >> odd.delay >> odd.driftx >> odd.drifty >> odd.sum; QDataStream stream3(&pack3,QIODevice::ReadOnly); stream3.setByteOrder(QDataStream::LittleEndian); stream3 >> snss.head >> snss.index >> snss.RMC_time >> snss.RMC_latitude_int >> snss.RMC_latitude_fract >> snss.RMC_longitude_int >> snss.RMC_longitude_fract >> snss.RMC_speed >> snss.RMC_track_angle >> snss.RMC_date >> snss.RMC_magnetic_declination >> snss.GGA_time >> snss.GGA_latitude_int >> snss.GGA_latitude_fract >> snss.GGA_longitude_int >> snss.GGA_longitude_fract >> snss.GGA_mode >> snss.GGA_number_of_satility >> snss.GGA_HDOP >> snss.GGA_altitude >> snss.GGA_dif_alt >> snss.GSA_numeration_mode >> snss.GSA_ind_sat[24] >> snss.GSA_PDOP >> snss.GSA_HDOP >> snss.GSA_VDOP >> snss.GSV_number_of_satility >> snss.GSV_ID[24] >> snss.GSV_elevation[24] >> snss.GSV_course[24] >> snss.GSV_ntsr[24] >> snss.DTM_coor_sys >> snss.DTM_lat_drift >> snss.DTM_long_drift >> snss.DTM_alt_drift >> snss.GBS_time >> snss.GBS_err_lat >> snss.GBS_err_long >> snss.GBS_err_alt >> snss.GBS_ex_sat >> snss.GBS_deviation >> snss.GLL_lat >> snss.GLL_long >> snss.GLL_time >> snss.ZDA_time >>snss.ZDA_day >> snss.ZDA_mounth >> snss.ZDA_year >> snss.ZDA_time_zone_hour >> snss.ZDA_time_zone_min >> snss.PORZE_time >> snss.PORZE_x >> snss.PORZE_y >> snss.PORZE_speed >> snss.PORZE_course >> snss.PORZE_date >> snss.PORZE_ID >> snss.PORZX_sys >> snss.PORZX_sns >> snss.PORZX_hour >> snss.PORZX_min >> snss.PORZX_sign >> snss.PORZX_mean_err >> snss.sum; QDataStream stream4(&pack4,QIODevice::ReadOnly); stream4.setByteOrder(QDataStream::LittleEndian); stream4 >> ndd.head >> ndd.time_power >> ndd.time_init >> ndd.ind >> ndd.ID >> ndd.FW >> ndd.pitch >> ndd.list >> ndd.course >> ndd.speed >> ndd.espeed >> ndd.nspeed >> ndd.vspeed >> ndd.height >> ndd.latitude >>ndd.longitude >>ndd.sum; ikj = 55; }//oRMC(12,25);}
C usleep(100);
Cvoid Thread::run(){ QEventLoop loop; tRead.start(10); connect(&tRead,SIGNAL(timeout()),this,SLOT(rBins())); loop.exec();}
C if (cnt>0){ QByteArray Bbuf1(buf);... if (ind1 = Bbuf1.indexOf(203),ind){ if(Bbuf1.at(ind1+1) == 15){ pack1 = Bbuf1.mid(ind1,36); break; } }}
Cif (ind1 = Bbuf1.indexOf(203),ind)
C// ищет match в src и копирует в dst если найден// возвращает позицию в src или код ошибки < 0int ExtractBlock( const char * src, int srcLen, const char * match, int matchLen, char * dst, int dstLen ){ const char * blk = FindFirstMatch(src, srcLen, match, matchLen); if (!blk) return err_NotFound; if (blk + dstLen > src + srcLen) return err_BadLen; // блок выходит за границы src memmove(dst, blk, dstLen); return blk - src;} // оберточквint ExtractBlock( const char * src, int srcLen, char c1, char c2, char * dst, int dstLen ){ char temp[2] = { c1, c2 }; return ExtractBlock(src, srcLen, temp, 2, dst, dstLen);}
C++ (Qt)QDataStream &operator >>(QDataStream &ds, DnssClass &dnss){ ds >> dnss.head >> dnss.time >> dnss.wx >> dnss.wy >> dnss.wz >> dnss.ax >> dnss.ay >> dnss.az >> dnss.altitude >> dnss.sum; return ds;}
C++ (Qt)QDataStream stream1(&pack1,QIODevice::ReadOnly);stream1.setByteOrder(QDataStream::LittleEndian);stream1 >> dnss;
Cif ((ind1 = Bbuf1.indexOf(203, ind)) != -1)