KaCanOpen
 All Classes Functions Variables Typedefs Enumerations Pages
sdo_response.h
1 /*
2  * Copyright (c) 2015, Thomas Keh
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #pragma once
33 
34 #include <cstdint>
35 #include <string>
36 
37 namespace kaco {
38 
43 struct SDOResponse {
44 
46  uint8_t node_id;
47 
49  uint8_t command;
50 
54  uint16_t index;
55 
59  uint8_t subindex;
60 
62  uint8_t data[7];
63 
65  uint16_t get_index() const;
66 
68  uint16_t get_subindex() const;
69 
71  uint8_t get_length() const;
72 
74  uint8_t failed() const;
75 
77  uint32_t get_data() const;
78 
80  void print() const;
81 
84  std::string get_error() const;
85 
86 };
87 
88 } // end namespace kaco
void print() const
Prints the response to command line.
uint8_t get_length() const
Returns the number of data bytes.
uint8_t failed() const
Check if the transfer failed.
This struct contains the response of a SDO request. Note that there are two types of response - segme...
Definition: sdo_response.h:43
uint16_t index
Dictionary index.
Definition: sdo_response.h:54
uint16_t get_subindex() const
Returns the subindex (only for expedited transfer).
std::string get_error() const
Returns a human-readable representation of the error (only if failed()==true)
uint8_t command
SDO command specifier.
Definition: sdo_response.h:49
uint8_t subindex
Subindex.
Definition: sdo_response.h:59
uint16_t get_index() const
Returns the dictionary index (only for expedited transfer).
uint32_t get_data() const
Returns the data as a single 4-byte value (only for expedited transfer).
uint8_t node_id
Node id.
Definition: sdo_response.h:46
uint8_t data[7]
Data bytes.
Definition: sdo_response.h:62