SlideShare a Scribd company logo
1 of 39
Download to read offline
© Integrated Computer Solutions, Inc. All Rights Reserved
QtSerialBus: Using Modbus
and CAN bus with Qt
Jeff Tranter <jtranter@ics.com>
Integrated Computer Solutions, Inc.
© Integrated Computer Solutions, Inc. All Rights Reserved
Agenda
• What is CAN bus?
• What is Modbus?
• The QtSerialBus Module
• What Hardware and Platforms are Supported?
• Qt APIs
• Code Examples
• Demonstration
• Areas of Possible Future Work
• Summary
• References
© Integrated Computer Solutions, Inc. All Rights Reserved
What is CAN bus?
• Controller Area Network bus.
• Bus standard that allows microcontrollers and devices to communicate
with each other in applications without a host computer.
• Multi-master serial bus where all nodes are connected to each other
through a two wire bus.
• Message-based protocol.
• Originally designed for multiplexed electrical wiring within automobiles,
but also used in many other contexts.
© Integrated Computer Solutions, Inc. All Rights Reserved
What is CAN bus?
© Integrated Computer Solutions, Inc. All Rights Reserved
What is CAN bus?
© Integrated Computer Solutions, Inc. All Rights Reserved
What is CAN bus?
© Integrated Computer Solutions, Inc. All Rights Reserved
What is CAN bus?
© Integrated Computer Solutions, Inc. All Rights Reserved
What is Modbus?
• Serial communications protocol commonly used
for connecting industrial electronic devices.
• Allows communication among multiple devices
connected to the same network, often to connect
a supervisory computer with a remote terminal
unit in Supervisory Control and Data Acquisition
(SCADA) systems.
• Originally developed by Modicon in 1979 for use
with its programmable logic controllers (PLCs).
© Integrated Computer Solutions, Inc. All Rights Reserved
What is Modbus?
© Integrated Computer Solutions, Inc. All Rights Reserved
What is Modbus?
© Integrated Computer Solutions, Inc. All Rights Reserved
What is Modbus?
© Integrated Computer Solutions, Inc. All Rights Reserved
The QtSerialBus Module
• New module introduced as technical preview in Qt 5.6.0.
• Supports CAN bus and Modbus.
• May support other serial protocols in the future.
• Licensed like most Qt modules (LGPLv3, GPLv2, GPLv3 or commercial).
• git repo: http://code.qt.io/cgit/qt/qtserialbus.git
• Main developers and maintainers are Alex Blasche (CAN bus) and Karsten
Heimrich (Modbus) of The Qt Company.
© Integrated Computer Solutions, Inc. All Rights Reserved
What Hardware and Platforms are Supported?
For CAN bus, currently supports the following back ends:
• SocketCAN, which uses Linux sockets and open source drivers.
• Peak CAN, which supports PCAN adaptors from PEAK-System Technik
GmbH.
• TinyCAN, with support for Tiny-CAN adapters from MHS Elektronik.
• VectorCAN, supporting Vector Informatik CAN adapters.
© Integrated Computer Solutions, Inc. All Rights Reserved
What Hardware and Platforms are Supported?
For Modbus:
• One implementation (not a plugin) which doesn't depend on any external
libraries.
• Uses Qt's QtSerialPort and networking APIs.
• Supports RTU (serial) and TCP (Ethernet) communications.
© Integrated Computer Solutions, Inc. All Rights Reserved
Qt APIs
• C++ only, no QML
• To add to qmake projects: QT += serialbus
• Module include file: #include <QtSerialBus>
• logging categories:
• qt.modbus (standard)
• qt.modbus.lowlevel (low-level packets)
© Integrated Computer Solutions, Inc. All Rights Reserved
Qt APIs - CAN bus
Six classes:
QcanBus - Handles registration and creation of bus backends
QcanBusDevice::Filter - Defines a filter for CAN bus messages
QcanBusDevice - The interface class for CAN bus
QcanBusFactory - Factory class used as the plugin interface
QcanBusFrame - Container class representing a single CAN frame
QcanBusFrame::TimeStamp - Timestamp information with µsec precision
© Integrated Computer Solutions, Inc. All Rights Reserved
Qt APIs - Modbus
14 classes:
QModbusClient - The interface to send Modbus requests
QmodbusDataUnit - Container class representing entries in Modbus
register
QmodbusDevice - base class for QModbusServer and QModbusClient
QmodbusDeviceIdentification - Container class representing the physical
and functional description of a Modbus server
QmodbusExceptionResponse - Container class containing the function and
error code inside a Modbus ADU
QmodbusPdu - Abstract container class containing the function code and
payload that is stored inside a Modbus ADU
© Integrated Computer Solutions, Inc. All Rights Reserved
Qt APIs – Modbus (cont'd)
QmodbusRequest - Container class containing the function code and
payload that is stored inside a Modbus ADU
QmodbusResponse - Container class containing the function code and
payload that is stored inside a Modbus ADU
QmodbusReply - Contains the data for a request sent with a
QModbusClient derived class
QmodbusRtuSerialMaster - Represents a Modbus client that uses a serial
bus for its communication with the Modbus server
QmodbusRtuSerialSlave - Represents a Modbus server that uses a serial
port for its communication with the Modbus client
© Integrated Computer Solutions, Inc. All Rights Reserved
Qt APIs – Modbus (cont'd)
QmodbusServer - The interface to receive and process Modbus requests
QmodbusTcpClient - The interface class for Modbus TCP client device
QmodbusTcpServer - Represents a Modbus server that uses a TCP server
for its communication with the Modbus client
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples - CAN bus
Basic Steps:
1. Create a device, specifying plugin and device name.
2. Connect.
3. Create data frames.
4. Send data frames.
5. Disconnect when done.
QCanBusDevice emits signals: errorOccurred, framesReceived, framesWritten,
stateChanged. To receive frames, connect to signal framesReceived.
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples - CAN bus
// Create device.
QCanBusDevice *device = QCanBus::instance()->createDevice("socketcan", "vcan0");
if (device != nullptr) {
qDebug() << "Created device, state is:" << device->state();
} else {
qFatal("Unable to create CAN device.");
}
// Connect.
if (device->connectDevice()) {
qDebug() << "Connected, state is:" << device->state();
} else {
qDebug() << "Connect failed, error is:" << device->errorString();
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples - CAN bus (cont'd)
// Create a data frame.
QCanBusFrame frame(QCanBusFrame::DataFrame, "12345");
// Send it.
if (device->writeFrame(frame)) {
qDebug() << "Wrote frame, state is:" << device->state();
} else {
qDebug() << "Write failed, error is:" << device->errorString();
}
// Disconnect.
device->disconnectDevice();
qDebug() << "Disconnected, state is:" << device->state();
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples - CAN bus
On Linux there is a virtual CAN driver for testing purposes which can be
loaded and created as below:
sudo modprobe can
sudo modprobe can_raw
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
ip link show vcan0
3: vcan0: <NOARP,UP,LOWER_UP> mtu 16 qdisc noqueue state UNKNOWN
link/can
© Integrated Computer Solutions, Inc. All Rights Reserved
More Complete Example – CAN bus
© Integrated Computer Solutions, Inc. All Rights Reserved
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples - Modbus
• Unlike CAN bus which is peer to peer, Modbus is client/server.
• Client sends request and gets response from server.
• Master/Slave arrangement where the Master is a Client and the Slave is a
Server.
• Confusing terminology: there is a single Modbus client (master) and
multiple Modbus servers (slaves).
• Support for serial devices and TCP network devices.
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples - Modbus
QObject
QModbusDevice
QModbusClient QModbusServer
QModbusSerialMaster QModbusTcpClient QModbusRtuSerialSlave QModbusTcpServer
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples - Modbus
Basic steps for a TCP client (others are similar):
1. Create a QModbusTcpClient()
2. Set connection parameters with setConnectionParameter()
3. Connect using connectDevice()
4. Call as needed:
sendRawRequest()
sendReadRequest()
sendReadWriteRequest()
sendWriteRequest()
4. When done, call disconnectDevice()
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples - Modbus
// Create device.
QModbusTcpClient *device = new QModbusTcpClient();
if (device != nullptr) {
qDebug() << "Created device, state is:" << device->state();
} else {
qFatal("Unable to create Modbus TCP client device.");
}
// Set connection parameters. Defaults to local host port 502.
// Instead use TCP port 1502 as it is non-privileged.
device->setConnectionParameter(QModbusDevice::NetworkPortParameter, 1502);
// Connect.
if (device->connectDevice()) {
qDebug() << "Connected, state is:" << device->state();
} else {
qDebug() << "Connect failed, error is:" << device->errorString();
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Code Examples – Modbus (cont'd)
// Create ADU.
QVector<quint16> data(4);
QModbusDataUnit adu(QModbusDataUnit::Coils, 1, data);
// Send read request to a server at address 1.
QModbusReply *reply = device->sendReadRequest(adu, 1);
if (reply != nullptr) {
qDebug() << "Sent read request, state is:" << device->state();
qDebug() << reply;
} else {
qDebug() << "Send of read request failed, error is:" << device->errorString();
}
// Disconnect.
device->disconnectDevice();
qDebug() << "Disconnected, state is:" << device->state();
© Integrated Computer Solutions, Inc. All Rights Reserved
More Complete Example - Modbus
© Integrated Computer Solutions, Inc. All Rights Reserved
© Integrated Computer Solutions, Inc. All Rights Reserved
Documentation
© Integrated Computer Solutions, Inc. All Rights Reserved
Qt Code Examples
© Integrated Computer Solutions, Inc. All Rights Reserved
Areas of Possible Future Work
• APIs final in Qt 5.8.0
• Support/plugins for more hardware back ends
• Higher level protocols?
© Integrated Computer Solutions, Inc. All Rights Reserved
Summary
© Integrated Computer Solutions, Inc. All Rights Reserved
References
1. https://en.wikipedia.org/wiki/CAN_bus
2. https://en.wikipedia.org/wiki/Modbus
3. https://doc-snapshots.qt.io/qt5-dev/qtserialbus-index.html
4. http://code.qt.io/cgit/qt/qtserialbus.git/
5. http://www.modbus.org
6. http://opengarages.org
7. ftp://ftp.ics.com/pub/pickup/qtserialbusexamples.zip
© Integrated Computer Solutions, Inc. All Rights Reserved
Questions?
© Integrated Computer Solutions, Inc. All Rights Reserved
QtSerialBus: Using Modbus
and CAN bus with Qt
Jeff Tranter <jtranter@ics.com>
Integrated Computer Solutions, Inc.

More Related Content

What's hot

Meet Qt 6.0
Meet Qt 6.0 Meet Qt 6.0
Meet Qt 6.0
Qt
 

What's hot (20)

Best Practices in Qt Quick/QML - Part II
Best Practices in Qt Quick/QML - Part IIBest Practices in Qt Quick/QML - Part II
Best Practices in Qt Quick/QML - Part II
 
QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI development
 
Linux SMEP bypass techniques
Linux SMEP bypass techniquesLinux SMEP bypass techniques
Linux SMEP bypass techniques
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part III
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
UI Programming with Qt-Quick and QML
UI Programming with Qt-Quick and QMLUI Programming with Qt-Quick and QML
UI Programming with Qt-Quick and QML
 
Introduction to QML
Introduction to QMLIntroduction to QML
Introduction to QML
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part I
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
Advanced C - Part 1
Advanced C - Part 1 Advanced C - Part 1
Advanced C - Part 1
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 
02 - Basics of Qt
02 - Basics of Qt02 - Basics of Qt
02 - Basics of Qt
 
Introduction to Qt
Introduction to QtIntroduction to Qt
Introduction to Qt
 
IPC with Qt
IPC with QtIPC with Qt
IPC with Qt
 
Overview of ZeroMQ
Overview of ZeroMQOverview of ZeroMQ
Overview of ZeroMQ
 
Meet Qt 6.0
Meet Qt 6.0 Meet Qt 6.0
Meet Qt 6.0
 
Hello, QML
Hello, QMLHello, QML
Hello, QML
 
Advanced C - Part 3
Advanced C - Part 3Advanced C - Part 3
Advanced C - Part 3
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 

Viewers also liked

Возможности, применение и монетизация социальных API Mail.Ru на мобильных пла...
Возможности, применение и монетизация социальных API Mail.Ru на мобильных пла...Возможности, применение и монетизация социальных API Mail.Ru на мобильных пла...
Возможности, применение и монетизация социальных API Mail.Ru на мобильных пла...
Elena Kotina
 
CodeFest 2012. Титов А. — Инженерный дзен. Непрерывные изменения
CodeFest 2012. Титов А. — Инженерный дзен. Непрерывные измененияCodeFest 2012. Титов А. — Инженерный дзен. Непрерывные изменения
CodeFest 2012. Титов А. — Инженерный дзен. Непрерывные изменения
CodeFest
 
Modbus Data Communication Systems
Modbus Data Communication SystemsModbus Data Communication Systems
Modbus Data Communication Systems
Living Online
 

Viewers also liked (19)

[Webinar] An Introduction to the Yocto Embedded Framework
[Webinar] An Introduction to the Yocto Embedded Framework[Webinar] An Introduction to the Yocto Embedded Framework
[Webinar] An Introduction to the Yocto Embedded Framework
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the experts
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
 
Industrial Automation training
Industrial Automation trainingIndustrial Automation training
Industrial Automation training
 
Денис Кормалев — Qt. Как выжить на минном поле. Советы сапёру
Денис Кормалев — Qt. Как выжить на минном поле. Советы сапёруДенис Кормалев — Qt. Как выжить на минном поле. Советы сапёру
Денис Кормалев — Qt. Как выжить на минном поле. Советы сапёру
 
Возможности, применение и монетизация социальных API Mail.Ru на мобильных пла...
Возможности, применение и монетизация социальных API Mail.Ru на мобильных пла...Возможности, применение и монетизация социальных API Mail.Ru на мобильных пла...
Возможности, применение и монетизация социальных API Mail.Ru на мобильных пла...
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgets
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing more
 
K NX system DDIS
K NX system DDIS K NX system DDIS
K NX system DDIS
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt Quick
 
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
 
[Webinar] Software: The Lifeblood of any Medical Device
[Webinar] Software: The Lifeblood of any Medical Device[Webinar] Software: The Lifeblood of any Medical Device
[Webinar] Software: The Lifeblood of any Medical Device
 
Best Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVBest Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IV
 
Modbus TCP/IP implementation in Siemens S7-300 PLC
Modbus TCP/IP implementation in Siemens S7-300 PLC Modbus TCP/IP implementation in Siemens S7-300 PLC
Modbus TCP/IP implementation in Siemens S7-300 PLC
 
Automation Training With ITS PLC
Automation Training With ITS PLCAutomation Training With ITS PLC
Automation Training With ITS PLC
 
CodeFest 2012. Титов А. — Инженерный дзен. Непрерывные изменения
CodeFest 2012. Титов А. — Инженерный дзен. Непрерывные измененияCodeFest 2012. Титов А. — Инженерный дзен. Непрерывные изменения
CodeFest 2012. Титов А. — Инженерный дзен. Непрерывные изменения
 
Modbus Data Communication Systems
Modbus Data Communication SystemsModbus Data Communication Systems
Modbus Data Communication Systems
 
SIEMENS PLC S7-300&WINCC COURSE
SIEMENS PLC S7-300&WINCC COURSESIEMENS PLC S7-300&WINCC COURSE
SIEMENS PLC S7-300&WINCC COURSE
 
PLC-SCADA and automation
PLC-SCADA and automationPLC-SCADA and automation
PLC-SCADA and automation
 

Similar to [Webinar] QtSerialBus: Using Modbus and CAN bus with Qt

“Parallelizing Machine Learning Applications in the Cloud with Kubernetes: A ...
“Parallelizing Machine Learning Applications in the Cloud with Kubernetes: A ...“Parallelizing Machine Learning Applications in the Cloud with Kubernetes: A ...
“Parallelizing Machine Learning Applications in the Cloud with Kubernetes: A ...
Edge AI and Vision Alliance
 
Future Intelligent Mobility with Adaptive AUTOSAR - Transforming Vehicle E/E A
Future Intelligent Mobility with Adaptive AUTOSAR - Transforming Vehicle E/E AFuture Intelligent Mobility with Adaptive AUTOSAR - Transforming Vehicle E/E A
Future Intelligent Mobility with Adaptive AUTOSAR - Transforming Vehicle E/E A
GlobalLogic Croatia
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
QAware GmbH
 

Similar to [Webinar] QtSerialBus: Using Modbus and CAN bus with Qt (20)

“Parallelizing Machine Learning Applications in the Cloud with Kubernetes: A ...
“Parallelizing Machine Learning Applications in the Cloud with Kubernetes: A ...“Parallelizing Machine Learning Applications in the Cloud with Kubernetes: A ...
“Parallelizing Machine Learning Applications in the Cloud with Kubernetes: A ...
 
Pushing Data from S7-1200 to Cloud
Pushing Data from S7-1200 to CloudPushing Data from S7-1200 to Cloud
Pushing Data from S7-1200 to Cloud
 
MQTT enabling the smallest things
MQTT enabling the smallest thingsMQTT enabling the smallest things
MQTT enabling the smallest things
 
Hexagonal Architecture: The Standard for Qt Embedded Applications
Hexagonal Architecture: The Standard for Qt Embedded ApplicationsHexagonal Architecture: The Standard for Qt Embedded Applications
Hexagonal Architecture: The Standard for Qt Embedded Applications
 
Basic Cmake for Qt Users
Basic Cmake for Qt UsersBasic Cmake for Qt Users
Basic Cmake for Qt Users
 
Kubernetes on AWS
Kubernetes on AWSKubernetes on AWS
Kubernetes on AWS
 
Kubernetes on AWS
Kubernetes on AWSKubernetes on AWS
Kubernetes on AWS
 
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
Deploying Cloud Native Red Team Infrastructure with Kubernetes, Istio and Envoy
 
WebRTC Webinar & Q&A - Sumilcast Standards & Implementation
WebRTC Webinar & Q&A - Sumilcast Standards & ImplementationWebRTC Webinar & Q&A - Sumilcast Standards & Implementation
WebRTC Webinar & Q&A - Sumilcast Standards & Implementation
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt Communication
 
Is your MQTT broker IoT ready?
Is your MQTT broker IoT ready?Is your MQTT broker IoT ready?
Is your MQTT broker IoT ready?
 
Future Intelligent Mobility with Adaptive AUTOSAR - Transforming Vehicle E/E A
Future Intelligent Mobility with Adaptive AUTOSAR - Transforming Vehicle E/E AFuture Intelligent Mobility with Adaptive AUTOSAR - Transforming Vehicle E/E A
Future Intelligent Mobility with Adaptive AUTOSAR - Transforming Vehicle E/E A
 
F5 OpenShift Workshop
F5 OpenShift WorkshopF5 OpenShift Workshop
F5 OpenShift Workshop
 
KSS Session and Tech Talk-2019 on IOT.pptx
KSS Session and Tech Talk-2019 on IOT.pptxKSS Session and Tech Talk-2019 on IOT.pptx
KSS Session and Tech Talk-2019 on IOT.pptx
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
 
JDO 2019: What you should be aware of before setting up kubernetes on premise...
JDO 2019: What you should be aware of before setting up kubernetes on premise...JDO 2019: What you should be aware of before setting up kubernetes on premise...
JDO 2019: What you should be aware of before setting up kubernetes on premise...
 
my_resume(eng)
my_resume(eng)my_resume(eng)
my_resume(eng)
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQ
 

More from ICS

Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
ICS
 

More from ICS (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Practical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdfPractical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdf
 
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
 
Overcoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues WebinarOvercoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues Webinar
 
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdfEnhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
 
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdfDesigning and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
 
Quality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdfQuality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdf
 
Creating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdfCreating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdf
 
Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up
 
Cybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdfCybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdf
 
MDG Panel - Creating Expert Level GUIs for Complex Medical Devices
MDG Panel - Creating Expert Level GUIs for Complex Medical DevicesMDG Panel - Creating Expert Level GUIs for Complex Medical Devices
MDG Panel - Creating Expert Level GUIs for Complex Medical Devices
 
How to Craft a Winning IOT Device Management Solution
How to Craft a Winning IOT Device Management SolutionHow to Craft a Winning IOT Device Management Solution
How to Craft a Winning IOT Device Management Solution
 
Bridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory TeamsBridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory Teams
 
IoT Device Fleet Management: Create a Robust Solution with Azure
IoT Device Fleet Management: Create a Robust Solution with AzureIoT Device Fleet Management: Create a Robust Solution with Azure
IoT Device Fleet Management: Create a Robust Solution with Azure
 
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
 
Qt Installer Framework
Qt Installer FrameworkQt Installer Framework
Qt Installer Framework
 
Bridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory TeamsBridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory Teams
 
Overcome Hardware And Software Challenges - Medical Device Case Study
Overcome Hardware And Software Challenges - Medical Device Case StudyOvercome Hardware And Software Challenges - Medical Device Case Study
Overcome Hardware And Software Challenges - Medical Device Case Study
 
User Experience Design for IoT
User Experience Design for IoTUser Experience Design for IoT
User Experience Design for IoT
 
Software Bill of Materials - Accelerating Your Secure Embedded Development.pdf
Software Bill of Materials - Accelerating Your Secure Embedded Development.pdfSoftware Bill of Materials - Accelerating Your Secure Embedded Development.pdf
Software Bill of Materials - Accelerating Your Secure Embedded Development.pdf
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 

Recently uploaded (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 

[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt

  • 1. © Integrated Computer Solutions, Inc. All Rights Reserved QtSerialBus: Using Modbus and CAN bus with Qt Jeff Tranter <jtranter@ics.com> Integrated Computer Solutions, Inc.
  • 2. © Integrated Computer Solutions, Inc. All Rights Reserved Agenda • What is CAN bus? • What is Modbus? • The QtSerialBus Module • What Hardware and Platforms are Supported? • Qt APIs • Code Examples • Demonstration • Areas of Possible Future Work • Summary • References
  • 3. © Integrated Computer Solutions, Inc. All Rights Reserved What is CAN bus? • Controller Area Network bus. • Bus standard that allows microcontrollers and devices to communicate with each other in applications without a host computer. • Multi-master serial bus where all nodes are connected to each other through a two wire bus. • Message-based protocol. • Originally designed for multiplexed electrical wiring within automobiles, but also used in many other contexts.
  • 4. © Integrated Computer Solutions, Inc. All Rights Reserved What is CAN bus?
  • 5. © Integrated Computer Solutions, Inc. All Rights Reserved What is CAN bus?
  • 6. © Integrated Computer Solutions, Inc. All Rights Reserved What is CAN bus?
  • 7. © Integrated Computer Solutions, Inc. All Rights Reserved What is CAN bus?
  • 8. © Integrated Computer Solutions, Inc. All Rights Reserved What is Modbus? • Serial communications protocol commonly used for connecting industrial electronic devices. • Allows communication among multiple devices connected to the same network, often to connect a supervisory computer with a remote terminal unit in Supervisory Control and Data Acquisition (SCADA) systems. • Originally developed by Modicon in 1979 for use with its programmable logic controllers (PLCs).
  • 9. © Integrated Computer Solutions, Inc. All Rights Reserved What is Modbus?
  • 10. © Integrated Computer Solutions, Inc. All Rights Reserved What is Modbus?
  • 11. © Integrated Computer Solutions, Inc. All Rights Reserved What is Modbus?
  • 12. © Integrated Computer Solutions, Inc. All Rights Reserved The QtSerialBus Module • New module introduced as technical preview in Qt 5.6.0. • Supports CAN bus and Modbus. • May support other serial protocols in the future. • Licensed like most Qt modules (LGPLv3, GPLv2, GPLv3 or commercial). • git repo: http://code.qt.io/cgit/qt/qtserialbus.git • Main developers and maintainers are Alex Blasche (CAN bus) and Karsten Heimrich (Modbus) of The Qt Company.
  • 13. © Integrated Computer Solutions, Inc. All Rights Reserved What Hardware and Platforms are Supported? For CAN bus, currently supports the following back ends: • SocketCAN, which uses Linux sockets and open source drivers. • Peak CAN, which supports PCAN adaptors from PEAK-System Technik GmbH. • TinyCAN, with support for Tiny-CAN adapters from MHS Elektronik. • VectorCAN, supporting Vector Informatik CAN adapters.
  • 14. © Integrated Computer Solutions, Inc. All Rights Reserved What Hardware and Platforms are Supported? For Modbus: • One implementation (not a plugin) which doesn't depend on any external libraries. • Uses Qt's QtSerialPort and networking APIs. • Supports RTU (serial) and TCP (Ethernet) communications.
  • 15. © Integrated Computer Solutions, Inc. All Rights Reserved Qt APIs • C++ only, no QML • To add to qmake projects: QT += serialbus • Module include file: #include <QtSerialBus> • logging categories: • qt.modbus (standard) • qt.modbus.lowlevel (low-level packets)
  • 16. © Integrated Computer Solutions, Inc. All Rights Reserved Qt APIs - CAN bus Six classes: QcanBus - Handles registration and creation of bus backends QcanBusDevice::Filter - Defines a filter for CAN bus messages QcanBusDevice - The interface class for CAN bus QcanBusFactory - Factory class used as the plugin interface QcanBusFrame - Container class representing a single CAN frame QcanBusFrame::TimeStamp - Timestamp information with µsec precision
  • 17. © Integrated Computer Solutions, Inc. All Rights Reserved Qt APIs - Modbus 14 classes: QModbusClient - The interface to send Modbus requests QmodbusDataUnit - Container class representing entries in Modbus register QmodbusDevice - base class for QModbusServer and QModbusClient QmodbusDeviceIdentification - Container class representing the physical and functional description of a Modbus server QmodbusExceptionResponse - Container class containing the function and error code inside a Modbus ADU QmodbusPdu - Abstract container class containing the function code and payload that is stored inside a Modbus ADU
  • 18. © Integrated Computer Solutions, Inc. All Rights Reserved Qt APIs – Modbus (cont'd) QmodbusRequest - Container class containing the function code and payload that is stored inside a Modbus ADU QmodbusResponse - Container class containing the function code and payload that is stored inside a Modbus ADU QmodbusReply - Contains the data for a request sent with a QModbusClient derived class QmodbusRtuSerialMaster - Represents a Modbus client that uses a serial bus for its communication with the Modbus server QmodbusRtuSerialSlave - Represents a Modbus server that uses a serial port for its communication with the Modbus client
  • 19. © Integrated Computer Solutions, Inc. All Rights Reserved Qt APIs – Modbus (cont'd) QmodbusServer - The interface to receive and process Modbus requests QmodbusTcpClient - The interface class for Modbus TCP client device QmodbusTcpServer - Represents a Modbus server that uses a TCP server for its communication with the Modbus client
  • 20. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples - CAN bus Basic Steps: 1. Create a device, specifying plugin and device name. 2. Connect. 3. Create data frames. 4. Send data frames. 5. Disconnect when done. QCanBusDevice emits signals: errorOccurred, framesReceived, framesWritten, stateChanged. To receive frames, connect to signal framesReceived.
  • 21. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples - CAN bus // Create device. QCanBusDevice *device = QCanBus::instance()->createDevice("socketcan", "vcan0"); if (device != nullptr) { qDebug() << "Created device, state is:" << device->state(); } else { qFatal("Unable to create CAN device."); } // Connect. if (device->connectDevice()) { qDebug() << "Connected, state is:" << device->state(); } else { qDebug() << "Connect failed, error is:" << device->errorString(); }
  • 22. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples - CAN bus (cont'd) // Create a data frame. QCanBusFrame frame(QCanBusFrame::DataFrame, "12345"); // Send it. if (device->writeFrame(frame)) { qDebug() << "Wrote frame, state is:" << device->state(); } else { qDebug() << "Write failed, error is:" << device->errorString(); } // Disconnect. device->disconnectDevice(); qDebug() << "Disconnected, state is:" << device->state();
  • 23. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples - CAN bus On Linux there is a virtual CAN driver for testing purposes which can be loaded and created as below: sudo modprobe can sudo modprobe can_raw sudo modprobe vcan sudo ip link add dev vcan0 type vcan sudo ip link set up vcan0 ip link show vcan0 3: vcan0: <NOARP,UP,LOWER_UP> mtu 16 qdisc noqueue state UNKNOWN link/can
  • 24. © Integrated Computer Solutions, Inc. All Rights Reserved More Complete Example – CAN bus
  • 25. © Integrated Computer Solutions, Inc. All Rights Reserved
  • 26. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples - Modbus • Unlike CAN bus which is peer to peer, Modbus is client/server. • Client sends request and gets response from server. • Master/Slave arrangement where the Master is a Client and the Slave is a Server. • Confusing terminology: there is a single Modbus client (master) and multiple Modbus servers (slaves). • Support for serial devices and TCP network devices.
  • 27. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples - Modbus QObject QModbusDevice QModbusClient QModbusServer QModbusSerialMaster QModbusTcpClient QModbusRtuSerialSlave QModbusTcpServer
  • 28. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples - Modbus Basic steps for a TCP client (others are similar): 1. Create a QModbusTcpClient() 2. Set connection parameters with setConnectionParameter() 3. Connect using connectDevice() 4. Call as needed: sendRawRequest() sendReadRequest() sendReadWriteRequest() sendWriteRequest() 4. When done, call disconnectDevice()
  • 29. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples - Modbus // Create device. QModbusTcpClient *device = new QModbusTcpClient(); if (device != nullptr) { qDebug() << "Created device, state is:" << device->state(); } else { qFatal("Unable to create Modbus TCP client device."); } // Set connection parameters. Defaults to local host port 502. // Instead use TCP port 1502 as it is non-privileged. device->setConnectionParameter(QModbusDevice::NetworkPortParameter, 1502); // Connect. if (device->connectDevice()) { qDebug() << "Connected, state is:" << device->state(); } else { qDebug() << "Connect failed, error is:" << device->errorString(); }
  • 30. © Integrated Computer Solutions, Inc. All Rights Reserved Code Examples – Modbus (cont'd) // Create ADU. QVector<quint16> data(4); QModbusDataUnit adu(QModbusDataUnit::Coils, 1, data); // Send read request to a server at address 1. QModbusReply *reply = device->sendReadRequest(adu, 1); if (reply != nullptr) { qDebug() << "Sent read request, state is:" << device->state(); qDebug() << reply; } else { qDebug() << "Send of read request failed, error is:" << device->errorString(); } // Disconnect. device->disconnectDevice(); qDebug() << "Disconnected, state is:" << device->state();
  • 31. © Integrated Computer Solutions, Inc. All Rights Reserved More Complete Example - Modbus
  • 32. © Integrated Computer Solutions, Inc. All Rights Reserved
  • 33. © Integrated Computer Solutions, Inc. All Rights Reserved Documentation
  • 34. © Integrated Computer Solutions, Inc. All Rights Reserved Qt Code Examples
  • 35. © Integrated Computer Solutions, Inc. All Rights Reserved Areas of Possible Future Work • APIs final in Qt 5.8.0 • Support/plugins for more hardware back ends • Higher level protocols?
  • 36. © Integrated Computer Solutions, Inc. All Rights Reserved Summary
  • 37. © Integrated Computer Solutions, Inc. All Rights Reserved References 1. https://en.wikipedia.org/wiki/CAN_bus 2. https://en.wikipedia.org/wiki/Modbus 3. https://doc-snapshots.qt.io/qt5-dev/qtserialbus-index.html 4. http://code.qt.io/cgit/qt/qtserialbus.git/ 5. http://www.modbus.org 6. http://opengarages.org 7. ftp://ftp.ics.com/pub/pickup/qtserialbusexamples.zip
  • 38. © Integrated Computer Solutions, Inc. All Rights Reserved Questions?
  • 39. © Integrated Computer Solutions, Inc. All Rights Reserved QtSerialBus: Using Modbus and CAN bus with Qt Jeff Tranter <jtranter@ics.com> Integrated Computer Solutions, Inc.