summaryrefslogtreecommitdiffstats
path: root/src/serialbus/qmodbuspdu.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make pduFromStream work on big endian (again)Dmitry Shachnev2022-06-271-2/+19
| | | | | | | | | | | | | | reinterpret_cast<char *>(&code) works on little endian, but not on big endian, because code is an int (4 bytes value). I fixed this bug earlier in afb7f76efafcb04e430168416d9d74113bde13bc, but it was added back in 2c0bb738e988d84f36169e0103d051745b678479. [ChangeLog][QModbusPdu] Fix reading from stream on big endian systems Pick-to: 6.4 6.3 6.2 5.15 Change-Id: Ic432d5c86aac40ec2acdc07b4c4881967a023966 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QModbusPdu hierarchy: De-inline dtors of polymorphic classesMarc Mutz2022-06-221-0/+20
| | | | | | | | | | ... fixing Clang -Wweak-vtables warnings, which we'll soon add to headersclean. Pick-to: 6.4 Task-number: QTBUG-45582 Change-Id: I3b768548074236b8e3dd22588ef43f8e5d48def9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-101-38/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ie17b09db5a4aa7bb0d33906360f1125e9632425c Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Use up-to date LGPL license headerKai Köhne2021-11-301-11/+14
| | | | | | | | | Remove usages of outdated LGPL3 header that references LICENSES.LGPLv3 instead of LICENSES.LGPL3. Change-Id: I2dd25a1a7d6ad3e3cbb06753bbc839e26f4a7b26 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* Fix 5.15 compile errorKarsten Heimrich2021-03-041-2/+4
| | | | | Change-Id: Iff78d4f410e62328fce04c0a7212aec961425427 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Fix Modbus custom command size calculationKarsten Heimrich2021-02-251-46/+59
| | | | | | | | | | | | | | | | | | | We cannot early return with an invalid PDU if the private minimumDataSize() functions returns a negative value. The negative value might mean we hit a user defined function code, so advance and call the user data size calculater if registered. The broken function was only used by Modbus TCP implementations , so RTU was working correctly since it created the PDU differently. [ChangeLog] Fix Modbus TCP custom command size calculation. Pick-to: 5.15 Fixes: QTBUG-62192 Fixes: QTBUG-91037 Task-number: QTBUG-91214 Change-Id: I2d421e073777306d86a83cd05a289481fa082501 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Update dependencies and fix related issuesAlex Blasche2020-06-101-1/+1
| | | | | Change-Id: I7a84d3acea165128c0a9dcb4dec1929d5fe5aeab Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* QModBusPdu: Fix old-style and downcast compiler warningsAndre Hartmann2019-07-221-9/+9
| | | | | Change-Id: I08beed3bef1e4c96216c5b56a569207587ce0408 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Fix Qt6 buildSona Kurazyan2019-06-241-1/+1
| | | | | | | Added 'Qt::' prefixes where missing. Change-Id: I97d5d9fa78d7c1feaef4caae72b735ea0625a081 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Correct typos in qmodbuspdu.cpp's docThibaut Cuvelier2019-03-201-7/+7
| | | | | Change-Id: I8bbb3baaa568c1331d8945df158d062d68d2eed4 Reviewed-by: André Hartmann <aha_1980@gmx.de>
* Merge remote-tracking branch 'origin/5.11' into 5.12Qt Forward Merge Bot2018-12-111-2/+3
|\ | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: Ia0da4c27d820778cb156a73cbad4fe79f0694267
| * Make pduFromStream work on big endianDmitry Shachnev2018-11-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | (char *) (&code) is pointing to the correct byte on little endian systems, but on big endian it is pointing to the wrong byte. This caused tst_QModbusPdu::testQModbusResponseStreamOperator to fail on big endian. Change-Id: Icf374ed71429154b362fb074fbeb5501ea6095e0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com>
* | Fix various QDoc warnings/errors in QtSerialBusv5.12.0-beta3Alex Blasche2018-10-151-0/+15
|/ | | | | Change-Id: Iee3a9942657abf67c74aabd687b18af5f3e731f2 Reviewed-by: André Hartmann <aha_1980@gmx.de>
* Doc: Fix documentation warningsTopi Reinio2018-03-261-5/+5
| | | | | | | | | | | QDoc in Qt 5.11 uses Clang to parse C++ documentation, and it's capable of resolving templated function signatures; adjust the \fn commands accordingly. Also fix a couple of other minor documentation warnings. Change-Id: I867713a9e805b75bbd57e183aad91d7e21021f0a Reviewed-by: Martin Smith <martin.smith@qt.io>
* QModbusResponse: Silence Clazy warningAndre Hartmann2018-02-121-1/+1
| | | | | | | | | Looks like a false positive, as response is const, otherwise it should not hurt. Change-Id: I8607abe73566141267c1241f6356d0e9e83f9129 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* ModBus: Don't use QByteArray::operator[] on a temporaryv5.10.0-beta2Andre Hartmann2017-10-131-3/+3
| | | | | | | | Found by clazy. Change-Id: Ie1ff78bf4a2371a0650a9029bae256855916b17c Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Updated copyright headersAndre Hartmann2017-02-021-1/+1
| | | | | Change-Id: I7d38491c7ee15a1de788375acf9144c59b507d2a Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-11-161-4/+4
|\ | | | | | | | | | | | | | | | | Conflicts: src/plugins/canbus/peakcan/main.cpp src/plugins/canbus/tinycan/main.cpp src/serialbus/qcanbusframe.h Change-Id: I7a38350688086b5f5cd7072acccb3fa38af76f88
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-11-161-4/+4
| |\ | | | | | | | | | | | | | | | | | | Conflicts: tests/auto/qmodbuspdu/tst_qmodbuspdu.cpp Change-Id: Id97e8ef6a6c176add1eda3738888c69c33f5378c
| | * Fix handling of byte count fieldsSamuel Gaist2016-11-041-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The various byte count fields are all unsigned byte however the incoming data are loaded in a QByteArray which returns signed char. This patch fixes this by converting the field value to quint8. [ChangeLog][Modbus] Fixed handling of packets with payloads longer than 127 bytes. Task-number: QTBUG-54834 Change-Id: I699c4cf0cea9933bef6c040c573d2d6e6a113920 Reviewed-by: André Hartmann <aha_1980@gmx.de>
* | | Unify the \since base line version for qdocAlex Blasche2016-11-161-4/+4
|/ / | | | | | | | | | | | | | | | | | | | | The first stable API release is Qt 5.8. It makes no sense to document the changes before 5.8. Furthermore the meaning of \since 5.8 before this tag was rather unknown. It could have meant the function was changed or added. This double meaning disappears once a compatibility statement is in place. Change-Id: I047e15bdd92a8c1034947b9b6d03439a293af318 Reviewed-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-301-1/+1
|\| | | | | | | | | | | | | Conflicts: src/serialbus/qmodbusrtuserialmaster_p.h Change-Id: Ib7b6b93816942837203d922992ee4b55f27bfec5
| * Fix compilation with MinGW 4.9Robert Loehning2016-06-281-1/+1
| | | | | | | | | | | | Change-Id: I2b49dab5d934c9ff8524c45129f00becef87fd85 Reviewed-by: Ralf Nolden <nolden@kde.org> Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-061-2/+2
|\| | | | | | | Change-Id: I687907747e05cedbd3f9f1c20df95e5de2d5cd48
| * Adjust Pointer and Reference to Qt Coding StyleAndre Hartmann2016-04-221-2/+2
| | | | | | | | | | Change-Id: Ifa233b324a82209cb597b5cf555b4e290b890e10 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Have a means to register a custom data size calculator.Karsten Heimrich2016-03-171-0/+55
|/ | | | | | | | | Adds possibility to: * Override our data size calculation for a function code. * Implement data size calculation for a custom function code. Change-Id: I5611990a7bc10c2e90aef0f52aa1eb7ddf440717 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Properly calculate EncapsulatedInterfaceTransport sizes.Karsten Heimrich2016-02-241-36/+99
| | | | | Change-Id: If2f1a481da506646cdd9d4e65f1e6140c22676c9 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Adjust size calculation for Modbus Encapsulated Interface Transport.Karsten Heimrich2016-02-191-0/+8
| | | | | | | | | It is at least known that the data part of "Read Device Identification" is 3 bytes in size, so as soon as we know we have that sub function code, return the expected size. Change-Id: I1eff9cdadf0538f45533dbabff2787ad34e8f6d8 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Some API and data size calculation fixes.Karsten Heimrich2016-02-171-100/+79
| | | | | | | | | | | | | | | | | | | API: * We pass the PDU already, no need to pass the data part because we can get it from the PDU inside the function. Calculation: * Ignore the fact that "Diagnostics:ReturnQueryData" and "EncapsulatedInterfaceTransport" can be of variable length. A proper fix needs to be employed in the receiving code. * Refactor stream operator into a single function, it was quite similar except {minimum|calculate} data size. * Take into account that only "Diagnostics:ReturnQueryData" and "EncapsulatedInterfaceTransport" are of variable size. Change-Id: I0f958395f10bf4d93cc2436399ddc36c87f1c4da Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Use a more explictit type for data minimum size request.Karsten Heimrich2016-02-171-8/+8
| | | | | | | | Update docs. We do no calculation, it's a simple lookup. Change-Id: Idbaa52c0d37e029c0ea21f7ad616d540ed65cd8d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* qDebug: Add exception byte when streaming exception response.Karsten Heimrich2016-02-171-2/+3
| | | | | Change-Id: I43c8e966d8f1f201c53d9672868a7baedbc6704c Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* doc: Be more explicit what argument types are supported.Karsten Heimrich2016-02-151-10/+15
| | | | | Change-Id: I0e16477923d15bf28df85cdd505a6827c45cabdc Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Remove qdoc related defines, we support the features now.Karsten Heimrich2016-02-151-2/+2
| | | | | Change-Id: I2a847c3452dffcb4bef98271e25f308d4b449106 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Doc fix: Add missing 'relates' context command.Karsten Heimrich2016-01-041-0/+2
| | | | | Change-Id: I957e20b901cb49ffc59ff359c62df799913864dd Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Fix documentation, remove superfluous include.Karsten Heimrich2015-12-091-1/+1
| | | | | Change-Id: I841fa87393ea4a1c3d0e183820e3f65bde6e7d5b Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Fix documentation for QModbusPdu::ExceptionByteAlex Blasche2015-12-021-2/+7
| | | | | | | | | QDoc cannot handle default initialised member variables. This feature is new in C++. This patch is a work-around. Task-number: QTBUG-49732 Change-Id: I0bd2ac282bafbb27de290dc27d3b048512145940 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Return the real function code without the exception byte.Karsten Heimrich2015-12-011-25/+43
| | | | | Change-Id: Ifb4f0964f47b48f0cb9b33056c732a039cbaee69 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Improve the QModbusPdu and derived classes documentationAlex Blasche2015-11-271-9/+25
| | | | | | | | | | | | | | | | | | | | | | Variadic templates cause qdoc to choke. Documenting them at all is challenging at best. The variadic ctor's will not be documented whereas the two public function (using variadic templates) will be documented. The ctors have been shifted because qdoc stops working once it encounters such a template. This would cause subsequent functions in the same class to not appear at all. The signature of the to-be-documented functions has been simplified so that qdoc recognizes them. It causes some information loss but the attached code snippets should cover most issues. The not documented ctors remain in the code base to keep the warnings in the qdoc output. Every other qdoc warning related to the same classes has been fixed. Task-number: QTBUG-47085 Change-Id: Iff5355fa62d6a54feec565f52c5869c973cb1514 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Align size condition and according comment.Karsten Heimrich2015-11-241-2/+2
| | | | | Change-Id: Ifb18427cc53c9921542e4daef0e809c4d076fd3d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Rename QModbusServer::processPrivateModbusRequest()Alex Blasche2015-11-181-1/+1
| | | | | | | | | It is renamed to processPrivateRequest() to have a better naming analogy towards processRequest(). Change-Id: I65975b485b1863d30a434a42ceb6678f834d440a Reviewed-by: Ralf Nolden <nolden@kde.org> Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Fix QModbusResponse stream in operatorAlex Blasche2015-11-171-1/+2
| | | | | | | | QModbusExceptionResponses were not properly streamed as the exception character of the response was not recognized. Change-Id: Ie64c99b54e7f18a41e39987f2e39122c22e27f64 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Implement missing PDU length calculations, fix stream operators.Karsten Heimrich2015-11-171-14/+35
| | | | | Change-Id: I55633a7e147383dbb8de2063fc781d895009d790 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Make the return value of minimumDataSize() signed.Karsten Heimrich2015-11-111-30/+48
| | | | | | | | | | Done to be able to report an error following the idea of calculateDataSize(...). Fix stream operator implementation. Adjust auto-test. Adjust minimumDataSize(...) to be able to handle unknow minimum sizes for certain function codes. Change-Id: I6dbbd7c5e609557f21dcd8a81609c863e6eb6747 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Update and fix documentation. Add TODO's.Karsten Heimrich2015-11-061-16/+12
| | | | | Change-Id: I2734cd34ba0cddb0d3f0778d7bf4a480b4a7a834 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Remove extra newlines. Whitespace only change.Karsten Heimrich2015-11-061-4/+0
| | | | | Change-Id: I941cfc5d30c65a6805f289263a6b0c1774f642b4 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Add NegativeAcknowledge (7) missing exception codeRalf Nolden2015-11-051-1/+6
| | | | | | | | | | | Add NegativeAcknowledge to the enum of known exception codes. The code is not included in the current modbus spec but is widely used in devices that use it as a response for programming commands (such as Schneider Electric). The according negative acknowledge message counter is also already present which accompanies this exception code. Change-Id: Ida86914bfe073601e2a286d92978f547e3ae7b60 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Do not overload transmission and Modbus exception codesAlex Blasche2015-11-051-2/+3
| | | | | | | QModbusReply::ProtocolError stands for Modbus exception codes. Change-Id: I2dfb89ebe574c8e83b9f8621bc4a451e4663dffa Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Add a queue system to RTU masterAlex Blasche2015-11-051-0/+1
| | | | | | | | | | | | | The serial bus protocol specifies that each request is followed by a response (unless a request does not require a response e.g. broadcast requests). Therefore if the user sends of multiple requests the master has to enqueue them for later sending. Timeout handling, retry after timeout and send limitations on bus will be added later on. Change-Id: Ib1fa83315dca637ac071832de5e05762ae972e65 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Move exceptionCode() from QModbusExceptionResponse to QModbusPduAlex Blasche2015-11-041-6/+6
| | | | | Change-Id: I8e50417ba4973721f7d9f40f4d87d11c0b705925 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Extend QModbusPdu et al in preparation of upcoming RTU client codeAlex Blasche2015-11-041-0/+12
| | | | | | | | - New error messages added - Convenience function for exception access added Change-Id: Ibcccbb4bfeebe476f305ce230b86636c7bc6276e Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>