Results 1 to 6 of 6

Thread: transfer binary file from pc(ubuntu) to raspberry(rasbian) without lrzsz or kermit, e

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: transfer binary file from pc(ubuntu) to raspberry(rasbian) without lrzsz or kermi

    I don't think either QProcess nor system() understand shell syntax like ">", they simply execute a single program.

    Have you tried using "dd" with "if=file_to_send of=/dev/ttyUSB0"?

    Cheers,
    _

  2. #2
    Join Date
    Jan 2019
    Posts
    11
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: transfer binary file from pc(ubuntu) to raspberry(rasbian) without lrzsz or kermi

    Thank you for your reply.
    i am trying with "dd" but i always receive the same error message "cannot open /dev/ttyUSB0: Device or resource busy". May be i cannot utilize in the same time with 2 differents(QSerialPort and System/or QProcess) process the device /dev/ttyUSB0. do you have any idea?
    Thank you!

    this is my code cpp.
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9.  
    10. m_stdOut_Proc = "";
    11. m_stdOut_Serial = "";
    12. m_command = "";
    13.  
    14. m_serial = new QSerialPort(this);
    15. openSerialPort();
    16.  
    17. }
    18.  
    19. MainWindow::~MainWindow()
    20. {
    21. if(m_serial->isOpen())
    22. m_serial->close();
    23. delete ui;
    24. }
    25.  
    26. void MainWindow::openSerialPort()
    27. {
    28. m_serial->setPortName("/dev/ttyUSB0");
    29. m_serial->setBaudRate(QSerialPort::Baud115200);
    30. m_serial->setDataBits(QSerialPort::Data8);
    31. m_serial->setParity(QSerialPort::NoParity);
    32. m_serial->setStopBits(QSerialPort::OneStop);
    33. m_serial->setFlowControl(QSerialPort::NoFlowControl);
    34.  
    35. connect(m_serial, &QSerialPort::readyRead, this, &MainWindow::readyreadStdOut_QSerial);
    36. if(m_serial->open(QIODevice::ReadWrite))
    37. qDebug()<<"Device opened successful";
    38. else
    39. {
    40. qDebug()<<"Device opened fail";
    41. return;
    42. }
    43. }
    44.  
    45. void MainWindow::readyreadStdOut_QSerial()
    46. {
    47. m_stdOut_Serial = m_serial->readAll();
    48. qDebug()<< m_stdOut_Serial;
    49. ui->labelQSerial->setText(m_stdOut_Serial);
    50. }
    51.  
    52. void MainWindow::on_btnWrite_clicked()
    53. {
    54. m_command = ui->lineEditCommand->text() +"\r";
    55. m_serial->write(m_command.toLocal8Bit());
    56. ui->lineEditCommand->setText("");
    57. }
    58.  
    59. void MainWindow::on_btnQuitApp_clicked()
    60. {
    61. qApp->quit();
    62. }
    63.  
    64. void MainWindow::on_btnRecv_clicked() //after connection and login to raspberry. i run this command in console raspi
    65. {
    66. m_command = "dd bs=1 count=138333 | base64 -d > file_to_receive\r";
    67. m_serial->write(m_command.toLocal8Bit());
    68. }
    69.  
    70.  
    71. void MainWindow::on_btnFirmware_clicked() // i try to start this command in shell pc but it doesn't work. i receive a error message: "cannot open /dev/ttyUSB0: Device or resource busy"
    72. {
    73. system("dd if=file_to_send of=/dev/ttyUSB0");
    74. }
    To copy to clipboard, switch view to plain text mode 



    this is my h-file:
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include <QSerialPort>
    6. #include <QSerialPortInfo>
    7.  
    8. #include <QDebug>
    9. #include <QDataStream>
    10. #include <QByteArray>
    11.  
    12. namespace Ui {
    13. class MainWindow;
    14. }
    15.  
    16. class MainWindow : public QMainWindow
    17. {
    18. Q_OBJECT
    19.  
    20. public:
    21. explicit MainWindow(QWidget *parent = nullptr);
    22. ~MainWindow();
    23.  
    24. private slots:
    25. void readyreadStdOut_QSerial();
    26.  
    27. void on_btnWrite_clicked();
    28. void on_btnQuitApp_clicked();
    29. void on_btnFirmware_clicked();
    30. void on_btnRecv_clicked();
    31.  
    32. private:
    33. void writeDate_test(const QByteArray &data);
    34. void openSerialPort();
    35.  
    36. private:
    37. Ui::MainWindow *ui;
    38.  
    39. QSerialPort *m_serial;
    40. QString m_stdOut_Serial;
    41. QString m_command;
    42.  
    43.  
    44. };
    45.  
    46. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2019
    Posts
    11
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: transfer binary file from pc(ubuntu) to raspberry(rasbian) without lrzsz or kermi

    nobody can help me?

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: transfer binary file from pc(ubuntu) to raspberry(rasbian) without lrzsz or kermi

    It is normal if You have COM port opened by application and trying to open this port from another process.

  5. The following user says thank you to Lesiok for this useful post:

    malone (28th May 2019)

  6. #5
    Join Date
    Jan 2019
    Posts
    11
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: transfer binary file from pc(ubuntu) to raspberry(rasbian) without lrzsz or kermi

    thank you for your reply. i have found out a solution.


    Added after 4 minutes:


    thank you very much anda_skoa,
    you given me a solution but i misused it.
    Last edited by malone; 28th May 2019 at 15:15.

Similar Threads

  1. transfer file via wi fi
    By montanaro in forum Newbie
    Replies: 2
    Last Post: 17th February 2019, 16:15
  2. How to install Qt 4.7 from binary on Ubuntu 11.04
    By ibn-tashfin in forum Installation and Deployment
    Replies: 12
    Last Post: 31st March 2011, 13:55
  3. File Transfer in Qt
    By Rajeshsan in forum Qt Programming
    Replies: 6
    Last Post: 11th February 2011, 04:13
  4. Replies: 2
    Last Post: 2nd April 2008, 17:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.