-
Notifications
You must be signed in to change notification settings - Fork 49
Attribute id 2 bytes #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: indigo-devel
Are you sure you want to change the base?
Changes from 3 commits
8fe6110
00d24c5
61dad8c
1801f70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,10 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI | |
|
||
#include <boost/asio.hpp> | ||
|
||
#include <iostream> | ||
#include <unistd.h> | ||
#include <iomanip> | ||
|
||
namespace eip { | ||
|
||
Path::Path(bool pad_after_length) : pad_after_length_(pad_after_length) | ||
|
@@ -41,13 +45,26 @@ Path::Path(EIP_USINT class_id, EIP_USINT instance_id, EIP_USINT attribute_id, | |
addLogicalClass(class_id); | ||
addLogicalInstance(instance_id); | ||
addLogicalAttribute(attribute_id); | ||
//this->print(); | ||
} | ||
|
||
Path::Path(EIP_USINT class_id, EIP_USINT instance_id, EIP_UINT attribute_id, | ||
bool pad_after_length) : pad_after_length_(pad_after_length) | ||
{ | ||
path_buf_.reserve(7); | ||
addLogicalClass(class_id); | ||
addLogicalInstance(instance_id); | ||
addLogicalAttribute(attribute_id); | ||
//this->print(); | ||
} | ||
|
||
|
||
Path::Path(EIP_USINT class_id, EIP_USINT instance_id) : pad_after_length_(false) | ||
{ | ||
path_buf_.reserve(4); | ||
addLogicalClass(class_id); | ||
addLogicalInstance(instance_id); | ||
//this->print(); | ||
} | ||
|
||
void Path::addSegment(EIP_USINT type, EIP_USINT data) | ||
|
@@ -56,6 +73,13 @@ void Path::addSegment(EIP_USINT type, EIP_USINT data) | |
path_buf_.push_back(data); | ||
} | ||
|
||
void Path::addSegment(EIP_USINT type, EIP_UINT data) | ||
{ | ||
path_buf_.push_back(type); | ||
path_buf_.push_back( (EIP_USINT)(data&0xff) ); | ||
path_buf_.push_back( (EIP_USINT)((data&0xff00)>>8) ); | ||
} | ||
|
||
void Path::addLogicalClass(EIP_USINT class_id) | ||
{ | ||
addSegment(0x20, class_id); | ||
|
@@ -71,6 +95,11 @@ void Path::addLogicalAttribute(EIP_USINT attribute_id) | |
addSegment(0x30, attribute_id); | ||
} | ||
|
||
void Path::addLogicalAttribute(EIP_UINT attribute_id) | ||
{ | ||
addSegment(0x31, attribute_id); | ||
} | ||
|
||
void Path::addLogicalConnectionPoint(EIP_USINT connection_id) | ||
{ | ||
addSegment(0x2C, connection_id); | ||
|
@@ -94,4 +123,15 @@ Writer& Path::serialize(Writer& writer, bool pad_after_length) const | |
return writer; | ||
} | ||
|
||
void Path::print() const | ||
{ | ||
std::cout << "PATH: "; | ||
for (unsigned int ii=0; ii< path_buf_.size(); ii++) | ||
{ | ||
std::cout << std::hex << std::setfill('0') << std::setw(2) << (unsigned short int)path_buf_.at(ii); | ||
if ( (ii+1)%2 == 0 ) std::cout << " "; | ||
} | ||
std::cout << std::dec << std::endl; | ||
} | ||
|
||
|
||
} // namespace eip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove (here and elsewhere).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, they can be removed. They were used for debugging.