添加debug重定向,添加命令行
This commit is contained in:
@@ -4,43 +4,43 @@
|
||||
#include "base/mycfg.h"
|
||||
#include "QDebug"
|
||||
|
||||
|
||||
void if_uart::init()
|
||||
{
|
||||
if(serial_==nullptr)
|
||||
if (serial_ == nullptr)
|
||||
{
|
||||
serial_=new QSerialPort();
|
||||
serial_->setPortName(com);
|
||||
serial_->setBaudRate(bsp);
|
||||
serial_->setParity(QSerialPort::NoParity);
|
||||
serial_->setDataBits(QSerialPort::Data8);
|
||||
serial_->setStopBits(QSerialPort::OneStop);
|
||||
serial_->setFlowControl(QSerialPort::NoFlowControl);
|
||||
if(serial_->open(QIODevice::ReadWrite))
|
||||
{
|
||||
connect(serial_,&QSerialPort::readyRead,this,&if_uart::ready_read_cb);
|
||||
qDebug("uart \"%s\" bsp=%d",serial_->portName().toLocal8Bit().data(), bsp);
|
||||
serial_open=true;
|
||||
} else
|
||||
{
|
||||
qWarning()<<"uart open failed."<<serial_->portName();
|
||||
}
|
||||
serial_ = new QSerialPort();
|
||||
serial_->setPortName(com);
|
||||
serial_->setBaudRate(bsp);
|
||||
serial_->setParity(QSerialPort::NoParity);
|
||||
serial_->setDataBits(QSerialPort::Data8);
|
||||
serial_->setStopBits(QSerialPort::OneStop);
|
||||
serial_->setFlowControl(QSerialPort::NoFlowControl);
|
||||
if (serial_->open(QIODevice::ReadWrite))
|
||||
{
|
||||
connect(serial_, &QSerialPort::readyRead, this, &if_uart::ready_read_cb);
|
||||
qDebug("uart \"%s\" bsp=%d", serial_->portName().toLocal8Bit().data(), bsp);
|
||||
serial_open = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "uart open failed." << serial_->portName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int if_uart::write(myarray data)
|
||||
{
|
||||
if((nullptr == serial_)||(serial_open!=true))
|
||||
if ((nullptr == serial_) || (serial_open != true))
|
||||
{
|
||||
//qWarning() << "Can’t send data , TcpClient socket not connect.";
|
||||
// qWarning() << "Can’t send data , TcpClient socket not connect.";
|
||||
return 0;
|
||||
}
|
||||
qDebug("uart send:%s",data.toHex(' ').data());
|
||||
qDebug("uart send:%s", data.toHex(' ').data());
|
||||
|
||||
int wb = serial_->write(data);
|
||||
if((!serial_->flush())||(wb!=data.size()))
|
||||
if ((!serial_->flush()) || (wb != data.size()))
|
||||
{
|
||||
//qWarning() << "uart data:"<<data.toHex(' ')<<"not sent.";
|
||||
// qWarning() << "uart data:"<<data.toHex(' ')<<"not sent.";
|
||||
}
|
||||
return wb;
|
||||
}
|
||||
@@ -48,21 +48,19 @@ int if_uart::write(myarray data)
|
||||
void if_uart::ready_read_cb()
|
||||
{
|
||||
QByteArray data = serial_->readAll();
|
||||
qDebug("uart recv:%s",data.toHex(' ').data());
|
||||
qDebug("uart recv:%s", data.toHex(' ').data());
|
||||
if (irq_fun)
|
||||
{
|
||||
irq_fun(myarray(data));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
InterFace *if_uart_hmi()
|
||||
{
|
||||
static InterFace *if_ = nullptr;
|
||||
if (if_ == nullptr)
|
||||
{
|
||||
if_ = new if_uart("/dev/ttySTM1",115200);
|
||||
if_ = new if_uart("/dev/ttySTM1", 115200);
|
||||
// QTimer::singleShot(0, if_, &InterFace::init);
|
||||
if_->init();
|
||||
}
|
||||
@@ -71,18 +69,17 @@ InterFace *if_uart_hmi()
|
||||
|
||||
if_export(uart_hmi, if_uart_hmi);
|
||||
|
||||
|
||||
|
||||
InterFace *if_uart_host()
|
||||
{
|
||||
static InterFace *if_ = nullptr;
|
||||
if (if_ == nullptr)
|
||||
{
|
||||
int bsp=57600;
|
||||
if(syscfg()->uart_bsp!=0){
|
||||
bsp=syscfg()->uart_bsp;
|
||||
int bsp = 57600;
|
||||
if (syscfg()->uart_bsp != 0)
|
||||
{
|
||||
bsp = syscfg()->uart_bsp;
|
||||
}
|
||||
if_ = new if_uart("/dev/ttySTM2",bsp);
|
||||
if_ = new if_uart("/dev/ttySTM2", bsp);
|
||||
// QTimer::singleShot(0, if_, &InterFace::init);
|
||||
if_->init();
|
||||
}
|
||||
@@ -91,14 +88,12 @@ InterFace *if_uart_host()
|
||||
|
||||
if_export(uart_host, if_uart_host);
|
||||
|
||||
|
||||
|
||||
InterFace *if_uart_m4()
|
||||
{
|
||||
static InterFace *if_ = nullptr;
|
||||
if (if_ == nullptr)
|
||||
{
|
||||
if_ = new if_uart("/dev/ttyRPMSG0",115200);
|
||||
if_ = new if_uart("/dev/ttyRPMSG0", 115200);
|
||||
// QTimer::singleShot(0, if_, &InterFace::init);
|
||||
if_->init();
|
||||
}
|
||||
@@ -106,4 +101,3 @@ InterFace *if_uart_m4()
|
||||
}
|
||||
|
||||
if_export(uart_m4, if_uart_m4);
|
||||
|
||||
|
Reference in New Issue
Block a user