• 大小: 100KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: 其他
  • 标签: GPS  qt  

资源简介

飞凌-MX6UL GPS 模块的测试方法,请先确保已经连接 GPS 天线(最好将天线的接收端放到窗外)。运行 GPS 测试程序

资源截图

代码片段和文件信息

#include “gps.h“
#include “ui_gps.h“

#define USE_BEIJING_TIMEZONE


gps::gps(QWidget *parent) :
    QWidget(parent)
    ui(new Ui::gps)
{
    ui->setupUi(this);
    m_timer = new QTimer;
    connect(m_timer SIGNAL(timeout()) this SLOT(read_sermios()));
}

gps::~gps()
{
    printf(“~gps\n“);
    m_timer->stop();
    delete ui;
}

void gps::on_pb_read_clicked()
{
    printf(“read\n“);
    set_termios();
     m_timer->setInterval(1000);
    m_timer->start();
}

void gps::on_pb_close_clicked()
{
    printf(“close\n“);
    m_timer->stop();
  // ui->tedit_output->clear();
}

int gps:: set_termios()
{
    int bound=ui->cmb_bound->currentText().toInt();
    QString m_com=“/dev/“ + ui->cmb_com->currentText();
    const char *com_name=m_com.toUtf8().constData();
       fd = open(com_name O_RDWR | O_NONBLOCK| O_NOCTTY | O_NDELAY);
        if(fd<0)
       {
          QMessageBox::about(NULL “About“ “com open error“);
          return -1;
        }
     struct termios terminfo;

      if (bound == 4800)
      {
          terminfo.c_cflag = B4800 | CRTSCTS | CS8 | CLOCAL | CREAD;/*ctrol flag*/
      }
      if (bound == 9600)
      {
          terminfo.c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD;/*ctrol flag*/
      }
      if (bound == 19200)
      {
          terminfo.c_cflag = B19200| CRTSCTS | CS8 | CLOCAL | CREAD;/*ctrol flag*/
      }
      if (bound == 38400)
      {
          terminfo.c_cflag = B38400 | CRTSCTS | CS8 | CLOCAL | CREAD;/*ctrol flag*/
      }

      terminfo.c_iflag = IGNPAR; /*input flag*/
      terminfo.c_oflag = 0; /*output flag*/
      terminfo.c_lflag = 0;/* local flag */
      terminfo.c_cc[VMIN]=1;
      terminfo.c_cc[VTIME]=0;

      tcflush(fd TCIFLUSH);/*clear */
      tcsetattr(fdTCSANOW&terminfo);/*set attrib   */

      return 1;
    }

void gps::read_sermios()
{
     gps_info gpsinfo;
     int i=0j=0nread=0;
     bool valid_flag=false;
     char c;
     char buf[1024];

     nread=read(fd&c1);// read sermios
     if(nread>0)
     {
         buf[i++] = c;
         for(j=0;j<1024;j++)
        {
         nread=read(fd&c1);// read sermios
         if(nread>0)
         {
           buf[i++] = c;
           j++;
           if(c == ‘\n‘ )
             {
                 strncpy(m_bufbufi);
                 i=0;
                 j=0;
                 valid_flag=true;
                 break;
              }
         }
        }
         if (j>=1024)
         {
             printf(“baudrate error\n“);
             ui->tedit_output->setText(“No data availableplease check the baudrate.“);
             m_timer->stop();
             return;
         }
     }
     printf(“%s\n“&buf);

     if(valid_flag==true)
     {
         parse_gps(m_buf&gpsinfo);
         if ( gpsinfo.D.year > 1900 && gpsinfo.D.year < 2100)
         {
           QString date = QString(“%1-%2-%3“).arg(gpsinfo.D.year).arg(gpsinfo.D.month).arg(gpsinfo.D.day);
           QString time = QString(“%1:%2:%3“).arg(gpsinfo.D.hour).arg(gpsinfo.D.minut

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件         13  2016-05-26 17:18  qt-gps\.git\COMMIT_EDITMSG

     文件        279  2016-05-26 17:18  qt-gps\.git\config

     文件         73  2016-05-26 17:18  qt-gps\.git\description

     文件         38  2016-05-26 17:18  qt-gps\.git\HEAD

     文件        452  2016-05-26 17:18  qt-gps\.git\hooks\applypatch-msg.sample

     文件        896  2016-05-26 17:18  qt-gps\.git\hooks\commit-msg.sample

     文件        189  2016-05-26 17:18  qt-gps\.git\hooks\post-update.sample

     文件        398  2016-05-26 17:18  qt-gps\.git\hooks\pre-applypatch.sample

     文件       1704  2016-05-26 17:18  qt-gps\.git\hooks\pre-commit.sample

     文件       4898  2016-05-26 17:18  qt-gps\.git\hooks\pre-rebase.sample

     文件       1239  2016-05-26 17:18  qt-gps\.git\hooks\prepare-commit-msg.sample

     文件       3611  2016-05-26 17:18  qt-gps\.git\hooks\update.sample

     文件        577  2016-05-26 17:18  qt-gps\.git\index

     文件        240  2016-05-26 17:18  qt-gps\.git\info\exclude

     文件        517  2016-05-26 17:18  qt-gps\.git\logs\HEAD

     文件        297  2016-05-26 17:18  qt-gps\.git\logs\refs\heads\DualLite_GPS_optimize

     文件        192  2016-05-26 17:18  qt-gps\.git\logs\refs\heads\master

     文件        140  2016-05-26 17:18  qt-gps\.git\logs\refs\remotes\origin\DualLite_GPS_optimize

     文件        626  2016-05-26 17:18  qt-gps\.git\objects\26\0d07dbb6fcc2e17c4b3c403941a38df75d28c4

     文件      16121  2016-05-26 17:18  qt-gps\.git\objects\7b\0ef8fdcab2999b44c19a25839b572c83416fc7

     文件       2413  2016-05-26 17:18  qt-gps\.git\objects\92\9d0227a84533b6183c63cc0b0bb5543277c315

     文件        225  2016-05-26 17:18  qt-gps\.git\objects\a0\a4e68baa22e90599b60d18c5703b24ec1846a2

     文件        175  2016-05-26 17:18  qt-gps\.git\objects\a8\1803e276a44c80b801dbf4aec127367a61639f

     文件       1436  2016-05-26 17:18  qt-gps\.git\objects\pack\pack-c93db5e0746856903f8310783653d2fef16bd5cf.idx

     文件      24746  2016-05-26 17:18  qt-gps\.git\objects\pack\pack-c93db5e0746856903f8310783653d2fef16bd5cf.pack

     文件         94  2016-05-26 17:18  qt-gps\.git\packed-refs

     文件         41  2016-05-26 17:18  qt-gps\.git\refs\heads\DualLite_GPS_optimize

     文件         41  2016-05-26 17:18  qt-gps\.git\refs\heads\master

     文件         41  2016-05-26 17:18  qt-gps\.git\refs\remotes\origin\DualLite_GPS_optimize

     文件         32  2016-05-26 17:18  qt-gps\.git\refs\remotes\origin\HEAD

............此处省略43个文件信息

评论

共有 条评论