3
3
// Licensed under: MIT License <http://opensource.org/licenses/MIT>
4
4
5
5
#include " TCP/connection.hpp"
6
+ #include < cstdint>
6
7
#include < sys/poll.h>
7
8
#include < sys/socket.h>
8
9
@@ -25,16 +26,16 @@ std::vector<uint8_t> Connection::sendRequest(const MB::ModbusRequest &req) {
25
26
std::vector<uint8_t > rawReq;
26
27
rawReq.reserve (6 );
27
28
28
- rawReq.push_back (reinterpret_cast <const uint8_t *>(&_messageID)[1 ]);
29
- rawReq.push_back (reinterpret_cast <const uint8_t *>(&_messageID)[0 ]);
29
+ rawReq.push_back (static_cast < const uint8_t &&>( reinterpret_cast <const uint8_t *>(&_messageID)[1 ]) );
30
+ rawReq.push_back (static_cast < const uint8_t &&>( reinterpret_cast <const uint8_t *>(&_messageID)[0 ]) );
30
31
rawReq.push_back (0x00 );
31
32
rawReq.push_back (0x00 );
32
33
33
34
std::vector<uint8_t > dat = req.toRaw ();
34
35
35
36
uint32_t size = dat.size ();
36
- rawReq.push_back (reinterpret_cast <uint16_t *>(&size)[1 ]);
37
- rawReq.push_back (reinterpret_cast <uint16_t *>(&size)[0 ]);
37
+ rawReq.push_back (static_cast < const uint16_t &&>( reinterpret_cast <const uint16_t *>(&size)[1 ]) );
38
+ rawReq.push_back (static_cast < const uint16_t &&>( reinterpret_cast <const uint16_t *>(&size)[0 ]) );
38
39
39
40
rawReq.insert (rawReq.end (), dat.begin (), dat.end ());
40
41
@@ -47,16 +48,16 @@ std::vector<uint8_t> Connection::sendResponse(const MB::ModbusResponse &res) {
47
48
std::vector<uint8_t > rawReq;
48
49
rawReq.reserve (6 );
49
50
50
- rawReq.push_back (reinterpret_cast <const uint8_t *>(&_messageID)[1 ]);
51
- rawReq.push_back (reinterpret_cast <const uint8_t *>(&_messageID)[0 ]);
51
+ rawReq.push_back (static_cast < const uint8_t &&>( reinterpret_cast <const uint8_t *>(&_messageID)[1 ]) );
52
+ rawReq.push_back (static_cast < const uint8_t &&>( reinterpret_cast <const uint8_t *>(&_messageID)[0 ]) );
52
53
rawReq.push_back (0x00 );
53
54
rawReq.push_back (0x00 );
54
55
55
56
std::vector<uint8_t > dat = res.toRaw ();
56
57
57
58
uint32_t size = dat.size ();
58
- rawReq.push_back (reinterpret_cast <uint16_t *>(&size)[1 ]);
59
- rawReq.push_back (reinterpret_cast <uint16_t *>(&size)[0 ]);
59
+ rawReq.push_back (static_cast < const uint16_t &&>( reinterpret_cast <const uint16_t *>(&size)[1 ]) );
60
+ rawReq.push_back (static_cast < const uint16_t &&>( reinterpret_cast <const uint16_t *>(&size)[0 ]) );
60
61
61
62
rawReq.insert (rawReq.end (), dat.begin (), dat.end ());
62
63
@@ -69,16 +70,16 @@ std::vector<uint8_t> Connection::sendException(const MB::ModbusException &ex) {
69
70
std::vector<uint8_t > rawReq;
70
71
rawReq.reserve (6 );
71
72
72
- rawReq.push_back (reinterpret_cast <const uint8_t *>(&_messageID)[1 ]);
73
- rawReq.push_back (reinterpret_cast <const uint8_t *>(&_messageID)[0 ]);
73
+ rawReq.push_back (static_cast < const uint8_t &&>( reinterpret_cast <const uint8_t *>(&_messageID)[1 ]) );
74
+ rawReq.push_back (static_cast < const uint8_t &&>( reinterpret_cast <const uint8_t *>(&_messageID)[0 ]) );
74
75
rawReq.push_back (0x00 );
75
76
rawReq.push_back (0x00 );
76
77
77
78
std::vector<uint8_t > dat = ex.toRaw ();
78
79
79
80
uint32_t size = dat.size ();
80
- rawReq.push_back (reinterpret_cast <uint16_t *>(&size)[1 ]);
81
- rawReq.push_back (reinterpret_cast <uint16_t *>(&size)[0 ]);
81
+ rawReq.push_back (static_cast < const uint16_t &&>( reinterpret_cast <const uint16_t *>(&size)[1 ]) );
82
+ rawReq.push_back (static_cast < const uint16_t &&>( reinterpret_cast <const uint16_t *>(&size)[0 ]) );
82
83
83
84
rawReq.insert (rawReq.end (), dat.begin (), dat.end ());
84
85
0 commit comments