rllib  1
rlcanopenclient.h
Go to the documentation of this file.
1 /***************************************************************************
2  rlcanopen.cpp - description
3  -------------------
4  begin : Tue March 03 2004
5  copyright : (C) 2004 by Marc Br�tigam, Christian Wilmes, R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <sys/types.h>
19 #include <unistd.h>
20 #include "rlsocket.h"
21 #include "rlthread.h"
22 #include "rlcutil.h"
23 #include "rlwthread.h"
24 
25 #include "rlcanopentypes.h"
26 
28 
35 {
36 public:
37 
38  enum rl_msg {
39  MSG_SEND = 0,
50  };
51 
55  rlCanOpenClient(int _port, char* _remoteadress);
59  int connect();
61  int disconnect();
62 
63 
69  int sdo_read( int _boardnr,
70  int _nodeid,int _objectindex,
71  int _subindex,
72  rlCanOpenTypes &_sdo_data);
73 
79  int sdo_write(int _boardnr,
80  int _nodeid,int _objectindex,
81  int _subindex,
82  rlCanOpenTypes &_sdo_data);
83 
88  int pdo_receive(int _boardnr,
89  int _nodeid,int _pdonr,
90  int _mappingnr,
91  rlCanOpenTypes &_pdo_data);
92 
97  int pdo_receive(int _boardnr,
98  int _nodeid,int _pdonr,
99  rlCanOpenTypes &_pdo_data);
100 
105  int pdo_transmit(int _boardnr,
106  int _nodeid,int _pdonr,
107  int _mappingnr,
108  rlCanOpenTypes &_pdo_data);
109 
114  int pdo_transmit(int _boardnr,
115  int _nodeid,
116  int _pdonr,
117  rlCanOpenTypes &_pdo_data);
118 
120  int sendNMTCommand( int _boardnr,
121  int _nodeid,
122  unsigned char _cmd,
123  bool &returnstate);
124 
126  int restartBoard(int _boardnr, int _restarttype, bool &returnstate);
127 
129  int getNodeState(int _boardnr, int _nodeid,rlCanOpenTypes &_data);
130 
132  void setPort(int _port);
133 
135  void setAdr(char* _adr);
136 
137 private:
139  int pid;
140 
142  bool connected;
143 
145  int port;
146 
148  char remoteadress[40];
149 
154 };
155 
156 //#####################################################################################
157 // convenience class for client users
159 {
160 public:
161  rlCanClient(int _port, char* _remoteadress, int _boardnr);
162  ~rlCanClient();
163  int sdo_read(int _nodeid, int _objectindex, int _subindex, rlCanOpenTypes &_sdo_data);
164  int sdo_write(int _nodeid,int _objectindex, int _subindex, rlCanOpenTypes &_sdo_data);
165  int pdo_receive(int _nodeid, int _pdonr, int _mappingnr, rlCanOpenTypes &_pdo_data);
166  int pdo_receive(int _nodeid, int _pdonr, rlCanOpenTypes &_pdo_data);
167  int pdo_transmit(int _nodeid, int _pdonr, int _mappingnr, rlCanOpenTypes &_pdo_data);
168  int pdo_transmit(int _nodeid, int _pdonr, rlCanOpenTypes &_pdo_data);
169  int sendNMTCommand(int _nodeid, unsigned char _cmd, bool &returnstate);
170  int restartBoard(int _restarttype, bool &returnstate);
171  int getNodeState(int _nodeid, rlCanOpenTypes &_data);
172 private:
173  int boardnr;
174 };
int pdo_transmit(int _boardnr, int _nodeid, int _pdonr, int _mappingnr, rlCanOpenTypes &_pdo_data)
sends a single mapped pdo object to daemon.
int sendNMTCommand(int _nodeid, unsigned char _cmd, bool &returnstate)
int disconnect()
disconnects from daemon
char remoteadress[40]
string of remoteadress
class to handle CANopen types
Class performs API rlcanopen functions remotely through tcp sockets.
int sdo_read(int _boardnr, int _nodeid, int _objectindex, int _subindex, rlCanOpenTypes &_sdo_data)
remotely reads a certain object from the object dictionary of a node.
int restartBoard(int _restarttype, bool &returnstate)
int pdo_receive(int _boardnr, int _nodeid, int _pdonr, int _mappingnr, rlCanOpenTypes &_pdo_data)
receives single mapped pdo object from daemon.
rlCanOpenClient()
initializes the client on localhost port 5000
rlCanClient(int _port, char *_remoteadress, int _boardnr)
int pdo_receive(int _nodeid, int _pdonr, int _mappingnr, rlCanOpenTypes &_pdo_data)
int restartBoard(int _boardnr, int _restarttype, bool &returnstate)
forces daemon to restart canopen device.
int pdo_transmit(int _nodeid, int _pdonr, int _mappingnr, rlCanOpenTypes &_pdo_data)
int sdo_write(int _nodeid, int _objectindex, int _subindex, rlCanOpenTypes &_sdo_data)
int sendNMTCommand(int _boardnr, int _nodeid, unsigned char _cmd, bool &returnstate)
sends a NMT command to daemon.
int sdo_write(int _boardnr, int _nodeid, int _objectindex, int _subindex, rlCanOpenTypes &_sdo_data)
remotely writes data into a certain object from the object dictionary of a node
rlSocket * socket
pointer to socket object
int getNodeState(int _nodeid, rlCanOpenTypes &_data)
int pid
variable contains process id
int connect()
opens a new connection to a running rlCanOpenDaemon
int getNodeState(int _boardnr, int _nodeid, rlCanOpenTypes &_data)
receives node state data of particular node from daemon.
bool connected
flag indicates connection status
int port
variable contains port
int sdo_read(int _nodeid, int _objectindex, int _subindex, rlCanOpenTypes &_sdo_data)
~rlCanOpenClient()
destructor disconnects client
int client_timeout
timeout in ms
void setPort(int _port)
setter for private port variable
void setAdr(char *_adr)
setter for private remoteadress variable