summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup constructors and destructors.Karsten Heimrich2016-01-291-1/+0
| | | | | | | | | | | | - replace Q_DECL_EQ_DEFAULT/DELETE with explicit '= default/delete' - DebugHandler: no default ctor necessary - QModbusCommEvent: fix = default that should have been = delete - remove defaulted ctors/ dtors, where possible, matching the current module style Change-Id: I7d6fd5b8404cbb5c2741927ec676c6f8a1f75c22 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Remove meta-type registration and add it where used.Karsten Heimrich2016-01-131-1/+3
| | | | | Change-Id: I96af842dd7c61a963cb9ea88145cc3e35193a518 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Fix warning about missing meta-type registration.Karsten Heimrich2016-01-131-0/+6
| | | | | Change-Id: I210debb0bd8133dcba1f9dc61ac1eb78032d53d0 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Provide default values for QCanbusDevice::Filter members.Alex Blasche2016-01-081-0/+6
| | | | | | | | | The default values are as permissive as possible from a filtering perspective. Change-Id: Ie471adc72f6c4957330af74d3108e2808dde290f Reviewed-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Implement the ClearOverrunCounterAndFlag sub-function code.Karsten Heimrich2016-01-081-0/+8
| | | | | | | | | Even if machine specific, we can implement it software side; as our server can and should be a total of all available and documented functionality as described by the Modbus specs. Change-Id: I97b9eb8f6495b6ce9c2a858d22326f236d9b044b Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Adjust header includes according to our coding conventions.Karsten Heimrich2016-01-083-4/+4
| | | | | Change-Id: Id2c01e09e5d24bf2ecce57211cb13299478544e3 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Implement auto-test for private sendRequest function.Karsten Heimrich2016-01-081-7/+50
| | | | | Change-Id: I9bbb32645048e78bad35b8e3ef307f70c431f711 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Resolve TODO's. Merge both error code enums, update code.Karsten Heimrich2016-01-081-17/+17
| | | | | Change-Id: I52bfdcd84d2164b45754fdfe85a96679f64133f2 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Rename function errorText() -> errorString()Karsten Heimrich2016-01-061-10/+10
| | | | | | | Most if not all Qt functions use the '...String()' suffix. Change-Id: I8f98e16d27e42c5246ee17b088949f779ccfb224 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* The number of retries must be greater than or equal to 0.Karsten Heimrich2016-01-061-0/+12
| | | | | Change-Id: I29b7f265baa8028355aaab29c760bf82332c86cc Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Fix typos.Karsten Heimrich2016-01-061-2/+2
| | | | | Change-Id: Ib31a522f78fd9905e2a3d8d92b8fe10bcf7354d7 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Remove similar test-cases, add timeoutChanged() signal test.Karsten Heimrich2016-01-061-7/+4
| | | | | Change-Id: I9a3ed5dd0de14f72bf52eb0a70cd352ab505d1d6 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Remove Modbus and ModbusDevice prefix.Karsten Heimrich2016-01-041-2/+2
| | | | | | | | The naming is already obvious, no need to duplicate the protocol or base class name. Change-Id: I855c65379992c93c3abaf5c2be57cd192a23fb11 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Add comment. Fix combined virtual and override usage.Karsten Heimrich2016-01-041-8/+8
| | | | | Change-Id: I17471daa31cddc0e6beeb9dcd5b5b921e0159e41 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Enable DiagnosticsRequest-RestartCommunicationsOption auto-test.Karsten Heimrich2016-01-041-19/+21
| | | | | Change-Id: I7ebadb8bee9eee171b174af81a3eb0411c8c8f40 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Implement minimum response timeout, update auto-test.Karsten Heimrich2015-12-181-3/+7
| | | | | Change-Id: I4f46cf74dd486ca56ea17437e15638246283363e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QCanBusFrame: check more error conditions in isValid()Rolf Eike Beer2015-12-171-15/+51
| | | | | | | | | Flag frames with too long payload, or too long frame id as invalid. Change-Id: I3ebc6d6a1d36d259c21f3913fd2315d93d2046bf Reviewed-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QCanBusFrame: automatically set extended frame format by frame idRolf Eike Beer2015-12-161-2/+17
| | | | | | | | | If a frame id is set that requires the extended frame format then also set this flag. This makes it harder to accidentially construct an invalid frame. Change-Id: Ie65b5441fcad98efc8dbea59252b8057b36ddc69 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Return the real function code without the exception byte.Karsten Heimrich2015-12-011-98/+106
| | | | | Change-Id: Ifb4f0964f47b48f0cb9b33056c732a039cbaee69 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Move QModbusClient responseTimer into QModbusRtuSerialMasterAlex Blasche2015-11-241-21/+1
| | | | | | | | | | The TCP client doesn't use a queue system for requests and therefore needs one timer per request. Therefore the abstraction offered by QModbusClient is not suitable for the TCP client. As a consequence we move the response timer into the RTU client implementation. Change-Id: Ic30dfd730bcdae42ee7515be0fdf0eaff64af2fa Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Implement Modbus listen only mode, update TODO's.Karsten Heimrich2015-11-231-1/+7
| | | | | Change-Id: Ibe7a8c233a4a7e6b064f4060de37e0d2c125f600 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Extend QModbusReply to contain the raw response as well.Karsten Heimrich2015-11-231-51/+48
| | | | | | | | | | | The idea is to reuse this later in case of sending raw requests that we have no real data units for the return. This makes the protocol error functions superfluous as well, as now, the actual response can be queried for the real exception code. Change-Id: I5d6b5e050b273c8ff4ed19f0a3eae5c31420942e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Fix wrong Modbus addresses.Karsten Heimrich2015-11-231-0/+7
| | | | | | | | | | | | | | | Serial slave devices are assigned addresses in the range of 1 – 247. See Modbus Serial Line Protocol and Implementation Guide V1.02, page 8, 2.2 MODBUS Addressing rules. On TCP/IP, the MODBUS server is addressed using its IP address; therefore, the MODBUS Unit Identifier is useless. The value 0xFF has to be used. See Modbus Messaging on TCP/IP Implementation Guide V1.0b, page 23, paragraph * Unit Identifier. Change-Id: Id6b304f0f37ae24280729c8f3f0c375898bad4f9 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Ralf Nolden <nolden@kde.org>
* Don't use deprecated API especially if we don't even need QCharAlex Blasche2015-11-231-3/+13
| | | | | | | | | | | | | | | | | | | QChar is for unicode chars and this fixes the warnings below. Going forward we store the value as uint or int and ensure that we stay within the limits of ascii. The test case has been extended to cover additional corner cases. qmodbusserver.cpp: In member function ‘virtual QVariant QModbusServer::value(int) const’: qmodbusserver.cpp:203:63: warning: ‘constexpr QChar::QChar(char)’ is deprecated (declared at /home/ablasche/dev/qt/qt56/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:85) [-Wdeprecated-declarations] return d->m_serverOptions.value(option, QChar('\n')); ^ qmodbusserver.cpp: In member function ‘QModbusResponse QModbusServerPrivate::processDiagnosticsRequest(const QModbusRequest&)’: qmodbusserver.cpp:844:77: warning: ‘constexpr QChar::QChar(char)’ is deprecated (declared at /home/ablasche/dev/qt/qt56/qtbase/include/QtCore/../../src/corelib/tools/qchar.h:85) [-Wdeprecated-declarations] q_func()->setValue(QModbusServer::AsciiInputDelimiter, QChar(data[0])); ^ Change-Id: I6113bcbd275d58141fa7df82e8ae6cccbae178cf Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Finally rename all remaining slave* occurrences to server*.Karsten Heimrich2015-11-203-16/+16
| | | | | Change-Id: Ia71200686660f25f624e83d7bb3f8b3a8cb1b774 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Implement Modbus ASCII input delimiter, update TODO's.Karsten Heimrich2015-11-201-0/+11
| | | | | Change-Id: Ic1d003fcc5cee7a6bfcec9432fe6d24be1376707 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Merge the TCP and RTU read/write implementations.Karsten Heimrich2015-11-191-9/+0
| | | | | | | | | This allows us to get rid of several public pure virtual functions and to have the implementation in a single place instead of duplicating it in several classes. Change-Id: I88fb28a5d507c7b64d20bba73765534e2925165e Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Implement report server id. Update TODO's and add auto-test.Karsten Heimrich2015-11-191-0/+34
| | | | | | Change-Id: Ibed7854d0136323337296dc0d2dd51ea20f1b1c2 Reviewed-by: Ralf Nolden <nolden@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Introduce enum and setValue|value functions to set server values.Karsten Heimrich2015-11-171-17/+9
| | | | | Change-Id: Ie752837e3eff31710c28087f71f243f24b2a1def Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Fix QModbusResponse stream in operatorAlex Blasche2015-11-171-0/+8
| | | | | | | | 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-15/+19
| | | | | Change-Id: I55633a7e147383dbb8de2063fc781d895009d790 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Make QModbusReply setter public APIAlex Blasche2015-11-161-29/+8
| | | | | | | | It avoids friend declarations and custom implementations can use QModbusReply as well. Change-Id: I7293cac73155da55f707f6c7225ac65298b3cf84 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* TCP: Respond with illegal function for serial only requests.Karsten Heimrich2015-11-132-1/+30
| | | | | | Task-number: QTBUG-49239 Change-Id: I7ab2f74c3b894eb001562135e5f56a08c0f25bdd Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Introduce Modbus ADU class and reuse where possible.Karsten Heimrich2015-11-135-123/+234
| | | | | | | Merge the LRC/CRC chechsum functions as well, add test. Change-Id: Icc7dae90c5dea5e597852fa3d1bd552a8ee39d99 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Implement handling of missing server registers, update docs.Karsten Heimrich2015-11-121-0/+16
| | | | | | Change-Id: I6de28ac751303b05305f3a335e9ee9c2de20c2a3 Reviewed-by: Ralf Nolden <nolden@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Make the return value of minimumDataSize() signed.Karsten Heimrich2015-11-111-20/+20
| | | | | | | | | | 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>
* QModbusReply::setError() does not have to be followed by setFinished()Alex Blasche2015-11-111-0/+10
| | | | | | | | setError() implicitly calls setFinished(). The unit tests have been modified to ensure this behavior does not stop. Change-Id: Id5f67e748fb330eada7575db79bc2239fa877385 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Fix CRC checks in RTU slave and masterKarsten Heimrich2015-11-111-1/+1
| | | | | | | | | | | | | The previous check always succeeded as the crc check function result was not negated. In addition, the crc must be run over the entire ADU without the trailing 2 byte CRC. checkCRC() was renamed to improve readability of code and to avoid accidental inversion of CRC logic. Change-Id: Id9cb1a008152d60f49a3514c90f10f981613945a Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* fix spurious dependenciesOswald Buddenhagen2015-11-111-1/+1
| | | | | | | | | most importantly, eliminate gui everywhere where it is not needed, and don't redundantly list it where it is. Change-Id: I8567e8473d976d9087a7da6d8f9f81b43148c8b2 Reviewed-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Missed to name to file properly, add _p for private files.Karsten Heimrich2015-11-102-2/+2
| | | | | Change-Id: I89405e60afa7c34271e6e854527f9b04c5d46361 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Introduce API to manage response timerAlex Blasche2015-11-071-2/+28
| | | | | | | The timer will keep track of the expired time since sending a request. Change-Id: Iecf64980d3fea778d391a87fd63c020600e0ec02 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Fix warning in QModbusDevice unit testAlex Blasche2015-11-061-1/+1
| | | | | | | | | tst_qmodbusdevice.cpp:60:22: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 bool openState = false; ^ Change-Id: Ifb2a653a4fdbf4cc72105e8a81607fb815d610f0 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Implement GetCommEventCounter and GetCommEventLog functions.Karsten Heimrich2015-11-061-0/+33
| | | | | Change-Id: Ia5b1a6f38f0271ab1ff479028d86a77b113536d2 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Fix memory leaks in QModbus{Client|Device} unit tests.Karsten Heimrich2015-11-062-37/+43
| | | | | | | | | | | QObjectPrivate initialization is not complete without QObject. It leaves uninitialized members behind which crash when directly deleting a QObjectPrivate derived class manually. To fix the problem the patch creates a QModbusDevice first and then extracts its internal QObjectPrivate derived class. Change-Id: I4b3b6502650f04f1267335b0a76a556ed226f368 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Remove extra newlines. Whitespace only change.Karsten Heimrich2015-11-062-4/+0
| | | | | Change-Id: I941cfc5d30c65a6805f289263a6b0c1774f642b4 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Cleanup QModbusDataUnit documentation and codeAlex Blasche2015-11-051-7/+8
| | | | | | | | | reset() was removed, incorrect documentation fixed and some minor doc layout issues resolved. The unit test was modified to test further cases. Change-Id: I77caae7cdd5d89bae35cd487370a8f6d813d1dc1 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Add unit test for QModbusReplyAlex Blasche2015-11-051-4/+188
| | | | | Change-Id: Ic9ace7e62b1f0c3d3d085c37186727462d676ece Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Do not overload transmission and Modbus exception codesAlex Blasche2015-11-051-7/+7
| | | | | | | QModbusReply::ProtocolError stands for Modbus exception codes. Change-Id: I2dfb89ebe574c8e83b9f8621bc4a451e4663dffa Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Move exceptionCode() from QModbusExceptionResponse to QModbusPduAlex Blasche2015-11-041-0/+5
| | | | | Change-Id: I8e50417ba4973721f7d9f40f4d87d11c0b705925 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Introduce QModbusCommEvent for event logging.Karsten Heimrich2015-11-043-0/+100
| | | | | Change-Id: Id97a2c9e58dbc432de600770ee28c9e585e97307 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>