scanner_frames.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Pilz GmbH & Co. KG
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
16 #include <cstring>
18 #include "psen_scan/scanner_data.h"
19 #include <boost/crc.hpp>
20 
21 namespace psen_scan
22 {
30 StartMonitoringFrame::StartMonitoringFrame(const std::string& password,
31  const uint32_t& host_ip,
32  const uint32_t& host_udp_port)
33  : RESERVED_(0)
34  , password_("")
35  , OPCODE_(START_MONITORING_OPCODE)
36  , host_ip_(host_ip)
37  , host_udp_port_(host_udp_port)
38  , FIXED_SEQUENCE_(START_MONITORING_FIXED_SEQUENCE)
39  , RESERVED2_({ 0 })
40 {
41  strncpy(password_, password.c_str(), sizeof(password_));
42 
43  boost::crc_32_type result;
44  result.process_bytes(&RESERVED_, sizeof(StartMonitoringFrame) - sizeof(crc_));
45  crc_ = result.checksum();
46 }
47 
53 StopMonitoringFrame::StopMonitoringFrame(const std::string& password)
55 {
56  strncpy(password_, password.c_str(), sizeof(password_));
57 
58  boost::crc_32_type result;
59  result.process_bytes(&RESERVED_, sizeof(StopMonitoringFrame) - sizeof(crc_));
60  crc_ = result.checksum();
61 }
62 
63 } // namespace psen_scan
Frame containing all necessary fields for a Start Monitoring Command.
StopMonitoringFrame(const std::string &password="")
Construct a new Stop Monitoring Frame:: Stop Monitoring Frame object.
uint32_t const START_MONITORING_OPCODE
Opcode for StartMonitoring Frame.
Definition: scanner_data.h:32
uint64_t const START_MONITORING_FIXED_SEQUENCE
Fixed sequence for StartMonitoring Frame.
Definition: scanner_data.h:40
StartMonitoringFrame(const std::string &password="", const uint32_t &host_ip=0, const uint32_t &host_udp_port=0)
Construct a new Start Monitoring Frame:: Start Monitoring Frame object.
Frame containing all necessary fields for a Stop Monitoring Command.
uint32_t const STOP_MONITORING_OPCODE
Opcode for StopMonitoring Frame.
Definition: scanner_data.h:48


psen_scan
Author(s):
autogenerated on Mon Feb 28 2022 23:16:20