Okay. I think i found the source of problem. Calculation of send timeout is incorrect.
Here is the calculation code: http://code.qt.io/cgit/qt/qtserialbus.git/tree/src/serialbus/qmodbusrtuserialmaster_p.h#n294 // Example: 9600 baud, 11 bit per packet -> 872 char/sec // so: 1000 ms / 872 char = 1.147 ms/char * 3.5 character m_sendTimer.start((1000. / (qreal(m_baudRate) / 11.)) * m_current.adu.size()); Which in my case (115200 and 8 bytes of data) gives 0.7 ms. And after conversion to int, it becomes zero. So m_sendTimer is fired up immediately, which brings us to to this code: http://code.qt.io/cgit/qt/qtserialbus.git/tree/src/serialbus/qmodbusrtuserialmaster_p.h#n323 } else if (m_current.bytesWritten < m_current.adu.size()) { qCDebug(QT_MODBUS) << "(RTU client) Send failed:" << m_current.requestPdu; if (m_current.numberOfRetries <= 0) { if (m_current.reply) { m_current.reply->setError(QModbusDevice::TimeoutError, QModbusClient::tr("Request timeout.")); } So there comes a premature timeout. I experimented with a timeout and found that even a value of 15-20ms does not give stable results. only the value of around 50ms gives a stable result in my case. I suppose that timeout calculation must include some additional minimum time constant. I will report this bug. Thank you all for the help ) 2016-05-31 17:15 GMT+05:00 Ralf Nolden <[email protected]>: > Am Dienstag, 31. Mai 2016, 13:53:15 schrieb Denis Shienkov: > > > But why ? > > > > I don't know.. maybe the Qt Modbus Master closes the connection without > > waiting of data send, > > > > maybe something else.. > > > > PS: I just have checked the QSerialPort autotests with the PL2303 on > > Windows - all worked. > > > > PS2: You can try to use the Terminal Example (from the Qt Serial Port) > > with the Rx/Tx connected, > > > > to check that your serial port works. > > If you have a second PC around, try running the slave example there and > connect them with a second adapter, then try the master example to see if > your > conection works between those two computers. > > At any rate. the modbus master is doing the right thing if the error comes > from the serial port. We can't just ignore port errors in cases where the > returned response theoretically matches the expected results :) > > > > > 31.05.2016 13:17, Dmitry Shapovalov пишет: > > > Yep. That's right. It is ERROR_OPERATION_ABORTED. > > > But why ? Any other application works as expected with this hardware. > > > > > > And i confirm that 0x01040000000131ca and 0x0104024c494c06 are correct > > > request and response. > > > > > > > > > 2016-05-31 15:05 GMT+05:00 Denis Shienkov <[email protected] > > > > > > <mailto:[email protected]>>: > > > Seems, this: > > > > qt.modbus: (RTU server) QSerialPort error: > > > > QSerialPort::SerialPortError(ResourceError) "Операция> > > > ввода/вывода была прервана из-за завершения потока команд или по > > > запросу приложения." > > > > > > It is an 'ERROR_OPERATION_ABORTED', that can be caused by > > > > > > ::CancelIo() (e.g. when the serial port closes) or by a HW > problems. > > > > > > BR, > > > > > > Denis > > > > > > 31.05.2016 12:23, Dmitry Shapovalov пишет: > > >> Thanks for reply Ralf. Email more preferable for me. > > >> > > >> Can you tell me what type of adapter you are using? Which version > > >> of qtserialport are you using? Maybe my problem is related to the > > >> type of serial port adapter. I tried use arduino with different > > >> usb-uart chips(ch430 and pl2303), but unsuccessfully. > > >> > > >> Here is output of qt modbus master example > > >> > > >> Запускается > > >> > C:\Qt\Examples\Qt-5.6\qtserialbus\serialbus\modbus\build-master-Deskt > > >> op_Qt_5_6_0_MinGW_32bit-Debug\debug\modbusmaster.exe... qt.modbus: > > >> (RTU client) Sent Serial PDU: 0x0400000001 > > >> qt.modbus.lowlevel: (RTU client) Sent Serial ADU: > 0x01040000000131ca > > >> qt.modbus: (RTU client) Send failed: 0x0400000001 > > >> qt.modbus: (RTU server) QSerialPort error: > > >> QSerialPort::SerialPortError(ResourceError) "Операция > > >> ввода/вывода была прервана из-за завершения потока команд или по > > >> запросу приложения." > > >> qt.modbus.lowlevel: (RTU client) Response buffer: "01" > > >> qt.modbus: (RTU client) Modbus ADU not complete > > >> qt.modbus.lowlevel: (RTU client) Response buffer: "0104024c494c06" > > >> qt.modbus: (RTU client) Received ADU: "0104024c494c06" > > >> qt.modbus: (RTU client) Cannot match response with open request, > > >> ignoring > > >> > > >> Look like it actually sends request, but qtserialport reports > > >> error, so qtserialbus(modbus) ignores response. > > >> > > >> > > >> 2016-05-31 11:59 GMT+05:00 Ralf Nolden <[email protected] > > >> > > >> <mailto:[email protected]>>: > > >> Am Dienstag, 31. Mai 2016, 09:34:19 schrieb Dmitry Shapovalov: > > >> > Hello, > > >> > can someone confirm that modbus over serial port is working > > >> > > >> on windows ? > > >> I have tested modbus over serial port on windows with two > > >> Schneider Electric > > >> PLCs, a Twido and a Premium, both with TCP and RS485. We > > >> could evaluate your > > >> problems on IRC if you want. > > >> > > >> > all my experiments led me to the thought that it is > > >> > > >> absolutely broken. > > >> > > >> > i am using arduno as a modbus device. i tested it with > > >> > > >> qmodbus and modbus > > >> > > >> > poll. works great. but when i try to use modbus examples > from > > >> > qt(qtserialbus/examples/serialbus/modbus/master), look like > > >> > > >> it can not send > > >> > > >> > request. > > >> > i tried release(5.6) and git version of qtserialbus and > > >> > > >> qtserialport > > >> > > >> > modules with no luck. > > >> > > > >> > i am using windows 7 on virtualbox. > > >> > arduino modbus library from here > > >> > > https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino > > >> > arduino sketch http://pastebin.com/FHW3B7TX > > >> > > > >> > it's me or it's really broken ? > > >> > > >> -- > > >> Kind regards, > > >> > > >> Ralf Nolden > > >> > > >> _______________________________________________ > > >> Development mailing list > > >> [email protected] <mailto:[email protected] > > > > >> http://lists.qt-project.org/mailman/listinfo/development > > >> > > >> _______________________________________________ > > >> Development mailing list > > >> [email protected] <mailto:[email protected]> > > >> http://lists.qt-project.org/mailman/listinfo/development > > > > > > _______________________________________________ > > > Development mailing list > > > [email protected] <mailto:[email protected]> > > > http://lists.qt-project.org/mailman/listinfo/development > > > > > > _______________________________________________ > > > Development mailing list > > > [email protected] > > > http://lists.qt-project.org/mailman/listinfo/development > > -- > Kind regards, > > Ralf Nolden > > _______________________________________________ > Development mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/development > -- -- With Best Regards Dmitry Shapovalov
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
