Hello Community,
i'm trying to transfer a binary file or file from my PC(ubuntu OS) to an embedded system raspberry(raspbian OS) over serial port. Physically, my PC is connected to my raspberry through FTDI Chip TTL-232R-Rpi Kabel(USB-to-UART).
I use an own application on my pc developed over qtcreator with QSerialPort library to configure and open the device /dev/ttyUSB0(COM3 for Windows OS) of my pc.
m_serial = new QSerialPort(this)
m_serial->setPortName("/dev/ttyUSB0)
m_serial->setBaudRate(QSerialPort::Baud115200);
m_serial->setDataBits(QSerialPort::Data8);
m_serial->setParity(QSerialPort::NoParity);
m_serial->setStopBits(QSerialPort::OneStop);
m_serial->setFlowControl(QSerialPort::NoFlowControl);
m_serial->open(QIODevice::ReadWrite);
m_serial = new QSerialPort(this)
m_serial->setPortName("/dev/ttyUSB0)
m_serial->setBaudRate(QSerialPort::Baud115200);
m_serial->setDataBits(QSerialPort::Data8);
m_serial->setParity(QSerialPort::NoParity);
m_serial->setStopBits(QSerialPort::OneStop);
m_serial->setFlowControl(QSerialPort::NoFlowControl);
m_serial->open(QIODevice::ReadWrite);
To copy to clipboard, switch view to plain text mode
All work fine. I can connect the pc to the raspberry with login. The serial connection currently is working but this is controlled by the Raspberry console like a remote connection to Raspberry and goes directly to console and login(raspberry).
On my PC, being connected on the raspberry console i run the following code "dd bs=1 count=138333 | base64 -d > myfile_to_receive \r"
void MainWindow::on_btnRecv_clicked()
{
m_command = "dd bs=1 count=138333 | base64 -d > test_32_test \r";
m_serial->write(m_command.toLocal8Bit());
}
void MainWindow::on_btnRecv_clicked()
{
m_command = "dd bs=1 count=138333 | base64 -d > test_32_test \r";
m_serial->write(m_command.toLocal8Bit());
}
To copy to clipboard, switch view to plain text mode
to wait and receive via serial port all binary data from pc, it works fine.
Unfortunately, when i send data from my pc using the same application but via QProcess or system with the following code "cat file_to_send > /dev/ttyUSB0"
system("cat file_to_send > /dev/ttyUSB0");
system("cat file_to_send > /dev/ttyUSB0");
To copy to clipboard, switch view to plain text mode
i cannot send my file and i get the message "cannot create /dev/ttyUSB0: Device or resource busy". I'm trying to remove the file LCK..ttyUSB0 created by QSerialport but nothing works well(Sending).
Can somebody help me, please?
Thank you in advance
N.B: transfer binary file over serial port without protocol like kermit, or zmodem or putty, etc.... as also no ethernet or ssh connection
Bookmarks