#include <session.h>
Public Member Functions | |
void | close () |
void | closeConnection (size_t n) |
int | createConnection (const EIP_CONNECTION_INFO_T &o_to_t, const EIP_CONNECTION_INFO_T &t_to_o) |
const Connection & | getConnection (size_t n) |
EIP_UDINT | getSerialNum () const |
EIP_UDINT | getSessionID () |
template<typename T > | |
T | getSingleAttribute (EIP_USINT class_id, EIP_USINT instance_id, EIP_USINT attribute_id, T v) |
void | getSingleAttributeSerializable (EIP_USINT class_id, EIP_USINT instance_id, EIP_USINT attribute_id, Serializable &result) |
EIP_UINT | getVendorID () const |
void | open (string hostname, string port="44818", string io_port="2222") |
CPFPacket | receiveIOPacket () |
void | sendIOPacket (CPFPacket &pkt) |
Session (shared_ptr< Socket > socket, shared_ptr< Socket > io_socket, EIP_UINT vendor_id=DEFAULT_VENDOR_ID, EIP_UDINT serial_num=DEFAULT_SERIAL_NUM) | |
template<typename T > | |
void | setSingleAttribute (EIP_USINT class_id, EIP_USINT instance_id, EIP_USINT attribute_id, T v) |
void | setSingleAttributeSerializable (EIP_USINT class_id, EIP_USINT instance_id, EIP_USINT attribute_id, shared_ptr< Serializable > data) |
virtual | ~Session () |
Private Member Functions | |
void | check_packet (EncapPacket &pkt, EIP_UINT exp_cmd) |
FRIEND_TEST (SessionTest, test_create_connection) | |
EncapPacket | sendCommand (EncapPacket &req) |
RRDataResponse | sendRRDataCommand (EIP_USINT service, const Path &path, shared_ptr< Serializable > data) |
Private Attributes | |
vector< Connection > | connections_ |
shared_ptr< Socket > | io_socket_ |
EIP_UDINT | my_serial_num_ |
EIP_UINT | my_vendor_id_ |
EIP_UDINT | next_connection_id_ |
EIP_UINT | next_connection_sn_ |
EIP_BYTE | recv_buffer_ [4 *1024] |
EIP_UDINT | session_id_ |
shared_ptr< Socket > | socket_ |
eip::Session::Session | ( | shared_ptr< Socket > | socket, |
shared_ptr< Socket > | io_socket, | ||
EIP_UINT | vendor_id = DEFAULT_VENDOR_ID , |
||
EIP_UDINT | serial_num = DEFAULT_SERIAL_NUM |
||
) |
Construct a session to use the given sockets
socket | Control socket, usually a TCP socket |
io_socket | IO Socket, usually a UDP socket directed at the same host |
vendor_id | My vendor ID number to be used if different than the default |
serial_num | My serial number to use when setting up connections |
Definition at line 52 of file session.cpp.
|
virtual |
Definition at line 67 of file session.cpp.
|
private |
Helper to check a returned encapsulation packet based on an expected command. Note that there are some warnings given that do not produce an exception
std::logic_error | if problems are found with the response |
Definition at line 194 of file session.cpp.
void eip::Session::close | ( | ) |
Close the session by unregistering the session and then closing the port
Definition at line 155 of file session.cpp.
void eip::Session::closeConnection | ( | size_t | n | ) |
Close the given connection number
n | Connection number to close |
Definition at line 327 of file session.cpp.
int eip::Session::createConnection | ( | const EIP_CONNECTION_INFO_T & | o_to_t, |
const EIP_CONNECTION_INFO_T & | t_to_o | ||
) |
Create an Ethernet/IP Connection for sending implicit messages
o_to_t | Origin to target connection info |
t_to_o | Target to origin connection info |
Definition at line 303 of file session.cpp.
|
private |
|
inline |
|
inline |
|
inline |
void eip::Session::getSingleAttributeSerializable | ( | EIP_USINT | class_id, |
EIP_USINT | instance_id, | ||
EIP_USINT | attribute_id, | ||
Serializable & | result | ||
) |
Get a single attribute from the given class / instance / attribute path
class_id | Class ID for the path to get |
instance_id | Instance ID number for the path to get |
attribute_id | Attribute ID number for the path to get |
result | Serializable that will accept the result |
Definition at line 230 of file session.cpp.
|
inline |
void eip::Session::open | ( | string | hostname, |
string | port = "44818" , |
||
string | io_port = "2222" |
||
) |
Open the session by opening the port and requesting a session.
hostname | hostname of the target |
port | port to use if other than the standard |
std::runtime_error | on problem opening the connection |
Definition at line 82 of file session.cpp.
CPFPacket eip::Session::receiveIOPacket | ( | ) |
Receive the next packet from the IO socket. This is a hack. I'd really much prefer to have the Session receive and do callback through the connection object, but there's no time for that now.
CPFPacket | the received packet |
Definition at line 342 of file session.cpp.
|
private |
Helper to send a command to the target as encapsulation packet and get the response, also as an encapsulation packet
req | Encapsulation packet to send |
Definition at line 171 of file session.cpp.
void eip::Session::sendIOPacket | ( | CPFPacket & | pkt | ) |
Send an IO packet. Yet another hack. Should really keep track of sequence numbers and things inside of the session, but again no time for that.
Definition at line 361 of file session.cpp.
|
private |
Helper to send an RR Data command to the target
service | Service code to send |
class_id | Class ID for the path |
instance_id | Instance ID number for the path |
attribute_id | Attribute ID number for the path |
data | Data to include. If null, then no data sent |
Definition at line 247 of file session.cpp.
void eip::Session::setSingleAttributeSerializable | ( | EIP_USINT | class_id, |
EIP_USINT | instance_id, | ||
EIP_USINT | attribute_id, | ||
shared_ptr< Serializable > | data | ||
) |
Set a single attribute from the given class / instance / attribute path
class_id | Class ID for the path to get |
instance_id | Instance ID number for the path to get |
attribute_id | Attribute ID number for the path to get |
data | Data to set the attribute to |
Definition at line 240 of file session.cpp.
|
private |